use of org.apache.cxf.sts.claims.ProcessedClaimCollection in project cxf by apache.
the class ClaimUtils method updateIssuer.
/**
* All claims within the provided collection will be updated in the following manner: If no original
* issuer is set, the issuer in the provided claims will be set as original issuer. If an original issuer
* was already set before, the original issuer will not be updated. All claims will be updated to have the
* provided issuer name be set as the claim issuer.
*
* @param processedClaims Collection of claims to be updated
* @param issuerName Issuer to be set for all claims within the collection
* @return Returns a new claim collection with clones of updated claims
*/
public ProcessedClaimCollection updateIssuer(ProcessedClaimCollection processedClaims, String newIssuer) {
ProcessedClaimCollection resultClaimCollection = null;
if (processedClaims != null) {
resultClaimCollection = new ProcessedClaimCollection();
for (ProcessedClaim c : processedClaims) {
ProcessedClaim newClaim = c.clone();
if (newClaim.getOriginalIssuer() == null) {
newClaim.setOriginalIssuer(newClaim.getIssuer());
}
newClaim.setIssuer(newIssuer);
resultClaimCollection.add(newClaim);
}
}
return resultClaimCollection;
}
use of org.apache.cxf.sts.claims.ProcessedClaimCollection in project cxf by apache.
the class JexlClaimsMapper method mapClaims.
public ProcessedClaimCollection mapClaims(String sourceRealm, ProcessedClaimCollection sourceClaims, String targetRealm, ClaimsParameters parameters) {
JexlContext context = new MapContext();
context.set("sourceClaims", sourceClaims);
context.set("targetClaims", new ProcessedClaimCollection());
context.set("sourceRealm", sourceRealm);
context.set("targetRealm", targetRealm);
context.set("claimsParameters", parameters);
Script s = getScript();
if (s == null) {
LOG.warning("No claim mapping script defined");
// TODO Check if null or an exception would be more
return new ProcessedClaimCollection();
// appropriate
}
return (ProcessedClaimCollection) s.execute(context);
}
use of org.apache.cxf.sts.claims.ProcessedClaimCollection in project cxf by apache.
the class DefaultJWTClaimsProvider method handleWSTrustClaims.
protected void handleWSTrustClaims(JWTClaimsProviderParameters jwtClaimsProviderParameters, JwtClaims claims) {
TokenProviderParameters providerParameters = jwtClaimsProviderParameters.getProviderParameters();
// Handle Claims
ProcessedClaimCollection retrievedClaims = ClaimsUtils.processClaims(providerParameters);
if (retrievedClaims != null) {
Iterator<ProcessedClaim> claimIterator = retrievedClaims.iterator();
while (claimIterator.hasNext()) {
ProcessedClaim claim = claimIterator.next();
if (claim.getClaimType() != null && claim.getValues() != null && !claim.getValues().isEmpty()) {
Object claimValues = claim.getValues();
if (claim.getValues().size() == 1) {
claimValues = claim.getValues().get(0);
}
claims.setProperty(translateClaim(claim.getClaimType().toString()), claimValues);
}
}
}
}
use of org.apache.cxf.sts.claims.ProcessedClaimCollection in project cxf by apache.
the class JexlClaimsMapperTest method testMultiToSingleValue.
@Test
public void testMultiToSingleValue() throws IOException {
ProcessedClaimCollection result = jcm.mapClaims("A", createClaimCollection(), "B", createProperties());
assertNotNull(result);
ProcessedClaim claim = findClaim(result, "http://my.schema.org/identity/claims/multi2single");
assertNotNull(claim);
assertNotNull(claim.getValues());
assertEquals(1, claim.getValues().size());
assertEquals("Value1,Value2,Value3", claim.getValues().get(0));
}
use of org.apache.cxf.sts.claims.ProcessedClaimCollection in project cxf by apache.
the class JexlClaimsMapperTest method testLowerCaseClaim.
@Test
public void testLowerCaseClaim() throws IOException {
ProcessedClaimCollection result = jcm.mapClaims("A", createClaimCollection(), "B", createProperties());
assertNotNull(result);
ProcessedClaim claim = findClaim(result, "http://my.schema.org/identity/claims/lowercase");
assertNotNull(claim);
assertNotNull(claim.getValues());
assertEquals(2, claim.getValues().size());
assertEquals("value2", claim.getValues().get(1));
}
Aggregations