use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.
the class AuthenticationTestCase method testAuthenticatedCall.
@Test
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 EjbXACMLAuthorizationModuleTestCase method testAuthenticationCache.
/**
* Tests unauthenticated call followed by the authentication and second call to the same instance.
*
* @throws Exception
*/
@Test
public void testAuthenticationCache() throws Exception {
try {
hello.sayHelloWorld();
fail("Access to sayHello() should be denied if not authenticated.");
} catch (EJBAccessException e) {
//OK
}
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 EjbXACMLAuthorizationModuleTestCase method testNotAuthz.
/**
* Test secured EJB call for authenticated but not authorized authorized user.
*
* @throws Exception
*/
@Test
public void testNotAuthz() throws Exception {
SecurityClient securityClient = SecurityClientFactory.getSecurityClient();
securityClient.setSimple("JohnDoe", "jdoe");
try {
securityClient.login();
hello.sayHelloWorld();
fail("Access to sayHelloWorld() should be denied for JohnDoe.");
} catch (EJBAccessException e) {
//OK - expected
} finally {
securityClient.logout();
}
}
use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.
the class DefaultManagedExecutorServiceTestCase method testTaskSubmit.
@Test
public void testTaskSubmit() throws Exception {
SecurityClient client = SecurityClientFactory.getSecurityClient();
client.setSimple("guest", "guest");
client.login();
try {
final DefaultManagedExecutorServiceTestEJB testEJB = (DefaultManagedExecutorServiceTestEJB) new InitialContext().lookup("java:module/" + DefaultManagedExecutorServiceTestEJB.class.getSimpleName());
testEJB.submit(new TestEJBRunnable()).get();
} finally {
client.logout();
}
}
use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.
the class DefaultManagedScheduledExecutorServiceTestCase method testTaskSubmit.
@Test
public void testTaskSubmit() throws Exception {
SecurityClient client = SecurityClientFactory.getSecurityClient();
client.setSimple("guest", "guest");
client.login();
try {
final DefaultManagedScheduledExecutorServiceTestEJB testEJB = (DefaultManagedScheduledExecutorServiceTestEJB) new InitialContext().lookup("java:module/" + DefaultManagedScheduledExecutorServiceTestEJB.class.getSimpleName());
testEJB.schedule(new TestEJBRunnable(), 10L, TimeUnit.MILLISECONDS).get();
} finally {
client.logout();
}
}
Aggregations