agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/managers/JobRequestProcessor.java
/**
	 * Can we login to the remote system?
	 *
	 * @param executionSystem the system on which the job will run
	 * @throws JobProcessingException if the system is not accessible, auth fails, etc.
	 */
Can we login to the remote system.
@param executionSystem the system on which the job will run
@throws JobProcessingException if the system is not accessible, auth fails, etc.
Can we login to the remote system . @param executionSystem the system on which the job will run @throws JobProcessingException if the system is not accessible auth fails etc .
public boolean checkExecutionSystemLogin(ExecutionSystem executionSystem) throws JobProcessingException {
		JobManager manager = getJobManager();
		try {
			Instant lastAccess = manager.getLastSuccessfulSystemAccess(executionSystem);
			if (lastAccess == null) {
				AuthConfig authConfig = getExecutionSystem().getLoginConfig().getAuthConfigForInternalUsername(getInternalUsername());
				if (authConfig == null) {
					String msg1 = "Null authConfig encountered.";
					String msg2 = " There are no credentials configured for the system: " + getExecutionSystem().getSystemId() + "." +
							" Please update (POST) the system to configure credentials using the URL systems/v2/" + getExecutionSystem().getSystemId()
							+ "/credentials.";
					log.error(msg1 + msg2);
					throw new JobProcessingException(412, msg2);
				}
				String salt = getExecutionSystem().getEncryptionKeyForAuthConfig(authConfig);
				if (authConfig.isCredentialExpired(salt)) {
					String msg = " Credentials of the " + (authConfig.isSystemDefault() ? "Default user" : "Internal user " + getInternalUsername())
							+ " for the system " + getExecutionSystem().getSystemId() + " have expired."
							+ " Please update the system with a valid " + getExecutionSystem().getLoginConfig().getType()
							+ " of execution credentials for the execution system and resubmit the job.";
					log.error(msg);
					throw new JobProcessingException(412, msg);
				}
				try {
					if (getExecutionSystem().getRemoteSubmissionClient(getInternalUsername()).canAuthentication()) {
						manager.setLastSuccessfulSystemAccess(executionSystem, Instant.now());
					} else {
						String msg = "Unable to authenticate to " + getExecutionSystem().getSystemId();
						log.error(msg);
						throw new RemoteExecutionException(msg);
					}
				} catch (Throwable e) {
					String msg = "Unable to authenticate to " + getExecutionSystem().getSystemId() + " with the " +
							(authConfig.isSystemDefault() ? "default " : "internal user " + getInternalUsername()) +
							"credential. Please check the " + getExecutionSystem().getLoginConfig().getType() +
							" execution credential for the execution system and resubmit the job.";
					log.error(msg, e);
					throw new JobProcessingException(412, msg);
				}
			}
		} catch (JobProcessingException e) {
			manager.setLastSuccessfulSystemAccess(executionSystem, null);
			throw e;
		}
		return true;
	}
public boolean checkExecutionSystemLogin ( ExecutionSystem executionSystem ) throws JobProcessingException { JobManager manager = getJobManager ( ) ; try { Instant lastAccess = manager . getLastSuccessfulSystemAccess ( executionSystem ) ; if ( lastAccess == null ) { AuthConfig authConfig = getExecutionSystem ( ) . getLoginConfig ( ) . getAuthConfigForInternalUsername ( getInternalUsername ( ) ) ; if ( authConfig == null ) { String msg1 = "Null authConfig encountered." ; String msg2 = " There are no credentials configured for the system: " + getExecutionSystem ( ) . getSystemId ( ) + "." + " Please update (POST) the system to configure credentials using the URL systems/v2/" + getExecutionSystem ( ) . getSystemId ( ) + "/credentials." ; log . error ( msg1 + msg2 ) ; throw new JobProcessingException ( 412 , msg2 ) ; } String salt = getExecutionSystem ( ) . getEncryptionKeyForAuthConfig ( authConfig ) ; if ( authConfig . isCredentialExpired ( salt ) ) { String msg = " Credentials of the " + ( authConfig . isSystemDefault ( ) ? "Default user" : "Internal user " + getInternalUsername ( ) ) + " for the system " + getExecutionSystem ( ) . getSystemId ( ) + " have expired." + " Please update the system with a valid " + getExecutionSystem ( ) . getLoginConfig ( ) . getType ( ) + " of execution credentials for the execution system and resubmit the job." ; log . error ( msg ) ; throw new JobProcessingException ( 412 , msg ) ; } try { if ( getExecutionSystem ( ) . getRemoteSubmissionClient ( getInternalUsername ( ) ) . canAuthentication ( ) ) { manager . setLastSuccessfulSystemAccess ( executionSystem , Instant . now ( ) ) ; } else { String msg = "Unable to authenticate to " + getExecutionSystem ( ) . getSystemId ( ) ; log . error ( msg ) ; throw new RemoteExecutionException ( msg ) ; } } catch ( Throwable e ) { String msg = "Unable to authenticate to " + getExecutionSystem ( ) . getSystemId ( ) + " with the " + ( authConfig . isSystemDefault ( ) ? "default " : "internal user " + getInternalUsername ( ) ) + "credential. Please check the " + getExecutionSystem ( ) . getLoginConfig ( ) . getType ( ) + " execution credential for the execution system and resubmit the job." ; log . error ( msg , e ) ; throw new JobProcessingException ( 412 , msg ) ; } } } catch ( JobProcessingException e ) { manager . setLastSuccessfulSystemAccess ( executionSystem , null ) ; throw e ; } return true ; }
Can we login to the remote system?
Can we login to the remote system?
// look up the last update time. We can skip the check if it's been access in the last few minutes. //When a system is cloned, a authConfig is not associated with it by default. It needs to be separately set. // set the lat successful update time on this system // clear the last successful update time as it failed here