}
WSHandlerResult rResult = new WSHandlerResult(actor, wsResult);
results.add(0, rResult);
for (int i = wsResult.size() - 1; i >= 0; i--) {
WSSecurityEngineResult o = wsResult.get(i);
Integer action = (Integer)o.get(WSSecurityEngineResult.TAG_ACTION);
if (action == WSConstants.ENCR) {
// Don't try to parse a Principal for the Decryption case
continue;
}
final Principal p = (Principal)o.get(WSSecurityEngineResult.TAG_PRINCIPAL);
final Subject subject = (Subject)o.get(WSSecurityEngineResult.TAG_SUBJECT);
final boolean useJAASSubject = MessageUtils
.getContextualBoolean(msg, SecurityConstants.SC_FROM_JAAS_SUBJECT, true);
if ((subject != null) && !(p instanceof KerberosPrincipal) && useJAASSubject) {
String roleClassifier =
(String)msg.getContextualProperty(SecurityConstants.SUBJECT_ROLE_CLASSIFIER);
if (roleClassifier != null && !"".equals(roleClassifier)) {
String roleClassifierType =
(String)msg.getContextualProperty(SecurityConstants.SUBJECT_ROLE_CLASSIFIER_TYPE);
if (roleClassifierType == null || "".equals(roleClassifierType)) {
roleClassifierType = "prefix";
}
msg.put(
SecurityContext.class,
new RolePrefixSecurityContextImpl(subject, roleClassifier, roleClassifierType)
);
} else {
msg.put(SecurityContext.class, new DefaultSecurityContext(p, subject));
}
break;
} else if (p != null && isSecurityContextPrincipal(p, wsResult)) {
msg.put(PRINCIPAL_RESULT, p);
if (!utWithCallbacks) {
WSS4JTokenConverter.convertToken(msg, p);
}
Object receivedAssertion = o.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
if (receivedAssertion == null) {
receivedAssertion = o.get(WSSecurityEngineResult.TAG_TRANSFORMED_TOKEN);
}
if (receivedAssertion instanceof SamlAssertionWrapper) {
String roleAttributeName = (String)msg.getContextualProperty(
SecurityConstants.SAML_ROLE_ATTRIBUTENAME);