/** * Create a clone of the provided claim. * * @param claim Claim to be cloned. Value cannot be null. */ public Claim(Claim claim) { if (claim == null) { throw new IllegalArgumentException("Claim cannot be null"); } claimType = claim.getClaimType(); optional = claim.isOptional(); values.addAll(claim.getValues()); }
/** * Create a clone of the provided claim. * * @param claim Claim to be cloned. Value cannot be null. */ public Claim(Claim claim) { if (claim == null) { throw new IllegalArgumentException("Claim cannot be null"); } claimType = claim.getClaimType(); optional = claim.isOptional(); values.addAll(claim.getValues()); }
/** * Extract roles from the given Claims */ public static Set<Principal> parseRolesFromClaims( ClaimCollection claims, String name, String nameFormat ) { String roleAttributeName = name; if (roleAttributeName == null) { roleAttributeName = SAMLClaim.SAML_ROLE_ATTRIBUTENAME_DEFAULT; } Set<Principal> roles = new HashSet<>(); for (Claim claim : claims) { if (claim instanceof SAMLClaim && ((SAMLClaim)claim).getName().equals(name) && (nameFormat == null || nameFormat.equals(((SAMLClaim)claim).getNameFormat()))) { for (Object claimValue : claim.getValues()) { if (claimValue instanceof String) { roles.add(new SimpleGroup((String)claimValue)); } } if (claim.getValues().size() > 1) { // Don't search for other attributes with the same name if > 1 claim value break; } } } return roles; }
Claim mergedClaim = new Claim(); mergedClaim.setClaimType(claim.getClaimType()); if (claim.getValues() != null && !claim.getValues().isEmpty()) { mergedClaim.setValues(claim.getValues()); if (matchingClaim.getValues() != null && !matchingClaim.getValues().isEmpty()) { LOG.log(Level.WARNING, "Secondary claim value " + matchingClaim.getValues() + " ignored in favour of primary claim value"); } else if (matchingClaim.getValues() != null && !matchingClaim.getValues().isEmpty()) { mergedClaim.setValues(matchingClaim.getValues());
Claim mergedClaim = new Claim(); mergedClaim.setClaimType(claim.getClaimType()); if (claim.getValues() != null && !claim.getValues().isEmpty()) { mergedClaim.setValues(claim.getValues()); if (matchingClaim.getValues() != null && !matchingClaim.getValues().isEmpty()) { LOG.log(Level.WARNING, "Secondary claim value " + matchingClaim.getValues() + " ignored in favour of primary claim value"); } else if (matchingClaim.getValues() != null && !matchingClaim.getValues().isEmpty()) { mergedClaim.setValues(matchingClaim.getValues());