* ":" + uri)
*/
public Principal authenticate(String username, String digest, String nonce, String nc, String cnonce, String qop,
String realm, String md5a2)
{
Principal principal = null;
Principal caller = SecurityAssociationValve.userPrincipal.get();
if (caller == null && username == null && digest == null)
{
return null;
}
try
{
DigestCallbackHandler handler = new DigestCallbackHandler(username, nonce, nc, cnonce, qop, realm, md5a2);
CallbackHandlerPolicyContextHandler.setCallbackHandler(handler);
// Get the JBoss security manager from the ENC context
SubjectSecurityManager securityMgr = getSubjectSecurityManager("authenticate( digest related)");
if(securityMgr == null)
return null;
principal = new SimplePrincipal(username);
Subject subject = new Subject();
if (securityMgr.isValid(principal, digest, subject))
{
log.trace("User: " + username + " is authenticated");
securityDomain = securityMgr.getSecurityDomain();
SecurityAssociationActions.setPrincipalInfo(principal, digest, subject);
// Get the CallerPrincipal mapping
RealmMapping realmMapping = null;
if(securityMgr instanceof RealmMapping)
realmMapping = (RealmMapping)securityMgr;
else
realmMapping = getRealmMapping();
if(realmMapping == null)
{
log.trace("RealmMapping is null for authenticate(digest params)");
return null;
}
Principal oldPrincipal = principal;
principal = realmMapping.getPrincipal(oldPrincipal);
if (trace)
{
log.trace("Mapped from input principal: " + oldPrincipal + "to: " + principal);
}