String username = (String)sharedState.get("javax.security.auth.login.name");
String password = (String)sharedState.get("javax.security.auth.login.password");
if (username == null || password == null)
return false;
Authenticator authenticator = (Authenticator)getContainer().getComponentInstanceOfType(Authenticator.class);
if (authenticator == null)
{
throw new LoginException("No Authenticator component found, check your configuration");
}
Credential[] credentials =
new Credential[]{new UsernameCredential(username), new PasswordCredential(password)};
String userId = authenticator.validateUser(credentials);
Identity identity = authenticator.createIdentity(userId);
sharedState.put("exo.security.identity", identity);
sharedState.put("javax.security.auth.login.name", userId);
subject.getPrivateCredentials().add(password);