use of org.apache.cxf.sts.claims.ClaimsParameters in project cas by apereo.
the class WrappingSecurityTokenServiceClaimsHandler method retrieveClaimValues.
@Override
public ProcessedClaimCollection retrieveClaimValues(final ClaimCollection claims, final ClaimsParameters parameters) {
if (parameters.getRealm() == null || !parameters.getRealm().equalsIgnoreCase(this.realm)) {
LOGGER.warn("Realm [{}] doesn't match with configured realm [{}]", parameters.getRealm(), this.realm);
return new ProcessedClaimCollection();
}
if (parameters.getPrincipal() == null) {
LOGGER.warn("No principal could be identified in the claim parameters request");
return new ProcessedClaimCollection();
}
if (claims == null || claims.isEmpty()) {
LOGGER.warn("No claims are available to process");
return new ProcessedClaimCollection();
}
final ProcessedClaimCollection claimCollection = new ProcessedClaimCollection();
claims.stream().map(requestClaim -> {
final ProcessedClaim claim = new ProcessedClaim();
claim.setClaimType(requestClaim.getClaimType());
claim.setIssuer(this.issuer);
claim.setOriginalIssuer(this.issuer);
claim.setValues(requestClaim.getValues());
return claim;
}).forEach(claimCollection::add);
return claimCollection;
}
use of org.apache.cxf.sts.claims.ClaimsParameters in project ddf by codice.
the class TestAttributeFileClaimsHandler method testRetrieveClaimsValuesNullPrincipal.
@Test
public void testRetrieveClaimsValuesNullPrincipal() {
ClaimsParameters claimsParameters = new ClaimsParameters();
ClaimCollection claimCollection = new ClaimCollection();
ProcessedClaimCollection processedClaims = attributeFileClaimsHandler.retrieveClaimValues(claimCollection, claimsParameters);
Assert.assertThat(processedClaims.size(), CoreMatchers.is(equalTo(0)));
}
use of org.apache.cxf.sts.claims.ClaimsParameters in project ddf by codice.
the class CertificateClaimsHandlerTest method testRetrieveClaimValuesWithCountry.
@Test
public void testRetrieveClaimValuesWithCountry() throws URISyntaxException {
CertificateClaimsHandler certificateClaimsHandler = new CertificateClaimsHandler();
ClaimCollection claims = getClaims();
ClaimsParameters parameters = new ClaimsParameters();
parameters.setPrincipal(mock(Principal.class));
Map<String, Object> map = new HashMap<>();
map.put(SubjectUtils.COUNTRY_CLAIM_URI, "USA");
parameters.setAdditionalProperties(map);
ProcessedClaimCollection processedClaims = certificateClaimsHandler.retrieveClaimValues(claims, parameters);
assertThat(processedClaims.size(), is(1));
assertThat(processedClaims.stream().map(c -> c.getClaimType().toString()).collect(Collectors.toList()), containsInAnyOrder(SubjectUtils.COUNTRY_CLAIM_URI));
}
use of org.apache.cxf.sts.claims.ClaimsParameters in project ddf by codice.
the class CertificateClaimsHandlerTest method testRetrieveClaimValuesWithCertValues.
@Test
public void testRetrieveClaimValuesWithCertValues() throws URISyntaxException {
CertificateClaimsHandler certificateClaimsHandler = new CertificateClaimsHandler();
ClaimCollection claims = getClaims();
ClaimsParameters parameters = new ClaimsParameters();
parameters.setPrincipal(mock(Principal.class));
Map<String, Object> map = new HashMap<>();
map.put(SubjectUtils.EMAIL_ADDRESS_CLAIM_URI, "local@localhost");
map.put(SubjectUtils.COUNTRY_CLAIM_URI, "USA");
parameters.setAdditionalProperties(map);
ProcessedClaimCollection processedClaims = certificateClaimsHandler.retrieveClaimValues(claims, parameters);
assertThat(processedClaims.size(), is(2));
assertThat(processedClaims.stream().map(c -> c.getClaimType().toString()).collect(Collectors.toList()), containsInAnyOrder(SubjectUtils.EMAIL_ADDRESS_CLAIM_URI, SubjectUtils.COUNTRY_CLAIM_URI));
}
use of org.apache.cxf.sts.claims.ClaimsParameters in project ddf by codice.
the class CertificateClaimsHandlerTest method testRetrieveClaimValuesWithAltNamesNotRequested.
@Test
public void testRetrieveClaimValuesWithAltNamesNotRequested() throws URISyntaxException {
CertificateClaimsHandler certificateClaimsHandler = new CertificateClaimsHandler();
certificateClaimsHandler.setCountryClaim("Country");
certificateClaimsHandler.setEmailClaim("Email");
ClaimCollection claims = getClaims();
ClaimsParameters parameters = new ClaimsParameters();
parameters.setPrincipal(mock(Principal.class));
Map<String, Object> map = new HashMap<>();
map.put(SubjectUtils.EMAIL_ADDRESS_CLAIM_URI, "local@localhost");
map.put(SubjectUtils.COUNTRY_CLAIM_URI, "USA");
parameters.setAdditionalProperties(map);
ProcessedClaimCollection processedClaims = certificateClaimsHandler.retrieveClaimValues(claims, parameters);
assertThat(processedClaims.size(), is(0));
}
Aggregations