List<WSSecurityEngineResult> signedResults = new ArrayList<WSSecurityEngineResult>();
WSSecurityUtil.fetchAllActionResults(
rResult.getResults(), WSConstants.SIGN, signedResults
);
IssuedTokenPolicyValidator issuedValidator =
new IssuedTokenPolicyValidator(signedResults, message);
Collection<AssertionInfo> issuedAis = aim.get(SP12Constants.ISSUED_TOKEN);
for (AssertionWrapper assertionWrapper : findSamlTokenResults(rResult.getResults())) {
boolean valid = issuedValidator.validatePolicy(issuedAis, assertionWrapper);
if (valid) {
SecurityToken token = createSecurityToken(assertionWrapper);
getTokenStore(message).add(token);
message.getExchange().remove(SecurityConstants.TOKEN);
message.getExchange().put(SecurityConstants.TOKEN_ID, token.getId());
return;
}
}
for (BinarySecurity binarySecurityToken : findBinarySecurityTokenResults(rResult.getResults())) {
boolean valid = issuedValidator.validatePolicy(issuedAis, binarySecurityToken);
if (valid) {
SecurityToken token = createSecurityToken(binarySecurityToken);
getTokenStore(message).add(token);
message.getExchange().remove(SecurityConstants.TOKEN);
message.getExchange().put(SecurityConstants.TOKEN_ID, token.getId());