Search in sources :

Example 6 with EJBClientContext

use of org.jboss.ejb.client.EJBClientContext in project wildfly by wildfly.

the class SwitchIdentityTestCase method callUsingClientLoginModule.

// Private methods -------------------------------------------------------
/**
     * Perform the tests using the ClientLoginModule and LoginContext API to set the desired Principal.
     */
private void callUsingClientLoginModule(String userName, boolean hasRole1, boolean hasRole2) throws Exception {
    AuthenticationContext authenticationContext = setupAuthenticationContext(userName);
    authenticationContext.runCallable(() -> {
        // register the client side interceptor
        final EJBClientContext ejbClientContext = EJBClientContext.getCurrent().withAddedInterceptors(new ClientSecurityInterceptor());
        ejbClientContext.runCallable(() -> {
            final Manage targetBean = EJBUtil.lookupEJB(TargetBean.class, Manage.class);
            final Manage bridgeBean = EJBUtil.lookupEJB(BridgeBean.class, Manage.class);
            //test direct access
            testMethodAccess(targetBean, ManageMethodEnum.ALLROLES, true);
            testMethodAccess(targetBean, ManageMethodEnum.ROLE1, hasRole1);
            testMethodAccess(targetBean, ManageMethodEnum.ROLE2, hasRole2);
            //test security context propagation
            testMethodAccess(bridgeBean, ManageMethodEnum.ALLROLES, true);
            testMethodAccess(bridgeBean, ManageMethodEnum.ROLE1, hasRole1);
            testMethodAccess(bridgeBean, ManageMethodEnum.ROLE2, hasRole2);
            return null;
        });
        return null;
    });
}
Also used : AuthenticationContext(org.wildfly.security.auth.client.AuthenticationContext) EJBClientContext(org.jboss.ejb.client.EJBClientContext)

Example 7 with EJBClientContext

use of org.jboss.ejb.client.EJBClientContext in project wildfly by wildfly.

the class ClusterPassivationTestBase method waitForClusterContext.

/**
     * Waiting for getting cluster context - it could take some time for client to get info from cluster nodes
     */
protected void waitForClusterContext() throws InterruptedException {
    int counter = 0;
    EJBClientContext ejbClientContext = EJBClientContext.getCurrent();
// TODO Elytron: Determine how this should be adapted once the clustering and EJB client changes are in
// ClusterContext clusterContext;
//do {
//    clusterContext = ejbClientContext.getClusterContext(CLUSTER_NAME);
//    counter--;
//    Thread.sleep(CLUSTER_ESTABLISHMENT_WAIT_MS);
//} while (clusterContext == null && counter < CLUSTER_ESTABLISHMENT_LOOP_COUNT);
//Assert.assertNotNull("Cluster context for " + CLUSTER_NAME + " was not taken in "
//        + (CLUSTER_ESTABLISHMENT_LOOP_COUNT * CLUSTER_ESTABLISHMENT_WAIT_MS) + " ms", clusterContext);
}
Also used : EJBClientContext(org.jboss.ejb.client.EJBClientContext)

Aggregations

EJBClientContext (org.jboss.ejb.client.EJBClientContext)7 HashMap (java.util.HashMap)2 Hashtable (java.util.Hashtable)2 Properties (java.util.Properties)2 Context (javax.naming.Context)2 InitialContext (javax.naming.InitialContext)2 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)2 SimplePrincipal (org.jboss.resteasy.plugins.server.embedded.SimplePrincipal)2 Test (org.junit.Test)2 AuthenticationContext (org.wildfly.security.auth.client.AuthenticationContext)2 Map (java.util.Map)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1