Search in sources :

Example 1 with ClaimCollection

use of org.apache.cxf.rt.security.claims.ClaimCollection in project ddf by codice.

the class CertificateClaimsHandlerTest method getClaims.

private ClaimCollection getClaims() throws URISyntaxException {
    ClaimCollection claims = new ClaimCollection();
    Claim claim = new Claim();
    claim.setClaimType(new URI(SubjectUtils.COUNTRY_CLAIM_URI));
    claims.add(claim);
    Claim claim1 = new Claim();
    claim1.setClaimType(new URI(SubjectUtils.EMAIL_ADDRESS_CLAIM_URI));
    claims.add(claim1);
    return claims;
}
Also used : ClaimCollection(org.apache.cxf.rt.security.claims.ClaimCollection) ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) URI(java.net.URI) Claim(org.apache.cxf.rt.security.claims.Claim)

Example 2 with ClaimCollection

use of org.apache.cxf.rt.security.claims.ClaimCollection 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));
}
Also used : ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) HashMap(java.util.HashMap) ClaimCollection(org.apache.cxf.rt.security.claims.ClaimCollection) ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) Principal(java.security.Principal) ClaimsParameters(org.apache.cxf.sts.claims.ClaimsParameters) Test(org.junit.Test)

Example 3 with ClaimCollection

use of org.apache.cxf.rt.security.claims.ClaimCollection 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)));
}
Also used : ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) ClaimCollection(org.apache.cxf.rt.security.claims.ClaimCollection) ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) ClaimsParameters(org.apache.cxf.sts.claims.ClaimsParameters) Test(org.junit.Test)

Example 4 with ClaimCollection

use of org.apache.cxf.rt.security.claims.ClaimCollection 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)));
}
Also used : ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) ClaimCollection(org.apache.cxf.rt.security.claims.ClaimCollection) ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) ClaimsParameters(org.apache.cxf.sts.claims.ClaimsParameters) Test(org.junit.Test)

Example 5 with ClaimCollection

use of org.apache.cxf.rt.security.claims.ClaimCollection 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);
}
Also used : URISyntaxException(java.net.URISyntaxException) ClaimCollection(org.apache.cxf.rt.security.claims.ClaimCollection) ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) URI(java.net.URI) Claim(org.apache.cxf.rt.security.claims.Claim) Principal(java.security.Principal) ClaimsParameters(org.apache.cxf.sts.claims.ClaimsParameters)

Aggregations

ClaimCollection (org.apache.cxf.rt.security.claims.ClaimCollection)100 Claim (org.apache.cxf.rt.security.claims.Claim)63 ClaimsManager (org.apache.cxf.sts.claims.ClaimsManager)46 ClaimsParameters (org.apache.cxf.sts.claims.ClaimsParameters)43 ProcessedClaimCollection (org.apache.cxf.sts.claims.ProcessedClaimCollection)42 ProcessedClaim (org.apache.cxf.sts.claims.ProcessedClaim)31 CustomTokenPrincipal (org.apache.wss4j.common.principal.CustomTokenPrincipal)26 ClaimsHandler (org.apache.cxf.sts.claims.ClaimsHandler)23 Principal (java.security.Principal)22 CustomClaimsHandler (org.apache.cxf.sts.common.CustomClaimsHandler)22 URI (java.net.URI)21 Element (org.w3c.dom.Element)21 StaticClaimsHandler (org.apache.cxf.sts.claims.StaticClaimsHandler)15 SamlAssertionWrapper (org.apache.wss4j.common.saml.SamlAssertionWrapper)13 ArrayList (java.util.ArrayList)12 LdapClaimsHandler (org.apache.cxf.sts.claims.LdapClaimsHandler)12 JAXBElement (javax.xml.bind.JAXBElement)10 Test (org.junit.Test)10 SAMLSecurityContext (org.apache.cxf.rt.security.saml.claims.SAMLSecurityContext)9 StaticEndpointClaimsHandler (org.apache.cxf.sts.claims.StaticEndpointClaimsHandler)9