Package org.jboss.ejb.client.EJBClientInterceptor

Examples of org.jboss.ejb.client.EJBClientInterceptor.Registration


            loginContext = new LoginContext("foo", new Subject(), new UsernamePasswordHandler(userName, new char[0]),
                    CLIENT_LOGIN_CONFIG);
            loginContext.login();

            // register the client side interceptor
            final Registration clientInterceptorHandler = EJBClientContext.requireCurrent().registerInterceptor(112567,
                    new ClientSecurityInterceptor());

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

            clientInterceptorHandler.remove();
        } finally {
            if (loginContext != null) {
                loginContext.logout();
            }
        }
View Full Code Here


            final Properties ejbClientConfiguration = EJBUtil.createEjbClientConfiguration(Utils.getHost(mgmtClient));
            EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(ejbClientConfiguration);
            final ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
            EJBClientContext.setSelector(selector);
            // register the client side interceptor
            final Registration clientInterceptorHandler = EJBClientContext.requireCurrent().registerInterceptor(112567,
                    new ClientSecurityInterceptor());
            SecurityContextAssociation.setPrincipal(new SimplePrincipal(userName));

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

            clientInterceptorHandler.remove();
        } finally {
            SecurityContextAssociation.clearSecurityContext();
        }
    }
View Full Code Here

            loginContext = new LoginContext("foo", new Subject(), new UsernamePasswordHandler(userName, new char[0]),
                    CLIENT_LOGIN_CONFIG);
            loginContext.login();

            // register the client side interceptor
            final Registration clientInterceptorHandler = EJBClientContext.requireCurrent().registerInterceptor(112567,
                    new ClientSecurityInterceptor());

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

            clientInterceptorHandler.remove();
        } finally {
            if (loginContext != null) {
                loginContext.logout();
            }
        }
View Full Code Here

            final Properties ejbClientConfiguration = EJBUtil.createEjbClientConfiguration(Utils.getHost(mgmtClient));
            EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(ejbClientConfiguration);
            final ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
            EJBClientContext.setSelector(selector);
            // register the client side interceptor
            final Registration clientInterceptorHandler = EJBClientContext.requireCurrent().registerInterceptor(112567,
                    new ClientSecurityInterceptor());
            SecurityContextAssociation.setPrincipal(new SimplePrincipal(userName));

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

            clientInterceptorHandler.remove();
        } finally {
            SecurityContextAssociation.clearSecurityContext();
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.ejb.client.EJBClientInterceptor.Registration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.