Search in sources :

Example 1 with RealmSupportClaimsHandler

use of org.apache.cxf.sts.common.RealmSupportClaimsHandler in project cxf by apache.

the class RealmSupportTest method testFilteredRealmBIdentityMapping.

@org.junit.Test
public void testFilteredRealmBIdentityMapping() throws Exception {
    ClaimsManager claimsManager = new ClaimsManager();
    claimsManager.setIdentityMapper(new CustomIdentityMapper());
    RealmSupportClaimsHandler realmAHandler = new RealmSupportClaimsHandler();
    realmAHandler.setRealm("A");
    realmAHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-A")));
    RealmSupportClaimsHandler realmBHandler = new RealmSupportClaimsHandler();
    realmBHandler.setRealm("B");
    realmBHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-B")));
    RealmSupportClaimsHandler realmCHandler = new RealmSupportClaimsHandler();
    realmCHandler.setRealm("A");
    realmCHandler.setSupportedRealms(Collections.singletonList("A"));
    realmCHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-C")));
    List<ClaimsHandler> claimHandlers = new ArrayList<>();
    claimHandlers.add(realmAHandler);
    claimHandlers.add(realmBHandler);
    claimHandlers.add(realmCHandler);
    claimsManager.setClaimHandlers(Collections.unmodifiableList(claimHandlers));
    ClaimCollection requestedClaims = createClaimCollection();
    ClaimsParameters parameters = new ClaimsParameters();
    parameters.setRealm("B");
    parameters.setPrincipal(new CustomTokenPrincipal("ALICE"));
    ProcessedClaimCollection claims = claimsManager.retrieveClaimValues(requestedClaims, parameters);
    Assert.assertEquals("Number of claims incorrect", 2, claims.size());
// Asserts in RealmSupportClaimsHandler must succeed
}
Also used : CustomTokenPrincipal(org.apache.wss4j.common.principal.CustomTokenPrincipal) CustomIdentityMapper(org.apache.cxf.sts.operation.CustomIdentityMapper) ClaimsHandler(org.apache.cxf.sts.claims.ClaimsHandler) RealmSupportClaimsHandler(org.apache.cxf.sts.common.RealmSupportClaimsHandler) ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) ArrayList(java.util.ArrayList) ClaimsManager(org.apache.cxf.sts.claims.ClaimsManager) ClaimCollection(org.apache.cxf.rt.security.claims.ClaimCollection) ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) RealmSupportClaimsHandler(org.apache.cxf.sts.common.RealmSupportClaimsHandler) ClaimsParameters(org.apache.cxf.sts.claims.ClaimsParameters)

Example 2 with RealmSupportClaimsHandler

use of org.apache.cxf.sts.common.RealmSupportClaimsHandler in project cxf by apache.

the class RealmSupportTest method testIdentityMappingRealmB2A.

@org.junit.Test
public void testIdentityMappingRealmB2A() throws Exception {
    ClaimsManager claimsManager = new ClaimsManager();
    claimsManager.setIdentityMapper(new CustomIdentityMapper());
    RealmSupportClaimsHandler realmAHandler = new RealmSupportClaimsHandler();
    realmAHandler.setRealm("A");
    realmAHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-A")));
    RealmSupportClaimsHandler realmBHandler = new RealmSupportClaimsHandler();
    realmBHandler.setRealm("B");
    realmBHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-B")));
    RealmSupportClaimsHandler realmCHandler = new RealmSupportClaimsHandler();
    realmCHandler.setRealm("B");
    realmCHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-C")));
    List<ClaimsHandler> claimHandlers = new ArrayList<>();
    claimHandlers.add(realmAHandler);
    claimHandlers.add(realmBHandler);
    claimHandlers.add(realmCHandler);
    claimsManager.setClaimHandlers(Collections.unmodifiableList(claimHandlers));
    ClaimCollection requestedClaims = createClaimCollection();
    ClaimsParameters parameters = new ClaimsParameters();
    parameters.setRealm("B");
    parameters.setPrincipal(new CustomTokenPrincipal("ALICE"));
    ProcessedClaimCollection claims = claimsManager.retrieveClaimValues(requestedClaims, parameters);
    Assert.assertEquals("Number of claims incorrect", 3, claims.size());
}
Also used : CustomTokenPrincipal(org.apache.wss4j.common.principal.CustomTokenPrincipal) CustomIdentityMapper(org.apache.cxf.sts.operation.CustomIdentityMapper) ClaimsHandler(org.apache.cxf.sts.claims.ClaimsHandler) RealmSupportClaimsHandler(org.apache.cxf.sts.common.RealmSupportClaimsHandler) ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) ArrayList(java.util.ArrayList) ClaimsManager(org.apache.cxf.sts.claims.ClaimsManager) ClaimCollection(org.apache.cxf.rt.security.claims.ClaimCollection) ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) RealmSupportClaimsHandler(org.apache.cxf.sts.common.RealmSupportClaimsHandler) ClaimsParameters(org.apache.cxf.sts.claims.ClaimsParameters)

Example 3 with RealmSupportClaimsHandler

use of org.apache.cxf.sts.common.RealmSupportClaimsHandler in project cxf by apache.

the class RealmSupportTest method testFilteredRealmAIdentityMapping.

