use of org.apache.cxf.common.security.SimplePrincipal in project cxf by apache.
the class DefaultSecurityContextTest method testUserInRole3.
@Test
public void testUserInRole3() {
Subject s = new Subject();
Principal p = new SimplePrincipal("Barry");
s.getPrincipals().add(p);
GroupPrincipal group = new SimpleGroup("Roles", p);
GroupPrincipal subgroup = new SimpleGroup("subgroup");
subgroup.addMember(new SimpleGroup("friend"));
group.addMember(subgroup);
s.getPrincipals().add(group);
assertTrue(new DefaultSecurityContext(p, s).isUserInRole("friend"));
}
use of org.apache.cxf.common.security.SimplePrincipal in project cxf by apache.
the class DefaultSecurityContextTest method testUserInRole.
@Test
public void testUserInRole() {
Subject s = new Subject();
Principal p = new SimplePrincipal("Barry");
s.getPrincipals().add(p);
s.getPrincipals().add(new SimpleGroup("friend", p));
assertTrue(new DefaultSecurityContext(p, s).isUserInRole("friend"));
}
use of org.apache.cxf.common.security.SimplePrincipal in project cxf by apache.
the class RolePrefixSecurityContextImplTest method testUserInRoleWithRolePrincipal.
@Test
public void testUserInRoleWithRolePrincipal() {
Subject s = new Subject();
Principal p = new SimplePrincipal("Barry");
s.getPrincipals().add(p);
s.getPrincipals().add(new RolePrincipal("friend"));
assertTrue(new RolePrefixSecurityContextImpl(s, "RolePrincipal", "classname").isUserInRole("friend"));
}
use of org.apache.cxf.common.security.SimplePrincipal in project cxf by apache.
the class RolePrefixSecurityContextImplTest method testMultipleRoles.
@Test
public void testMultipleRoles() {
Subject s = new Subject();
Principal p = new SimplePrincipal("Barry");
s.getPrincipals().add(p);
Set<Principal> roles = new HashSet<>();
roles.add(new SimplePrincipal("role_friend"));
roles.add(new SimplePrincipal("role_admin"));
s.getPrincipals().addAll(roles);
LoginSecurityContext context = new RolePrefixSecurityContextImpl(s, "role_");
assertTrue(context.isUserInRole("role_friend"));
assertTrue(context.isUserInRole("role_admin"));
assertFalse(context.isUserInRole("role_bar"));
Set<Principal> roles2 = context.getUserRoles();
assertEquals(roles2, roles);
}
use of org.apache.cxf.common.security.SimplePrincipal in project cxf by apache.
the class RolePrefixSecurityContextImplTest method testUserInRole.
@Test
public void testUserInRole() {
Subject s = new Subject();
Principal p = new SimplePrincipal("Barry");
s.getPrincipals().add(p);
s.getPrincipals().add(new SimplePrincipal("role_friend"));
assertTrue(new RolePrefixSecurityContextImpl(s, "role_").isUserInRole("role_friend"));
}
Aggregations