Search in sources :

Example 6 with IdentityMapper

use of org.apache.cxf.sts.IdentityMapper in project cxf by apache.

the class EhCacheIdentityCacheTest method testTwoDistinctMappings.

@org.junit.Test
public void testTwoDistinctMappings() {
    IdentityMapper mapper = new CacheIdentityMapper();
    Bus bus = BusFactory.getDefaultBus();
    EHCacheIdentityCache cache = new EHCacheIdentityCache(mapper, bus);
    cache.mapPrincipal("REALM_A", new CustomTokenPrincipal("user_aaa"), "REALM_B");
    cache.mapPrincipal("REALM_C", new CustomTokenPrincipal("user_ccc"), "REALM_D");
    assertEquals(4, cache.size());
    assertNotNull(cache.get("user_aaa", "REALM_A"));
    assertNotNull(cache.get("user_bbb", "REALM_B"));
    assertNotNull(cache.get("user_ccc", "REALM_C"));
    assertNotNull(cache.get("user_ddd", "REALM_D"));
    cache.close();
}
Also used : CustomTokenPrincipal(org.apache.wss4j.common.principal.CustomTokenPrincipal) Bus(org.apache.cxf.Bus) IdentityMapper(org.apache.cxf.sts.IdentityMapper)

Example 7 with IdentityMapper

use of org.apache.cxf.sts.IdentityMapper in project cxf by apache.

the class MemoryIdentityCacheTest method testTwoDistinctAndOneRelatedMapping.

@org.junit.Test
public void testTwoDistinctAndOneRelatedMapping() {
    IdentityMapper mapper = new CacheIdentityMapper();
    MemoryIdentityCache cache = new MemoryIdentityCache(mapper);
    cache.mapPrincipal("REALM_A", new CustomTokenPrincipal("user_aaa"), "REALM_B");
    cache.mapPrincipal("REALM_C", new CustomTokenPrincipal("user_ccc"), "REALM_D");
    cache.mapPrincipal("REALM_A", new CustomTokenPrincipal("user_aaa"), "REALM_D");
    // now, mapping from A -> D and B -> D are cached as well
    assertEquals(4, cache.size());
    assertNotNull(cache.get("user_aaa", "REALM_A"));
    assertNotNull(cache.get("user_bbb", "REALM_B"));
    assertNotNull(cache.get("user_ccc", "REALM_C"));
    assertNotNull(cache.get("user_ddd", "REALM_D"));
    assertEquals(4, cache.get("user_aaa", "REALM_A").size());
    assertEquals(4, cache.get("user_bbb", "REALM_B").size());
    assertEquals(4, cache.get("user_ccc", "REALM_C").size());
    assertEquals(4, cache.get("user_ddd", "REALM_D").size());
}
Also used : CustomTokenPrincipal(org.apache.wss4j.common.principal.CustomTokenPrincipal) IdentityMapper(org.apache.cxf.sts.IdentityMapper)

Example 8 with IdentityMapper

use of org.apache.cxf.sts.IdentityMapper in project cxf by apache.

the class MemoryIdentityCacheTest method testOneMapping.

// tests TokenStore apis for storing in the cache.
@org.junit.Test
public void testOneMapping() throws Exception {
    IdentityMapper mapper = new CacheIdentityMapper();
    MemoryIdentityCache cache = new MemoryIdentityCache(mapper);
    cache.mapPrincipal("REALM_A", new CustomTokenPrincipal("user_aaa"), "REALM_B");
    assertEquals(2, cache.size());
    assertNotNull(cache.get("user_aaa", "REALM_A"));
    assertNotNull(cache.get("user_bbb", "REALM_B"));
}
Also used : CustomTokenPrincipal(org.apache.wss4j.common.principal.CustomTokenPrincipal) IdentityMapper(org.apache.cxf.sts.IdentityMapper)

Example 9 with IdentityMapper

use of org.apache.cxf.sts.IdentityMapper in project cxf by apache.

the class MemoryIdentityCacheTest method testTwoDistinctMappings.

@org.junit.Test
public void testTwoDistinctMappings() {
    IdentityMapper mapper = new CacheIdentityMapper();
    MemoryIdentityCache cache = new MemoryIdentityCache(mapper);
    cache.mapPrincipal("REALM_A", new CustomTokenPrincipal("user_aaa"), "REALM_B");
    cache.mapPrincipal("REALM_C", new CustomTokenPrincipal("user_ccc"), "REALM_D");
    assertEquals(4, cache.size());
    assertNotNull(cache.get("user_aaa", "REALM_A"));
    assertNotNull(cache.get("user_bbb", "REALM_B"));
    assertNotNull(cache.get("user_ccc", "REALM_C"));
    assertNotNull(cache.get("user_ddd", "REALM_D"));
}
Also used : CustomTokenPrincipal(org.apache.wss4j.common.principal.CustomTokenPrincipal) IdentityMapper(org.apache.cxf.sts.IdentityMapper)

Aggregations

IdentityMapper (org.apache.cxf.sts.IdentityMapper)9 CustomTokenPrincipal (org.apache.wss4j.common.principal.CustomTokenPrincipal)8 Bus (org.apache.cxf.Bus)4 Principal (java.security.Principal)1 Relationship (org.apache.cxf.sts.token.realm.Relationship)1 RelationshipResolver (org.apache.cxf.sts.token.realm.RelationshipResolver)1 STSException (org.apache.cxf.ws.security.sts.provider.STSException)1