public GSSCredential createCredential ( byte [ ] buff , int option , int lifetime , Oid mech , int usage ) throws GSSException { checkMechanism ( mech ) ; if ( buff == null || buff . length < 1 ) { throw new GlobusGSSException ( GSSException . FAILURE , GlobusGSSException . BAD_ARGUMENT , "invalidBuf" ) ; } if ( lifetime == GSSCredential . INDEFINITE_LIFETIME || lifetime > 0 ) { // lifetime not supported throw new GlobusGSSException ( GSSException . FAILURE , GlobusGSSException . BAD_ARGUMENT , "badLifetime01" ) ; } InputStream input = null ; switch ( option ) { case ExtendedGSSCredential . IMPEXP_OPAQUE : input = new ByteArrayInputStream ( buff ) ; break ; case ExtendedGSSCredential . IMPEXP_MECH_SPECIFIC : String s = new String ( buff ) ; int pos = s . indexOf ( ' ' ) ; if ( pos == - 1 ) { throw new GSSException ( GSSException . FAILURE ) ; } String filename = s . substring ( pos + 1 ) . trim ( ) ; try { input = new FileInputStream ( filename ) ; } catch ( IOException e ) { throw new GlobusGSSException ( GSSException . FAILURE , e ) ; } break ; default : throw new GlobusGSSException ( GSSException . FAILURE , GlobusGSSException . BAD_ARGUMENT , "unknownOption" , new Object [ ] { new Integer ( option ) } ) ; } X509Credential cred = null ; try { cred = new X509Credential ( input ) ; } catch ( CredentialException e ) { throw new GlobusGSSException ( GSSException . DEFECTIVE_CREDENTIAL , e ) ; } catch ( Exception e ) { throw new GlobusGSSException ( GSSException . DEFECTIVE_CREDENTIAL , e ) ; } return new GlobusGSSCredentialImpl ( cred , usage ) ; }
Imports a credential .