Search in sources :

Example 1 with HelloBean

use of org.jboss.as.test.integration.security.common.ejb3.HelloBean in project wildfly by wildfly.

the class RemotingLoginModuleUseNewClientCertTestCase method testAuthorizedClient.

/**
     * Tests that an authorized user has access to an EJB method.
     *
     * @throws Exception
     */
@Test
public void testAuthorizedClient() throws Exception {
    final Properties env = configureEjbClient(CLIENT_AUTHORIZED_NAME);
    InitialContext ctx = new InitialContext(env);
    final Hello helloBean = (Hello) ctx.lookup(HELLOBEAN_LOOKUP_NAME);
    assertEquals(HelloBean.HELLO_WORLD, helloBean.sayHelloWorld());
    ctx.close();
}
Also used : Hello(org.jboss.as.test.integration.security.common.ejb3.Hello) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 2 with HelloBean

use of org.jboss.as.test.integration.security.common.ejb3.HelloBean in project wildfly by wildfly.

the class RemotingLoginModuleTestCase method testNotAuthorizedClient.

/**
     * Tests if role check is done correctly for authenticated user.
     *
     * @throws Exception
     */
@Test
public void testNotAuthorizedClient() throws Exception {
    final Properties env = configureEjbClient(CLIENT_NOT_AUTHORIZED_NAME);
    InitialContext ctx = new InitialContext(env);
    final Hello helloBean = (Hello) ctx.lookup(HELLOBEAN_LOOKUP_NAME);
    try {
        helloBean.sayHelloWorld();
        fail("The EJB call should fail for unauthorized client.");
    } catch (EJBAccessException e) {
    //OK
    }
    ctx.close();
}
Also used : Hello(org.jboss.as.test.integration.security.common.ejb3.Hello) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) EJBAccessException(javax.ejb.EJBAccessException) Test(org.junit.Test)

Example 3 with HelloBean

use of org.jboss.as.test.integration.security.common.ejb3.HelloBean in project wildfly by wildfly.

the class RemotingLoginModuleTestCase method testAuthorizedClient.

/**
     * Tests that an authorized user has access to an EJB method.
     *
     * @throws Exception
     */
@Test
public void testAuthorizedClient() throws Exception {
    final Properties env = configureEjbClient(CLIENT_AUTHORIZED_NAME);
    InitialContext ctx = new InitialContext(env);
    final Hello helloBean = (Hello) ctx.lookup(HELLOBEAN_LOOKUP_NAME);
    assertEquals(HelloBean.HELLO_WORLD, helloBean.sayHelloWorld());
    ctx.close();
}
Also used : Hello(org.jboss.as.test.integration.security.common.ejb3.Hello) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 4 with HelloBean

use of org.jboss.as.test.integration.security.common.ejb3.HelloBean in project wildfly by wildfly.

the class RemotingLoginModuleUseNewClientCertTestCase method testNotAuthorizedClient.

/**
     * Tests if role check is done correctly for authenticated user.
     *
     * @throws Exception
     */
@Test
public void testNotAuthorizedClient() throws Exception {
    final Properties env = configureEjbClient(CLIENT_NOT_AUTHORIZED_NAME);
    InitialContext ctx = new InitialContext(env);
    final Hello helloBean = (Hello) ctx.lookup(HELLOBEAN_LOOKUP_NAME);
    try {
        helloBean.sayHelloWorld();
        fail("The EJB call should fail for unauthorized client.");
    } catch (EJBAccessException e) {
    //OK
    }
    ctx.close();
}
Also used : Hello(org.jboss.as.test.integration.security.common.ejb3.Hello) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) EJBAccessException(javax.ejb.EJBAccessException) Test(org.junit.Test)

Aggregations

Properties (java.util.Properties)4 InitialContext (javax.naming.InitialContext)4 Hello (org.jboss.as.test.integration.security.common.ejb3.Hello)4 Test (org.junit.Test)4 EJBAccessException (javax.ejb.EJBAccessException)2