use of org.apache.catalina.realm.GenericPrincipal in project tomcat by apache.
the class DeltaRequest method setPrincipal.
/**
* Only support principals from type {@link GenericPrincipal GenericPrincipal}
* @param p Session principal
* @see GenericPrincipal
*/
public void setPrincipal(Principal p) {
int action = (p == null) ? ACTION_REMOVE : ACTION_SET;
GenericPrincipal gp = null;
if (p != null) {
if (p instanceof GenericPrincipal) {
gp = (GenericPrincipal) p;
if (log.isDebugEnabled())
log.debug(sm.getString("deltaRequest.showPrincipal", p.getName(), getSessionId()));
} else
log.error(sm.getString("deltaRequest.wrongPrincipalClass", p.getClass().getName()));
}
addAction(TYPE_PRINCIPAL, action, NAME_PRINCIPAL, gp);
}
use of org.apache.catalina.realm.GenericPrincipal in project tomee by apache.
the class CdiEventRealmTest method digest.
@Test
public void digest() {
final GenericPrincipal gp = getGenericPrincipal(new CdiEventRealm().authenticate("ryan", "md5", "nonce", "nc", "cnonce", "qop", "realm", "md5a2"));
final String[] actual = gp.getRoles();
final String[] expected = new String[] { "ryan", "md5", "nonce", "nc", "cnonce", "qop", "realm", "md5a2" };
Arrays.sort(actual);
Arrays.sort(expected);
assertArrayEquals(actual, expected);
}
use of org.apache.catalina.realm.GenericPrincipal in project tomee by apache.
the class CdiEventRealmTest method userPassword.
@Test
public void userPassword() {
final GenericPrincipal gp = getGenericPrincipal(new CdiEventRealm().authenticate("john", "secret"));
assertEquals("john", gp.getName());
assertEquals("", gp.getPassword());
assertEquals(1, gp.getRoles().length);
assertEquals("admin", gp.getRoles()[0]);
}
Aggregations