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;
});
}
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);
}
Aggregations