@org.junit.Test
public void testFilteredRealmAIdentityMapping() throws Exception {
    ClaimsManager claimsManager = new ClaimsManager();
    claimsManager.setIdentityMapper(new CustomIdentityMapper());
    RealmSupportClaimsHandler realmAHandler = new RealmSupportClaimsHandler();
    realmAHandler.setRealm("A");
    realmAHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-A")));
    RealmSupportClaimsHandler realmBHandler = new RealmSupportClaimsHandler();
    realmBHandler.setRealm("B");
    realmBHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-B")));
    RealmSupportClaimsHandler realmCHandler = new RealmSupportClaimsHandler();
    realmCHandler.setRealm("A");
    realmCHandler.setSupportedRealms(Collections.singletonList("A"));
    realmCHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-C")));
    List<ClaimsHandler> claimHandlers = new ArrayList<>();
    claimHandlers.add(realmAHandler);
    claimHandlers.add(realmBHandler);
    claimHandlers.add(realmCHandler);
    claimsManager.setClaimHandlers(Collections.unmodifiableList(claimHandlers));
    ClaimCollection requestedClaims = createClaimCollection();
    ClaimsParameters parameters = new ClaimsParameters();
    parameters.setRealm("A");
    parameters.setPrincipal(new CustomTokenPrincipal("alice"));
    ProcessedClaimCollection claims = claimsManager.retrieveClaimValues(requestedClaims, parameters);
    Assert.assertEquals("Number of claims incorrect", 3, claims.size());
// Asserts in RealmSupportClaimsHandler must succeed
}
Also used : CustomTokenPrincipal(org.apache.wss4j.common.principal.CustomTokenPrincipal) CustomIdentityMapper(org.apache.cxf.sts.operation.CustomIdentityMapper) ClaimsHandler(org.apache.cxf.sts.claims.ClaimsHandler) RealmSupportClaimsHandler(org.apache.cxf.sts.common.RealmSupportClaimsHandler) ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) ArrayList(java.util.ArrayList) ClaimsManager(org.apache.cxf.sts.claims.ClaimsManager) ClaimCollection(org.apache.cxf.rt.security.claims.ClaimCollection) ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) RealmSupportClaimsHandler(org.apache.cxf.sts.common.RealmSupportClaimsHandler) ClaimsParameters(org.apache.cxf.sts.claims.ClaimsParameters)

Example 4 with RealmSupportClaimsHandler

use of org.apache.cxf.sts.common.RealmSupportClaimsHandler in project cxf by apache.

the class RealmSupportTest method testIdentityMappingRealmA2B.

@org.junit.Test
public void testIdentityMappingRealmA2B() throws Exception {
    ClaimsManager claimsManager = new ClaimsManager();
    claimsManager.setIdentityMapper(new CustomIdentityMapper());
    RealmSupportClaimsHandler realmAHandler = new RealmSupportClaimsHandler();
    realmAHandler.setRealm("A");
    realmAHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-A")));
    RealmSupportClaimsHandler realmBHandler = new RealmSupportClaimsHandler();
    realmBHandler.setRealm("B");
    realmBHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-B")));
    RealmSupportClaimsHandler realmCHandler = new RealmSupportClaimsHandler();
    realmCHandler.setRealm("B");
    realmCHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-C")));
    List<ClaimsHandler> claimHandlers = new ArrayList<>();
    claimHandlers.add(realmAHandler);
    claimHandlers.add(realmBHandler);
    claimHandlers.add(realmCHandler);
    claimsManager.setClaimHandlers(Collections.unmodifiableList(claimHandlers));
    ClaimCollection requestedClaims = createClaimCollection();
    ClaimsParameters parameters = new ClaimsParameters();
    parameters.setRealm("A");
    parameters.setPrincipal(new CustomTokenPrincipal("alice"));
    ProcessedClaimCollection claims = claimsManager.retrieveClaimValues(requestedClaims, parameters);
    Assert.assertEquals("Number of claims incorrect", 3, claims.size());
}
Also used : CustomTokenPrincipal(org.apache.wss4j.common.principal.CustomTokenPrincipal) CustomIdentityMapper(org.apache.cxf.sts.operation.CustomIdentityMapper) ClaimsHandler(org.apache.cxf.sts.claims.ClaimsHandler) RealmSupportClaimsHandler(org.apache.cxf.sts.common.RealmSupportClaimsHandler) ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) ArrayList(java.util.ArrayList) ClaimsManager(org.apache.cxf.sts.claims.ClaimsManager) ClaimCollection(org.apache.cxf.rt.security.claims.ClaimCollection) ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) RealmSupportClaimsHandler(org.apache.cxf.sts.common.RealmSupportClaimsHandler) ClaimsParameters(org.apache.cxf.sts.claims.ClaimsParameters)

Aggregations

ArrayList (java.util.ArrayList)4 ClaimCollection (org.apache.cxf.rt.security.claims.ClaimCollection)4 ClaimsHandler (org.apache.cxf.sts.claims.ClaimsHandler)4 ClaimsManager (org.apache.cxf.sts.claims.ClaimsManager)4 ClaimsParameters (org.apache.cxf.sts.claims.ClaimsParameters)4 ProcessedClaimCollection (org.apache.cxf.sts.claims.ProcessedClaimCollection)4 RealmSupportClaimsHandler (org.apache.cxf.sts.common.RealmSupportClaimsHandler)4 CustomIdentityMapper (org.apache.cxf.sts.operation.CustomIdentityMapper)4 CustomTokenPrincipal (org.apache.wss4j.common.principal.CustomTokenPrincipal)4