{
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)