use of org.apache.tomee.catalina.realm.CdiEventRealm in project tomee by apache.
the class CdiEventRealmTest method ssl.
@Test
public void ssl() {
X509Certificate cert = mock(X509Certificate.class);
GenericPrincipal expected = new GenericPrincipal("john", "doe", Arrays.asList("test"));
when(cert.getSubjectDN()).thenReturn(expected);
final GenericPrincipal gp = getGenericPrincipal(new CdiEventRealm().authenticate(new X509Certificate[] { cert }));
assertEquals(expected, gp);
assertEquals("john", gp.getName());
assertEquals("doe", gp.getPassword());
assertEquals(1, gp.getRoles().length);
assertEquals("test", gp.getRoles()[0]);
}
use of org.apache.tomee.catalina.realm.CdiEventRealm in project tomee by apache.
the class CdiEventRealmTest method gss.
@Test
public void gss() {
final GenericPrincipal gp = getGenericPrincipal(new CdiEventRealm().authenticate(mock(GSSContext.class), false));
assertEquals("gss", gp.getName());
assertEquals("", gp.getPassword());
assertEquals(1, gp.getRoles().length);
assertEquals("dummy", gp.getRoles()[0]);
}
use of org.apache.tomee.catalina.realm.CdiEventRealm 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.tomee.catalina.realm.CdiEventRealm in project tomee by apache.
the class CdiEventRealmTest method find.
@Test
public void find() {
final SecurityConstraint[] securityConstraints = new CdiEventRealm().findSecurityConstraints(mock(Request.class), mock(Context.class));
assertEquals(1, securityConstraints.length);
final SecurityConstraint c = securityConstraints[0];
assertEquals("CONFIDENTIAL", c.getUserConstraint());
assertEquals(2, c.findAuthRoles().length);
assertEquals(1, c.findCollections().length);
SecurityCollection sc = c.findCollections()[0];
assertTrue(sc.findPattern("/*"));
}
use of org.apache.tomee.catalina.realm.CdiEventRealm 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