use of org.apache.cxf.common.security.SimpleGroup 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.SimpleGroup 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);
Group group = new SimpleGroup("Roles", p);
Group 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.SimpleGroup in project cxf by apache.
the class TestUserPasswordLoginModule method login.
@Override
public boolean login() throws LoginException {
NameCallback nameCallback = new NameCallback("User");
PasswordCallback passwordCallback = new PasswordCallback("Password", false);
Callback[] callbacks = new Callback[] { nameCallback, passwordCallback };
try {
this.callbackHandler.handle(callbacks);
} catch (IOException e) {
throw new LoginException(e.getMessage());
} catch (UnsupportedCallbackException e) {
throw new LoginException(e.getMessage());
}
String userName = nameCallback.getName();
String password = new String(passwordCallback.getPassword());
if (!TESTUSER.equals(userName)) {
throw new LoginException("wrong username");
}
if (!TESTPASS.equals(password)) {
throw new LoginException("wrong password");
}
subject.getPrincipals().add(new SimplePrincipal(userName));
subject.getPrincipals().add(new SimpleGroup(TESTGROUP));
return true;
}
Aggregations