use of org.apache.cxf.rt.security.claims.ClaimCollection in project alliance by codice.
the class VideographerClaimsHandlerTest method testNameClaim.
@SuppressWarnings("unchecked")
@Test
public void testNameClaim() throws URISyntaxException {
claimsHandler = new VideographerClaimsHandler();
claimsHandler.setAttributes(Collections.singletonList(CLAIM1));
requestClaims = new ClaimCollection();
Claim requestClaim = new Claim();
URI nameURI = new URI(CLAIM_URI_1);
requestClaim.setClaimType(nameURI);
requestClaims.add(requestClaim);
claimsParameters = new ClaimsParameters();
claimsParameters.setPrincipal(new VideographerPrincipal(IP_ADDR));
claimsCollection = claimsHandler.retrieveClaimValues(requestClaims, claimsParameters);
assertThat(claimsCollection, containsInAnyOrder(getNameClaim(nameURI), getIpClaim()));
}
use of org.apache.cxf.rt.security.claims.ClaimCollection 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.handlerRealm)) {
LOGGER.warn("Realm [{}] doesn't match with configured realm [{}]", parameters.getRealm(), this.handlerRealm);
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();
}
val claimCollection = new ProcessedClaimCollection();
claims.stream().map(c -> createProcessedClaim(c, parameters)).forEach(claimCollection::add);
return claimCollection;
}
use of org.apache.cxf.rt.security.claims.ClaimCollection in project cas by apereo.
the class CustomNamespaceWSFederationClaimsClaimsHandlerTests method verifySAML2Type.
@Test
public void verifySAML2Type() {
val handler = new CustomNamespaceWSFederationClaimsClaimsHandler("CAS", "https://apereo.org/cas", List.of("https://apereo.org/cas/givenName", "https://apereo.org/cas/email"));
val claims = new ClaimCollection();
val claim = new Claim();
claim.setClaimType("https://apereo.org/cas/givenName");
claims.add(claim);
val parameters = new ClaimsParameters();
val requirements = new TokenRequirements();
requirements.setTokenType(WSFederationConstants.WSS_SAML2_TOKEN_TYPE);
parameters.setTokenRequirements(requirements);
parameters.setRealm("CAS");
parameters.setPrincipal(mock(Principal.class));
val values = handler.retrieveClaimValues(claims, parameters);
assertFalse(values.isEmpty());
val processed = (ProcessedClaim) values.get(0);
assertEquals("givenName", processed.getClaimType());
assertEquals(handler.getIssuer(), processed.getIssuer());
}
use of org.apache.cxf.rt.security.claims.ClaimCollection in project cas by apereo.
the class CustomNamespaceWSFederationClaimsClaimsHandlerTests method verifySAML1Type.
@Test
public void verifySAML1Type() {
val handler = new CustomNamespaceWSFederationClaimsClaimsHandler("CAS", "https://apereo.org/cas", List.of("https://apereo.org/cas/givenName", "https://apereo.org/cas/email"));
val claims = new ClaimCollection();
val claim = new Claim();
claim.setClaimType("https://apereo.org/cas/givenName");
claims.add(claim);
val parameters = new ClaimsParameters();
val requirements = new TokenRequirements();
requirements.setTokenType(WSFederationConstants.WSS_SAML1_TOKEN_TYPE);
parameters.setTokenRequirements(requirements);
parameters.setRealm("CAS");
parameters.setPrincipal(mock(Principal.class));
val values = handler.retrieveClaimValues(claims, parameters);
assertFalse(values.isEmpty());
val processed = (ProcessedClaim) values.get(0);
assertEquals("https://apereo.org/cas/givenName", processed.getClaimType());
assertEquals(handler.getIssuer(), processed.getIssuer());
}
use of org.apache.cxf.rt.security.claims.ClaimCollection in project cas by apereo.
the class WrappingSecurityTokenServiceClaimsHandlerTests method verifyClaimMatchesRealm.
@Test
public void verifyClaimMatchesRealm() {
val claims = new ClaimCollection();
val claim = new Claim();
claim.setClaimType(WSFederationClaims.COMMON_NAME.getUri());
claims.add(claim);
val parameters = new ClaimsParameters();
parameters.setRealm("CAS-Other");
val handler = new WrappingSecurityTokenServiceClaimsHandler("CAS", "https://apereo.org/cas");
assertTrue(handler.retrieveClaimValues(claims, parameters).isEmpty());
}
Aggregations