agave-common/common-core/src/main/java/org/iplantc/service/common/auth/AgaveGSSManagerImpl.java
/**
	 * Acquires GSI GSS credentials. First, it tries to find the credentials in
	 * the private credential set of the current JAAS Subject. If the Subject is
	 * not set or credentials are not found in the Subject, it tries to get a
	 * default user credential (usually an user proxy file)
	 *
	 * @param lifetime
	 *            Only lifetime set to {@link GSSCredential#DEFAULT_LIFETIME
	 *            GSSCredential.DEFAULT_LIFETIME} is allowed.
	 * @see org.globus.gsi.X509Credential#getDefaultCredential()
	 */
Acquires GSI GSS credentials. First, it tries to find the credentials in
the private credential set of the current JAAS Subject. If the Subject is
not set or credentials are not found in the Subject, it tries to get a
default user credential (usually an user proxy file)


Acquires GSI GSS credentials . First it tries to find the credentials in the private credential set of the current JAAS Subject . If the Subject is not set or credentials are not found in the Subject it tries to get a default user credential ( usually an user proxy file )
public GSSCredential createCredential(GSSName name, int lifetime, Oid mech,
			int usage) throws GSSException {
		checkMechanism(mech);
		if (name != null) {
			if (name.isAnonymous()) {
				return new AgaveGSSCredentialImpl();
			} else {
				throw new GSSException(GSSException.UNAVAILABLE);
			}
		}
		AgaveX509Credential cred = null;
		Subject subject = JaasSubject.getCurrentSubject();
		if (subject != null) {
			logger.debug("Getting credential from context");
			Set gssCreds = subject
					.getPrivateCredentials(AgaveGSSCredentialImpl.class);
			if (gssCreds != null) {
				Iterator iter = gssCreds.iterator();
				if (iter.hasNext()) {
					AgaveGSSCredentialImpl credImpl = (AgaveGSSCredentialImpl) iter
							.next();
					cred = (AgaveX509Credential) credImpl.getX509Credential();
				}
			}
		}
		if (lifetime == GSSCredential.INDEFINITE_LIFETIME || lifetime > 0) {
			throw new GlobusGSSException(GSSException.FAILURE,
					GlobusGSSException.BAD_ARGUMENT, "badLifetime01");
		}
		if (cred == null) {
			logger.debug("Getting default credential");
			try {
				cred = AgaveX509Credential.getDefaultCredential();
			} catch (CredentialException e) {
				throw new GlobusGSSException(GSSException.DEFECTIVE_CREDENTIAL,
						e);
			} catch (Exception e) {
				throw new GlobusGSSException(GSSException.DEFECTIVE_CREDENTIAL,
						e);
			}
			return getDefaultCredential(cred, usage);
		} else {
			return new AgaveGSSCredentialImpl(cred, usage);
		}
	}
public GSSCredential createCredential ( GSSName name , int lifetime , Oid mech , int usage ) throws GSSException { checkMechanism ( mech ) ; if ( name != null ) { if ( name . isAnonymous ( ) ) { return new AgaveGSSCredentialImpl ( ) ; } else { throw new GSSException ( GSSException . UNAVAILABLE ) ; } } AgaveX509Credential cred = null ; Subject subject = JaasSubject . getCurrentSubject ( ) ; if ( subject != null ) { logger . debug ( "Getting credential from context" ) ; Set gssCreds = subject . getPrivateCredentials ( AgaveGSSCredentialImpl . class ) ; if ( gssCreds != null ) { Iterator iter = gssCreds . iterator ( ) ; if ( iter . hasNext ( ) ) { AgaveGSSCredentialImpl credImpl = ( AgaveGSSCredentialImpl ) iter . next ( ) ; cred = ( AgaveX509Credential ) credImpl . getX509Credential ( ) ; } } } if ( lifetime == GSSCredential . INDEFINITE_LIFETIME || lifetime > 0 ) { throw new GlobusGSSException ( GSSException . FAILURE , GlobusGSSException . BAD_ARGUMENT , "badLifetime01" ) ; } if ( cred == null ) { logger . debug ( "Getting default credential" ) ; try { cred = AgaveX509Credential . getDefaultCredential ( ) ; } catch ( CredentialException e ) { throw new GlobusGSSException ( GSSException . DEFECTIVE_CREDENTIAL , e ) ; } catch ( Exception e ) { throw new GlobusGSSException ( GSSException . DEFECTIVE_CREDENTIAL , e ) ; } return getDefaultCredential ( cred , usage ) ; } else { return new AgaveGSSCredentialImpl ( cred , usage ) ; } }
Acquires GSI GSS credentials.
Acquires GSI GSS credentials .
// lifetime not supported