RequestClaimCollection claims, ClaimsParameters parameters) {
if (claims != null && claims.size() > 0) {
ClaimCollection claimCollection = new ClaimCollection();
for (RequestClaim requestClaim : claims) {
Claim claim = new Claim();
claim.setClaimType(requestClaim.getClaimType());
if (ClaimTypes.FIRSTNAME.equals(requestClaim.getClaimType())) {
if (requestClaim instanceof CustomRequestClaim) {
CustomRequestClaim customClaim = (CustomRequestClaim) requestClaim;
String customName = customClaim.getClaimValue() + "@" + customClaim.getScope();
claim.setValue(customName);
} else {
claim.setValue("alice");
}
} else if (ClaimTypes.LASTNAME.equals(requestClaim.getClaimType())) {
claim.setValue("doe");
} else if (ClaimTypes.EMAILADDRESS.equals(requestClaim.getClaimType())) {
claim.setValue("alice@cxf.apache.org");
} else if (ROLE_CLAIM.equals(requestClaim.getClaimType())) {
String requestedRole = requestClaim.getClaimValue();
if (isUserInRole(parameters.getPrincipal(), requestedRole)) {
claim.setValue(requestedRole);
} else {
continue;
}
}
claimCollection.add(claim);