use of com.sun.identity.authentication.internal.AuthSubject in project OpenAM by OpenRock.
the class SpecialRepo method authenticate.
public boolean authenticate(Callback[] credentials) throws IdRepoException, AuthLoginException {
debug.message("SpecialRepo:authenticate called");
// Obtain user name and password from credentials and authenticate
String username = null;
String password = null;
for (int i = 0; i < credentials.length; i++) {
if (credentials[i] instanceof NameCallback) {
username = ((NameCallback) credentials[i]).getName();
if (debug.messageEnabled()) {
debug.message("SpecialRepo:authenticate username: " + username);
}
} else if (credentials[i] instanceof PasswordCallback) {
char[] passwd = ((PasswordCallback) credentials[i]).getPassword();
if (passwd != null) {
password = new String(passwd);
debug.message("SpecialRepo:authN passwd present");
}
}
}
if (username == null || password == null) {
return (false);
}
Map sharedState = new HashMap();
sharedState.put(ISAuthConstants.SHARED_STATE_USERNAME, username);
sharedState.put(ISAuthConstants.SHARED_STATE_PASSWORD, password);
debug.message("SpecialRepo:authenticate inst. SMSAuthModule");
SMSAuthModule module = new SMSAuthModule();
debug.message("SpecialRepo:authenticate SMSAuthModule:init");
module.initialize(new AuthSubject(), null, sharedState, Collections.EMPTY_MAP);
boolean answer = false;
try {
answer = module.login();
if (debug.messageEnabled()) {
debug.message("SpecialRepo:authenticate login: " + answer);
}
} catch (LoginException le) {
if (debug.warningEnabled()) {
debug.warning("authentication: login exception", le);
}
if (le instanceof AuthLoginException) {
throw ((AuthLoginException) le);
}
}
return (answer);
}
Aggregations