public ClaimCollection retrieveClaimValues(RequestClaimCollection claims,
ClaimsParameters parameters) {
if (parameters.getRealm() == null || !parameters.getRealm().equalsIgnoreCase(getRealm())) {
LOG.fine("Realm '" + parameters.getRealm() + "' doesn't match with configured realm '" + getRealm() + "'");
return new ClaimCollection();
}
if (getUserClaims() == null || parameters.getPrincipal() == null) {
return new ClaimCollection();
}
if (claims == null || claims.size() == 0) {
LOG.fine("No claims requested");
return new ClaimCollection();
}
Map<String, String> claimMap = getUserClaims().get(parameters.getPrincipal().getName());
if (claimMap == null || claimMap.size() == 0) {
LOG.fine("Claims requested for principal '" + parameters.getPrincipal().getName()
+ "' but not found");
return new ClaimCollection();
}
LOG.fine("Claims found for principal '" + parameters.getPrincipal().getName() + "'");
if (claims != null && claims.size() > 0) {
ClaimCollection claimCollection = new ClaimCollection();
for (RequestClaim requestClaim : claims) {
String claimValue = claimMap.get(requestClaim.getClaimType().toString());
if (claimValue != null) {
Claim claim = new Claim();
claim.setClaimType(requestClaim.getClaimType());
claim.setIssuer("Test Issuer");
claim.setOriginalIssuer("Original Issuer");
claim.addValue(claimValue);
claimCollection.add(claim);
}
}
return claimCollection;
}
return null;