use of org.apache.cxf.sts.claims.ClaimsParameters in project ddf by codice.
the class CertificateClaimsHandlerTest method testRetrieveClaimValuesNoCertValues.
@Test
public void testRetrieveClaimValuesNoCertValues() throws URISyntaxException {
CertificateClaimsHandler certificateClaimsHandler = new CertificateClaimsHandler();
ClaimCollection claims = getClaims();
ClaimsParameters parameters = new ClaimsParameters();
parameters.setPrincipal(mock(Principal.class));
ProcessedClaimCollection processedClaims = certificateClaimsHandler.retrieveClaimValues(claims, parameters);
assertThat(processedClaims.size(), is(0));
}
use of org.apache.cxf.sts.claims.ClaimsParameters in project ddf by codice.
the class CertificateClaimsHandlerTest method testRetrieveClaimValuesWithAltNamesRequested.
@Test
public void testRetrieveClaimValuesWithAltNamesRequested() throws URISyntaxException {
CertificateClaimsHandler certificateClaimsHandler = new CertificateClaimsHandler();
certificateClaimsHandler.setCountryClaim("Country");
certificateClaimsHandler.setEmailClaim("Email");
ClaimCollection claims = new ClaimCollection();
Claim claim = new Claim();
claim.setClaimType(new URI("Country"));
claims.add(claim);
Claim claim1 = new Claim();
claim1.setClaimType(new URI("Email"));
claims.add(claim1);
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("Email", "Country"));
}
use of org.apache.cxf.sts.claims.ClaimsParameters in project ddf by codice.
the class CertificateClaimsHandlerTest method testRetrieveClaimValuesWithEmail.
@Test
public void testRetrieveClaimValuesWithEmail() 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");
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.EMAIL_ADDRESS_CLAIM_URI));
}
use of org.apache.cxf.sts.claims.ClaimsParameters in project ddf by codice.
the class TestAttributeQueryClaimsHandler method testRetrieveClaimsValuesNullPrincipal.
@Test
public void testRetrieveClaimsValuesNullPrincipal() {
ClaimsParameters claimsParameters = mock(ClaimsParameters.class);
when(claimsParameters.getPrincipal()).thenReturn(null);
ClaimCollection claimCollection = new ClaimCollection();
ProcessedClaimCollection processedClaims = spyAttributeQueryClaimsHandler.retrieveClaimValues(claimCollection, claimsParameters);
assertThat(processedClaims.size(), is(equalTo(0)));
}
use of org.apache.cxf.sts.claims.ClaimsParameters in project ddf by codice.
the class TestAttributeQueryClaimsHandler method retrieveClaimValues.
private ProcessedClaimCollection retrieveClaimValues() {
ClaimCollection claimCollection = new ClaimCollection();
Claim claim = new Claim();
try {
claim.setClaimType(new URI("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"));
} catch (URISyntaxException e) {
fail("Could not create URI.");
}
claimCollection.add(claim);
ClaimsParameters claimsParameters = mock(ClaimsParameters.class);
Principal principal = mock(Principal.class);
when(principal.getName()).thenReturn(USERNAME);
when(claimsParameters.getPrincipal()).thenReturn(principal);
return spyAttributeQueryClaimsHandler.retrieveClaimValues(claimCollection, claimsParameters);
}
Aggregations