use of org.apache.cxf.sts.claims.ProcessedClaimCollection in project ddf by codice.
the class AttributeQueryClaimsHandler method getAttributes.
/**
* Gets the attributes for the supplied user from the external attribute store.
* Returns null if the AttributeQueryClient is null.
*
* @param nameId used for the request.
* @return The collection of attributes retrieved from the external attribute store.
* @throws URISyntaxException
*/
protected ProcessedClaimCollection getAttributes(String nameId) throws URISyntaxException {
ProcessedClaimCollection claimCollection = new ProcessedClaimCollection();
LOGGER.debug("Sending AttributeQuery Request.");
AttributeQueryClient attributeQueryClient;
Assertion assertion;
try {
attributeQueryClient = createAttributeQueryClient(simpleSign, externalAttributeStoreUrl, issuer, destination);
if (attributeQueryClient == null) {
return null;
}
assertion = attributeQueryClient.query(nameId);
if (assertion != null) {
createClaims(claimCollection, assertion);
}
} catch (AttributeQueryException ex) {
LOGGER.info("Error occurred in AttributeQueryClient, did not retrieve response. Set log level for \"org.codice.ddf.security.claims.attributequery.common\" to DEBUG for more information.");
LOGGER.debug("Error occurred in AttributeQueryClient, did not retrieve response.", ex);
}
return claimCollection;
}
use of org.apache.cxf.sts.claims.ProcessedClaimCollection in project cxf by apache.
the class ClaimUtils method mapType.
/**
* @param processedClaims Collection of claims to be mapped to a different claim type
* @param map Map of old:new claim types
* @param keepUnmapped if set to false only claims with a claim type contained in the map will be
* returned. If set to false claims with an unmapped claim type will also be returned.
* @return Returns claim collection with mapped claim types
*/
public ProcessedClaimCollection mapType(ProcessedClaimCollection processedClaims, Map<String, String> map, boolean keepUnmapped) {
ProcessedClaimCollection mappedProcessedClaims = new ProcessedClaimCollection();
if (processedClaims != null && map != null) {
for (ProcessedClaim c : processedClaims) {
String processedClaimType = (c.getClaimType() != null) ? c.getClaimType().toString() : "";
String mappedProcessedClaimType = map.get(processedClaimType);
if (mappedProcessedClaimType != null) {
ProcessedClaim processedClaim = c.clone();
processedClaim.setClaimType(URI.create(mappedProcessedClaimType));
mappedProcessedClaims.add(processedClaim);
} else if (keepUnmapped) {
mappedProcessedClaims.add(c.clone());
}
}
}
return mappedProcessedClaims;
}
use of org.apache.cxf.sts.claims.ProcessedClaimCollection in project cxf by apache.
the class JexlClaimsMapperTest method testWrappedUpperCaseClaim.
@Test
public void testWrappedUpperCaseClaim() throws IOException {
ProcessedClaimCollection result = jcm.mapClaims("A", createClaimCollection(), "B", createProperties());
assertNotNull(result);
ProcessedClaim claim = findClaim(result, "http://my.schema.org/identity/claims/wrappedUppercase");
assertNotNull(claim);
assertNotNull(claim.getValues());
assertEquals(1, claim.getValues().size());
assertEquals("PREFIX_VALUE_SUFFIX", claim.getValues().get(0));
}
use of org.apache.cxf.sts.claims.ProcessedClaimCollection in project cxf by apache.
the class JexlClaimsMapperTest method testClaimMerge.
@Test
public void testClaimMerge() throws IOException {
ProcessedClaimCollection result = jcm.mapClaims("A", createClaimCollection(), "B", createProperties());
assertNotNull(result);
assertTrue(result.size() >= 2);
assertEquals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", result.get(1).getClaimType().toString());
assertEquals(1, result.get(1).getValues().size());
assertEquals("Jan Bernhardt", result.get(1).getValues().get(0));
for (ProcessedClaim c : result) {
if ("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname".equals(c.getClaimType().toString())) {
fail("Only merged claim should be in result set, but not the individual claims");
}
}
}
use of org.apache.cxf.sts.claims.ProcessedClaimCollection in project cxf by apache.
the class JexlClaimsMapperTest method createClaimCollection.
@SuppressWarnings("unchecked")
protected ProcessedClaimCollection createClaimCollection() {
ProcessedClaimCollection cc = new ProcessedClaimCollection();
ProcessedClaim c = new ProcessedClaim();
c.setIssuer("STS-A");
c.setOriginalIssuer("STS-B");
c.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role"));
c.setValues((List<Object>) (List<?>) Arrays.asList("admin", "manager", "tester"));
cc.add(c);
c = new ProcessedClaim();
c.setIssuer("STS-A");
c.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"));
c.setValues((List<Object>) (List<?>) Arrays.asList("Jan"));
cc.add(c);
c = new ProcessedClaim();
c.setIssuer("STS-A");
c.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname"));
c.setValues((List<Object>) (List<?>) Arrays.asList("Bernhardt"));
cc.add(c);
c = new ProcessedClaim();
c.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/unused"));
c.setValues((List<Object>) (List<?>) Arrays.asList("noValue"));
cc.add(c);
c = new ProcessedClaim();
c.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/mail"));
c.setValues((List<Object>) (List<?>) Arrays.asList("test@apache.com"));
cc.add(c);
return cc;
}
Aggregations