Package org.apache.openejb.spi

Examples of org.apache.openejb.spi.SecurityService


        ThreadContext callContext = ThreadContext.getThreadContext();
        Object localClientIdentity = ClientSecurity.getIdentity();
        try {
            if (callContext == null && localClientIdentity != null) {
                SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
                securityService.associate(localClientIdentity);
            }
            if (strategy == CLASSLOADER_COPY) {

                IntraVmCopyMonitor.pre(strategy);
                ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
                Thread.currentThread().setContextClassLoader(getDeploymentInfo().getClassLoader());
                try {
                    args = copyArgs(args);
                    method = copyMethod(method);
                    interfce = copyObj(interfce);
                } finally {
                    Thread.currentThread().setContextClassLoader(oldClassLoader);
                    IntraVmCopyMonitor.post();
                }

            } else if (strategy == COPY && args != null && args.length > 0) {

                IntraVmCopyMonitor.pre(strategy);
                try {
                    args = copyArgs(args);
                } finally {
                    IntraVmCopyMonitor.post();
                }
            }

            try {

                Object returnValue = _invoke(proxy, interfce, method, args);

                return copy(strategy, returnValue);
            } catch (Throwable throwable) {
                throwable = copy(strategy, throwable);
                throw convertException(throwable, method, interfce);
            }
        } finally {
            if (callContext == null && localClientIdentity != null) {
                SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
                securityService.disassociate();
            }
        }
    }
View Full Code Here


                        logger.debug("startup.debugEntry", entry);
                    }
                }
            }

            SecurityService securityService = assembler.getSecurityService();
            if (securityService == null) {
                String msg = messages.message("startup.assemblerReturnedNullSecurityService");
                logger.fatal(msg);
                throw new OpenEJBException(msg);
            } else {
                logger.debug("startup.securityService", securityService.getClass().getName());
            }
            system.setComponent(SecurityService.class, securityService);

            TransactionManager transactionManager = assembler.getTransactionManager();
            if (transactionManager == null) {
View Full Code Here

        String pass = (String) env.get(Context.SECURITY_CREDENTIALS);
        String realmName = (String) env.get("openejb.authentication.realmName");

        if (user != null && pass != null){
            try {
                SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
                Object identity = null;
                if (realmName == null) {
                    identity = securityService.login(user, pass);
                } else {
                    identity = securityService.login(realmName, user, pass);
                }
                securityService.associate(identity);
            } catch (LoginException e) {
                throw (AuthenticationException) new AuthenticationException("User could not be authenticated: "+user).initCause(e);
            }
        }
View Full Code Here

    @Test
    public void isLogged() throws LoginException {
        final ThreadContext testContext = ThreadContext.getThreadContext();
        testContext.set(AbstractSecurityService.SecurityContext.class, null);

        final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
        final Object id = securityService.login("jonathan", "secret");
        securityService.associate(id);

        assertTrue(bean.isinRole("**"));
        assertFalse(bean.isinRole("whatever"));

        securityService.disassociate();
        securityService.logout(id);

        ThreadContext.enter(testContext);
    }
View Full Code Here

        }

        // log the user
        final String user = usernameToken.getName();
        final String password = pwCb.getPassword();
        final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
        final Object token;
        try {
            securityService.disassociate();

            token = securityService.login(user, password);
            securityService.associate(token);

        } catch (LoginException e) {
            throw new SecurityException("cannot log user " + user, e);
        }
    }
View Full Code Here

        if (user != null && pass != null) {
            try {
                if (logger.isDebugEnabled()) {
                    logger.debug("Logging in: " + user);
                }
                final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
                if (realmName == null) {
                    clientIdentity = securityService.login(user, pass);
                } else {
                    clientIdentity = securityService.login(realmName, user, pass);
                }
                ClientSecurity.setIdentity(clientIdentity);
            } catch (final LoginException e) {
                throw (AuthenticationException) new AuthenticationException("User could not be authenticated: " + user).initCause(e);
            }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    private void logout() {
        try {
            final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
            if (clientIdentity != null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Logging out: " + clientIdentity);
                }
                securityService.logout(clientIdentity);
                ClientSecurity.setIdentity(null);
            }
        } catch (final LoginException e) {
            throw new OpenEJBRuntimeException("User could not be logged out.", e);
        }
View Full Code Here

                        logger.debug("startup.debugEntry", entry);
                    }
                }
            }

            final SecurityService securityService = assembler.getSecurityService();
            if (securityService == null) {
                final String msg = messages.message("startup.assemblerReturnedNullSecurityService");
                logger.fatal(msg);
                throw new OpenEJBException(msg);
            } else {
                logger.debug("startup.securityService", securityService.getClass().getName());
            }
            system.setComponent(SecurityService.class, securityService);

            final TransactionManager transactionManager = assembler.getTransactionManager();
            if (transactionManager == null) {
View Full Code Here

        final ThreadContext callContext = ThreadContext.getThreadContext();
        final Object localClientIdentity = ClientSecurity.getIdentity();
        try {
            if (callContext == null && localClientIdentity != null) {
                final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
                securityService.associate(localClientIdentity);
            }
            if (strategy == CLASSLOADER_COPY || getBeanContext().getInterfaceType(interfce) == InterfaceType.BUSINESS_REMOTE) {

                IntraVmCopyMonitor.pre(strategy);
                final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
                Thread.currentThread().setContextClassLoader(getBeanContext().getClassLoader());
                try {
                    args = copyArgs(args);
                    method = copyMethod(method);
                    interfce = copyObj(interfce);
                } finally {
                    Thread.currentThread().setContextClassLoader(oldClassLoader);
                    IntraVmCopyMonitor.post();
                }

            } else if (strategy == COPY && args != null && args.length > 0) {

                IntraVmCopyMonitor.pre(strategy);
                try {
                    args = copyArgs(args);
                } finally {
                    IntraVmCopyMonitor.post();
                }
            }

            final IntraVmCopyMonitor.State oldStrategy = strategy;
            if (getBeanContext().isAsynchronous(method) || getBeanContext().getComponentType().equals(BeanType.MANAGED)) {
                strategy = IntraVmCopyMonitor.State.NONE;
            }

            try {

                final Object returnValue = _invoke(proxy, interfce, method, args);
                return copy(strategy, returnValue);
            } catch (Throwable throwable) {
                throwable = copy(strategy, throwable);
                throw convertException(throwable, method, interfce);
            } finally {
                strategy = oldStrategy;
            }
        } finally {

            if (callContext == null && localClientIdentity != null) {
                final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
                securityService.disassociate();
            }
        }
    }
View Full Code Here

                        logger.debug("startup.debugEntry", entry);
                    }
                }
            }

            final SecurityService securityService = assembler.getSecurityService();
            if (securityService == null) {
                final String msg = messages.message("startup.assemblerReturnedNullSecurityService");
                logger.fatal(msg);
                throw new OpenEJBException(msg);
            } else {
                logger.debug("startup.securityService", securityService.getClass().getName());
            }
            system.setComponent(SecurityService.class, securityService);

            final TransactionManager transactionManager = assembler.getTransactionManager();
            if (transactionManager == null) {
View Full Code Here

TOP

Related Classes of org.apache.openejb.spi.SecurityService

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.