mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Cs 1268 gs
Co-authored-by: Pearl Dsilva <pearl.dsilva@shapeblue.com>
This commit is contained in:
		
							parent
							
								
									22e0fc8752
								
							
						
					
					
						commit
						1d34eed43c
					
				| @ -104,6 +104,7 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, | ||||
|     private static final ConfigKey<Integer> VmJobLockTimeout = new ConfigKey<Integer>("Advanced", | ||||
|             Integer.class, "vm.job.lock.timeout", "1800", | ||||
|             "Time in seconds to wait in acquiring lock to submit a vm worker job", false); | ||||
|     private static final ConfigKey<Boolean> HidePassword = new ConfigKey<Boolean>("Advanced", Boolean.class, "log.hide.password", "true", "If set to true, the password is hidden", true, ConfigKey.Scope.Global); | ||||
| 
 | ||||
|     private static final Logger s_logger = Logger.getLogger(AsyncJobManagerImpl.class); | ||||
| 
 | ||||
| @ -159,7 +160,7 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, | ||||
| 
 | ||||
|     @Override | ||||
|     public ConfigKey<?>[] getConfigKeys() { | ||||
|         return new ConfigKey<?>[] {JobExpireMinutes, JobCancelThresholdMinutes, VmJobLockTimeout}; | ||||
|         return new ConfigKey<?>[] {JobExpireMinutes, JobCancelThresholdMinutes, VmJobLockTimeout, HidePassword}; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
| @ -255,9 +256,11 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, | ||||
|     @DB | ||||
|     public void completeAsyncJob(final long jobId, final Status jobStatus, final int resultCode, final String resultObject) { | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Complete async job-" + jobId + ", jobStatus: " + jobStatus + ", resultCode: " + resultCode + ", result: " + resultObject); | ||||
|             String resultObj = obfuscatePassword(resultObject, HidePassword.value()); | ||||
|             s_logger.debug("Complete async job-" + jobId + ", jobStatus: " + jobStatus + ", resultCode: " + resultCode + ", result: " + resultObj); | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         final AsyncJobVO job = _jobDao.findById(jobId); | ||||
|         if (job == null) { | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
| @ -460,6 +463,20 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, | ||||
|         return job; | ||||
|     } | ||||
| 
 | ||||
|     private String obfuscatePassword(String result, boolean hidePassword) { | ||||
|         if (hidePassword) { | ||||
|             String pattern = "\"password\":"; | ||||
|             if (result != null) { | ||||
|                 if (result.contains(pattern)) { | ||||
|                     String[] resp = result.split(pattern); | ||||
|                     String psswd = resp[1].toString().split(",")[0]; | ||||
|                     result = resp[0] + pattern + psswd.replace(psswd.substring(2, psswd.length() - 1), "*****") + "," + resp[1].split(",", 2)[1]; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
|     private void scheduleExecution(final AsyncJobVO job) { | ||||
|         scheduleExecution(job, false); | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user