File |
Line |
org/abstracthorizon/danube/auth/jaas/keystore/KeyStoreLoginModule.java |
190
|
org/abstracthorizon/danube/auth/jaas/memory/PropertiesLoginModule.java |
140
|
obtainCertificates();
status = AUTHENTICATED;
return true;
}
throw new LoginException("The login module is not initialized");
}
/**
* This method obtains username and password from the party that tries to log in
* @throws LoginException
*/
private void obtainAuthenticationDetails() throws LoginException {
TextOutputCallback bannerCallback = new TextOutputCallback(TextOutputCallback.INFORMATION, "Please login to keystore");
NameCallback aliasCallback = new NameCallback("Keystore alias: ");
PasswordCallback privateKeyPasswordCallback = new PasswordCallback("Password: ", false);
ConfirmationCallback confirmationCallback = new ConfirmationCallback(ConfirmationCallback.INFORMATION, ConfirmationCallback.OK_CANCEL_OPTION,
ConfirmationCallback.OK);
try {
callbackHandler.handle(
new Callback[]{
bannerCallback,
aliasCallback,
privateKeyPasswordCallback,
confirmationCallback}
);
} catch (IOException e) {
throw new LoginException("Exception while getting keystore alias and password: " + e);
} catch (UnsupportedCallbackException e) {
throw new LoginException("Error: " + e.getCallback().toString() + " is not available to retrieve authentication "
+ " information from the user");
}
int confirmationResult = confirmationCallback.getSelectedIndex();
if (confirmationResult == ConfirmationCallback.CANCEL) {
throw new LoginException("Login cancelled");
}
username = aliasCallback.getName();
char[] tmpPassword = privateKeyPasswordCallback.getPassword();
userPassword = new char[tmpPassword.length];
System.arraycopy(tmpPassword, 0, userPassword, 0, tmpPassword.length);
for (int i = 0; i < tmpPassword.length; i++) {
|
File |
Line |
org/abstracthorizon/danube/auth/jaas/keystore/KeyStoreLoginModule.java |
322
|
org/abstracthorizon/danube/auth/jaas/memory/PropertiesLoginModule.java |
250
|
subject.getPrincipals().addAll(principals);
subject.getPublicCredentials().add(publicCredentials);
subject.getPrivateCredentials().add(privateCredential);
status = LOGGED_IN;
return true;
}
}
if (status == INITIALIZED) {
logoutImpl();
throw new LoginException("Authentication failed");
}
throw new LoginException("The login module is not initialized");
}
/**
* Aborts login
* @return <code>true</code> if successful
*/
public boolean abort() throws LoginException {
if ((status == AUTHENTICATED) || (status == LOGGED_IN)) {
logoutImpl();
return true;
}
return false;
}
/**
* Logs out
* @return <code>true</code> if successful
*/
public boolean logout() throws LoginException {
if (status == LOGGED_IN) {
logoutImpl();
return true;
}
return false;
}
/**
* Internal log out method
* @throws LoginException
*/
private void logoutImpl() throws LoginException {
for (int i = 0; i < userPassword.length; i++) {
userPassword[i] = '\0';
}
userPassword = null;
if (subject.isReadOnly()) {
|
File |
Line |
org/abstracthorizon/danube/auth/jaas/keystore/KeyStoreModuleService.java |
94
|
org/abstracthorizon/danube/auth/jaas/memory/PropertiesModuleService.java |
77
|
public PropertiesModuleService() {
}
/**
* Starts the service - adding keystore login module to system application configuration entry
* @throws Exception
*/
public void start() throws Exception {
AppConfigurationEntry.LoginModuleControlFlag flag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED;
if (AppConfigurationEntry.LoginModuleControlFlag.REQUIRED.toString().indexOf(controlFlag) > 0 ) {
flag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED;
} else if( AppConfigurationEntry.LoginModuleControlFlag.REQUISITE.toString().indexOf(controlFlag) > 0 ) {
flag = AppConfigurationEntry.LoginModuleControlFlag.REQUISITE;
} else if( AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT.toString().indexOf(controlFlag) > 0 ) {
flag = AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT;
}else if( AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL.toString().indexOf(controlFlag) > 0 ) {
flag = AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL;
}
|
File |
Line |
org/abstracthorizon/danube/auth/jaas/keystore/KeyStoreLoginModule.java |
374
|
org/abstracthorizon/danube/auth/jaas/memory/PropertiesLoginModule.java |
302
|
principals = null;
publicCredentials = null;
status = INITIALIZED;
Iterator<Object> it = subject.getPrivateCredentials().iterator();
while (it.hasNext()) {
Object obj = it.next();
if (privateCredential.equals(obj)) {
privateCredential = null;
try {
((Destroyable) obj).destroy();
break;
} catch (DestroyFailedException dfe) {
throw new LoginException("Unable to destroy private credential, " + obj.getClass().getName() + ": " + dfe.getMessage());
}
}
}
throw new LoginException("Unable to remove Principal (X500Principal) and public credential from read-only Subject");
}
if (principals != null) {
|