Methods Summary |
---|
public boolean | commit()
// Put the principal name into the sharedState map
sharedState.put("javax.security.auth.login.name", userName);
// Add any run-as roles if addRunAsRoles is true
if( addRunAsRoles && runAsRoles != null )
{
SubjectActions.addRoles(subject, runAsRoles);
}
// Add the PasswordCredential
PasswordCredential cred = new PasswordCredential(userName, password);
cred.setManagedConnectionFactory(getMcf());
SubjectActions.addCredentials(subject, cred);
return super.commit();
|
protected java.security.Principal | getIdentity()
log.trace("getIdentity called");
Principal principal = new SimplePrincipal(userName);
return principal;
|
protected java.security.acl.Group[] | getRoleSets()
log.trace("getRoleSets called");
return new Group[]{};
|
public void | initialize(javax.security.auth.Subject subject, javax.security.auth.callback.CallbackHandler handler, java.util.Map sharedState, java.util.Map options)The initialize method sets up some default connection information for
basic connections. This is useful for container initialization connection
use or running the application in a non-secure manner. This method is
called before the login method.
super.initialize(subject, handler, sharedState, options);
userName = (String) options.get("userName");
if (userName == null)
{
log.debug("No default username supplied.");
}
String pass = (String) options.get("password");
if (pass == null)
{
log.debug("No default password supplied.");
}
else
{
password = pass.toCharArray();
}
// Check the addRunAsRoles
String flag = (String) options.get("addRunAsRoles");
addRunAsRoles = Boolean.valueOf(flag).booleanValue();
log.debug("got default principal: " + userName + ", username: "
+ userName + ", password: " + (password == null ? "null" : "****")
+ " addRunAsRoles: "+addRunAsRoles);
|
public boolean | login()Performs the login association between the caller and the resource for a
1 to 1 mapping. This acts as a login propagation strategy and is useful
for single-sign on requirements
log.trace("Caller Association login called");
//setup to use the default connection info. This will be overiden if security
//associations are found
String username = userName;
//ask the security association class for the principal info making this request
try
{
Principal user = GetPrincipalInfoAction.getPrincipal();
char[] userPassword = GetPrincipalInfoAction.getCredential();
if( userPassword != null )
{
password = userPassword;
}
if (user != null)
{
username = user.getName();
if (log.isTraceEnabled())
{
log.trace("Current Calling principal is: " + username
+ " ThreadName: " + Thread.currentThread().getName());
}
// Check for a RunAsIdentity
RunAsIdentity runAs = GetPrincipalInfoAction.peekRunAsIdentity();
if( runAs != null )
{
runAsRoles = runAs.getRunAsRoles();
}
}
}
catch (Throwable e)
{
throw new LoginException("Unable to get the calling principal or its credentials for resource association");
}
// Update userName so that getIdentity is consistent
userName = username;
if (super.login() == true)
{
return true;
}
// Put the principal name into the sharedState map
sharedState.put("javax.security.auth.login.name", username);
super.loginOk = true;
return true;
|