SimpleLoginModulepublic class SimpleLoginModule extends Object implements LoginModule
Fields Summary |
---|
private Subject | subject | private CallbackHandler | callbackHandler | private SimplePrincipal | principal | private boolean | debug | private String | userName | private boolean | succeeded | private boolean | commitSucceeded |
Methods Summary |
---|
public boolean | abort()
if (debug)
System.err.println("SimpleLoginModule: Abort");
if (succeeded == false)
// We failed, and so did someone else, so just clean up
return false;
else if (succeeded == true && commitSucceeded == true) {
// Our login succeeded, but another required module failed
// We must remove our principal and clean up
logout();
} else {
// Our commit failed, even though login succeeded
// The rest of our internal state should already
// have been cleaned up
succeeded = false;
}
return true;
| public boolean | commit()
if (debug)
System.err.println("SimpleLoginModule: Commit");
if (!succeeded) {
// We didn't authenticate the user, but someone else did.
// Clean up our state, but don't add our principal to
// the subject
userName = null;
return false;
}
principal = new SimplePrincipal(userName);
// defaultUser might already be in the subject if another module
// authenticated him.
if (!subject.getPrincipals().contains(principal)) {
subject.getPrincipals().add(principal);
}
// Clean up our internal state
userName = null;
commitSucceeded = true;
return true;
| public void | initialize(javax.security.auth.Subject s, javax.security.auth.callback.CallbackHandler cb, java.util.Map sharedMap, java.util.Map options)
subject = s;
callbackHandler = cb;
// initialize any configured options
debug = "true".equalsIgnoreCase((String)options.get("debug"));
// We don
|
|