public boolean login() throws LoginException {
switch (status) {
case UNINITIALIZED:
default :
    throw new LoginException("The login module is not initialized");
case INITIALIZED:
case AUTHENTICATED:
  if (token && !nullStream) {
    throw new LoginException("if keyStoreType is " + P11KEYSTORE + " then keyStoreURL must be "+ NONE);
  }
if (token && privateKeyPasswordURL != null) {
  throw new LoginException("if keyStoreType is " + P11KEYSTORE + " then privateKeyPasswordURL must not be specified");
}
if (protectedPath && (keyStorePasswordURL != null || privateKeyPasswordURL != null)) {
throw new LoginException("if protected is true then keyStorePasswordURL and " + "privateKeyPasswordURL must not be specified");
}
if (protectedPath) {
getAliasAndPasswords(PROTECTED_PATH);
}
 else if (token) {
getAliasAndPasswords(TOKEN);
}
 else {
getAliasAndPasswords(NORMAL);
}
try {
getKeyStoreInfo();
}
  finally {
if (privateKeyPassword != null && privateKeyPassword != keyStorePassword) {
Arrays.fill(privateKeyPassword,'\0');
privateKeyPassword=null;
}
if (keyStorePassword != null) {
Arrays.fill(keyStorePassword,'\0');
keyStorePassword=null;
}
}
status=AUTHENTICATED;
return true;
case LOGGED_IN:
return true;
}
}

public boolean login ( ) throws LoginException { switch ( status ) { case UNINITIALIZED : default : throw new LoginException ( "The login module is not initialized" ) ; case INITIALIZED : case AUTHENTICATED : if ( token && ! nullStream ) { throw new LoginException ( "if keyStoreType is " + P11KEYSTORE + " then keyStoreURL must be " + NONE ) ; } if ( token && privateKeyPasswordURL != null ) { throw new LoginException ( "if keyStoreType is " + P11KEYSTORE + " then privateKeyPasswordURL must not be specified" ) ; } if ( protectedPath && ( keyStorePasswordURL != null || privateKeyPasswordURL != null ) ) { throw new LoginException ( "if protected is true then keyStorePasswordURL and " + "privateKeyPasswordURL must not be specified" ) ; } if ( protectedPath ) { getAliasAndPasswords ( PROTECTED_PATH ) ; } else if ( token ) { getAliasAndPasswords ( TOKEN ) ; } else { getAliasAndPasswords ( NORMAL ) ; } try { getKeyStoreInfo ( ) ; } finally { if ( privateKeyPassword != null && privateKeyPassword != keyStorePassword ) { Arrays . fill ( privateKeyPassword , '\0' ) ; privateKeyPassword = null ; } if ( keyStorePassword != null ) { Arrays . fill ( keyStorePassword , '\0' ) ; keyStorePassword = null ; } } status = AUTHENTICATED ; return true ; case LOGGED_IN : return true ; } }
authenticate the user . < p > get the keystore alias and relevant passwords . retrieve the alias ' s principal and credentials from the keystore . < p >
