use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.
the class EjbXACMLAuthorizationModuleTestCase method testAuthz.
/**
* Test secured EJB call for authenticated and authorized user.
*
* @throws Exception
*/
@Test
public void testAuthz() throws Exception {
SecurityClient securityClient = SecurityClientFactory.getSecurityClient();
securityClient.setSimple("jduke", "theduke");
try {
securityClient.login();
assertEquals(HelloBean.HELLO_WORLD, hello.sayHelloWorld());
} finally {
securityClient.logout();
}
}
use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.
the class AuthenticationTestCase method testAuthenticatedCall.
@Test
@Ignore("[WFLY-7778] EJB identity propagation does not work with Elytron")
public void testAuthenticatedCall() throws Exception {
// TODO: this is not spec
final SecurityClient client = SecurityClientFactory.getSecurityClient();
client.setSimple("user1", "password1");
client.login();
try {
try {
final Principal principal = whoAmIBean.getCallerPrincipal();
assertNotNull("EJB 3.1 FR 17.6.5 The container must never return a null from the getCallerPrincipal method.", principal);
assertEquals("user1", principal.getName());
} catch (RuntimeException e) {
e.printStackTrace();
fail("EJB 3.1 FR 17.6.5 The EJB container must provide the caller’s security context information during the execution of a business method (" + e.getMessage() + ")");
}
} finally {
client.logout();
}
}
use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.
the class RunAsPrincipalTestCase method testSingletonPostconstructSecurity.
@Test
public void testSingletonPostconstructSecurity() throws Exception {
SecurityClient client = SecurityClientFactory.getSecurityClient();
client.setSimple("user1", "password1");
client.login();
try {
WhoAmI bean = lookupSingleCallerWithIdentity();
String actual = bean.getCallerPrincipal();
Assert.assertEquals("Helloween", actual);
} finally {
client.logout();
}
}
use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.
the class RunAsPrincipalTestCase method testJackInABox.
@Test
public void testJackInABox() throws Exception {
SecurityClient client = SecurityClientFactory.getSecurityClient();
client.setSimple("user1", "password1");
client.login();
try {
WhoAmI bean = lookupCallerWithIdentity();
String actual = bean.getCallerPrincipal();
Assert.assertEquals("jackinabox", actual);
} finally {
client.logout();
}
}
use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.
the class RunAsPrincipalTestCase method testAnonymous.
@Test
public void testAnonymous() throws Exception {
SecurityClient client = SecurityClientFactory.getSecurityClient();
client.setSimple("user1", "password1");
client.login();
try {
WhoAmI bean = lookupCaller();
String actual = bean.getCallerPrincipal();
Assert.assertEquals("anonymous", actual);
} finally {
client.logout();
}
}
Aggregations