Search in sources :

Example 11 with ProcessedClaimCollection

use of org.apache.cxf.sts.claims.ProcessedClaimCollection in project ddf by codice.

the class TestAttributeFileClaimsHandler method testRetrieveClaimValuesLocalhost.

@Test
public void testRetrieveClaimValuesLocalhost() {
    ProcessedClaimCollection processedClaims = attributeFileClaimsHandler.retrieveClaimValues(claimCollection, localhostClaimsParameters);
    assertThat(processedClaims.size(), is(0));
}
Also used : ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) Test(org.junit.Test)

Example 12 with ProcessedClaimCollection

use of org.apache.cxf.sts.claims.ProcessedClaimCollection 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 13 with ProcessedClaimCollection

use of org.apache.cxf.sts.claims.ProcessedClaimCollection in project ddf by codice.

the class TestAttributeQueryClaimsHandler method testRetrieveClaimValues.

@Test
public void testRetrieveClaimValues() throws Exception {
    ProcessedClaimCollection processedClaimCollection = retrieveClaimValues();
    // Test that the claims were created and mapped correctly.
    assertThat(processedClaimCollection.size(), is(equalTo(3)));
    assertThat(processedClaimCollection.get(0).getClaimType().toString(), is(equalTo("Role")));
    assertThat((String) processedClaimCollection.get(0).getValues().get(0), is(equalTo("Guest-hasMapping")));
    assertThat(processedClaimCollection.get(1).getClaimType().toString(), is(equalTo("NameIdentifier")));
    assertThat((String) processedClaimCollection.get(1).getValues().get(0), is(equalTo("Name-hasMapping")));
    // Does not have an attribute mapping.
    assertThat(processedClaimCollection.get(2).getClaimType().toString(), is(equalTo("Email")));
    assertThat((String) processedClaimCollection.get(2).getValues().get(0), is(equalTo("email")));
}
Also used : ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) Test(org.junit.Test)

Example 14 with ProcessedClaimCollection

use of org.apache.cxf.sts.claims.ProcessedClaimCollection 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 15 with ProcessedClaimCollection

use of org.apache.cxf.sts.claims.ProcessedClaimCollection 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

ProcessedClaimCollection (org.apache.cxf.sts.claims.ProcessedClaimCollection)68 ProcessedClaim (org.apache.cxf.sts.claims.ProcessedClaim)40 Test (org.junit.Test)32 ClaimCollection (org.apache.cxf.rt.security.claims.ClaimCollection)30 ClaimsParameters (org.apache.cxf.sts.claims.ClaimsParameters)29 Claim (org.apache.cxf.rt.security.claims.Claim)21 URI (java.net.URI)18 Principal (java.security.Principal)15 ClaimsManager (org.apache.cxf.sts.claims.ClaimsManager)14 CustomTokenPrincipal (org.apache.wss4j.common.principal.CustomTokenPrincipal)14 ArrayList (java.util.ArrayList)13 HashMap (java.util.HashMap)5 ClaimsHandler (org.apache.cxf.sts.claims.ClaimsHandler)5 LdapClaimsHandler (org.apache.cxf.sts.claims.LdapClaimsHandler)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 URISyntaxException (java.net.URISyntaxException)4 List (java.util.List)4 X500Principal (javax.security.auth.x500.X500Principal)4 LdapGroupClaimsHandler (org.apache.cxf.sts.claims.LdapGroupClaimsHandler)4 RealmSupportClaimsHandler (org.apache.cxf.sts.common.RealmSupportClaimsHandler)4