}
}
}
public ClaimCollection retrieveClaimValues(RequestClaimCollection claims, ClaimsParameters parameters) {
Relationship relationship = null;
if (parameters.getAdditionalProperties() != null) {
relationship = (Relationship)parameters.getAdditionalProperties().get(
Relationship.class.getName());
}
if (relationship == null || relationship.getType().equals(Relationship.FED_TYPE_IDENTITY)) {
// Federate identity. Identity already mapped.
// Call all configured claims handlers to retrieve the required claims
if (claimHandlers != null && claimHandlers.size() > 0 && claims != null && claims.size() > 0) {
ClaimCollection returnCollection = new ClaimCollection();
for (ClaimsHandler handler : claimHandlers) {
ClaimCollection claimCollection = handler.retrieveClaimValues(claims, parameters);
if (claimCollection != null && claimCollection.size() != 0) {
returnCollection.addAll(claimCollection);
}
}
validateClaimValues(claims, returnCollection);
return returnCollection;
}
} else {
// Federate claims
ClaimsMapper claimsMapper = relationship.getClaimsMapper();
if (claimsMapper == null) {
LOG.log(Level.SEVERE, "ClaimsMapper required to federate claims but not configured.");
throw new STSException("ClaimsMapper required to federate claims but not configured",
STSException.BAD_REQUEST);
}
// Get the claims of the received token (only SAML supported)
// Consider refactoring to use a CallbackHandler and keep ClaimsManager token independent
AssertionWrapper assertion =
(AssertionWrapper)parameters.getAdditionalProperties().get(AssertionWrapper.class.getName());
List<Claim> claimList = null;
if (assertion.getSamlVersion().equals(SAMLVersion.VERSION_20)) {
claimList = this.parseClaimsInAssertion(assertion.getSaml2());
} else {
claimList = this.parseClaimsInAssertion(assertion.getSaml1());
}
ClaimCollection sourceClaims = new ClaimCollection();
sourceClaims.addAll(claimList);
ClaimCollection targetClaims = claimsMapper.mapClaims(relationship.getSourceRealm(),
sourceClaims, relationship.getTargetRealm(), parameters);
validateClaimValues(claims, targetClaims);
return targetClaims;
}
return null;