Package org.apache.openejb.spi

Examples of org.apache.openejb.spi.SecurityService


        final BeanContext beanContext = getBeanContext();

        if (beanContext.isAsynchronous(method)) {

            final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
            Object stateTmp = securityService.currentState();
            final boolean associate;
            if (stateTmp == null) {
                stateTmp = ClientSecurity.getIdentity();
                associate = stateTmp != null;
            } else {
                associate = false;
            }
            final Object securityState = stateTmp;
            final ThreadContext currentCtx = ThreadContext.getThreadContext();
            final AsynchronousPool asynchronousPool = beanContext.getModuleContext().getAppContext().getAsynchronousPool();

            return asynchronousPool.invoke(new Callable<Object>() {
                @Override
                public Object call() throws Exception {
                    final Object threadState;
                    if (associate) {
                        //noinspection unchecked
                        securityService.associate(securityState);
                        threadState = null;
                    } else {
                        threadState = securityService.currentState();
                        securityService.setState(securityState);
                    }

                    final ThreadContext oldCtx; // ensure context is the same as for the caller
                    if (currentCtx != null) {
                        oldCtx = ThreadContext.enter(new ThreadContext(currentCtx));
                    } else {
                        oldCtx = null;
                    }
                    try {
                        return homeMethodInvoke(interfce, method, args);
                    } catch (final ApplicationException ae) {

                        logger.error("EjbHomeProxyHandler: Asynchronous call to '" + interfce.getSimpleName() + "' on '" + method.getName() + "' failed", ae);

                        throw ae;
                    } finally {
                        if (oldCtx != null) {
                            ThreadContext.exit(oldCtx);
                        }
                        if (!associate) {
                            securityService.setState(threadState);
                        } else {
                            securityService.disassociate();
                        }
                    }
                }
            }, method.getReturnType() == Void.TYPE);
        } else {
View Full Code Here


    protected Object businessMethod(final Class<?> interfce, final Method method, final Object[] args, final Object proxy) throws Throwable {
        final BeanContext beanContext = getBeanContext();

        if (beanContext.isAsynchronous(method)) {

            final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
            Object stateTmp = securityService.currentState();
            final boolean associate;
            if (stateTmp == null) {
                stateTmp = ClientSecurity.getIdentity();
                associate = stateTmp != null;
            } else {
                associate = false;
            }
            final Object securityState = stateTmp;

            final ThreadContext threadContext = ThreadContext.getThreadContext();
            final AsynchronousPool asynchronousPool = beanContext.getModuleContext().getAppContext().getAsynchronousPool();

            return asynchronousPool.invoke(new Callable<Object>() {
                @Override
                public Object call() throws Exception {
                    final Object threadState;
                    if (associate) {
                        //noinspection unchecked
                        securityService.associate(securityState);
                        threadState = null;
                    } else {
                        threadState = securityService.currentState();
                        securityService.setState(securityState);
                    }

                    final ThreadContext oldCtx; // ensure context is the same as for the caller
                    if (threadContext != null) {
                        oldCtx = ThreadContext.enter(new ThreadContext(threadContext));
                    } else {
                        oldCtx = null;
                    }

                    try {
                        return synchronizedBusinessMethod(interfce, method, args);
                    } catch (final ApplicationException ae) {

                        logger.error("EjbObjectProxyHandler: Asynchronous call to '" + interfce.getSimpleName() + "' on '" + method.getName() + "' failed", ae);

                        throw ae;
                    } finally {
                        if (oldCtx != null) {
                            ThreadContext.exit(oldCtx);
                        }
                        if (!associate) {
                            securityService.setState(threadState);
                        } else {
                            securityService.disassociate();
                        }
                    }
                }
            }, method.getReturnType() == Void.TYPE);
        } else {
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

            getNext().invoke(request, response);
        }
    }

    private TomcatSecurityService getSecurityService() {
        final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
        if (securityService instanceof TomcatSecurityService) {
            return (TomcatSecurityService) securityService;
        }
        return null;
    }
View Full Code Here

        transactionServiceInfo.id = "Default Transaction Manager";
        transactionServiceInfo.service = "TransactionManager";
        assembler.createTransactionManager(transactionServiceInfo);

        // install security service
        SecurityService securityService = new GeronimoSecurityService();
        SecurityServiceInfo securityServiceInfo = new SecurityServiceInfo();
        PassthroughFactory.add(securityServiceInfo, securityService);
        securityServiceInfo.id = "Default Security Service";
        securityServiceInfo.service = "SecurityService";
        assembler.createSecurityService(securityServiceInfo);
View Full Code Here

        serviceRegistry.getStartedService(NetworkConnectorTracker.NAME);
        modify().multiplicity(expect.from(0));
        tracker = (NetworkConnectorTracker) mock(NetworkConnectorTracker.class);
        modify().returnValue(tracker);

        SecurityService securityService = (SecurityService) mock(SecurityService.class);
        container = (ClusteredStatefulContainer) intercept(ClusteredStatefulContainer.class, new Object[] {"id",
                securityService});
        deploymentId = "deploymentId";
        deploymentInfo = new CoreDeploymentInfo(new DeploymentContext(deploymentId, null, null),
            SFSB.class,
View Full Code Here

        transactionServiceInfo.service = "TransactionManager";
        assembler.createTransactionManager(transactionServiceInfo);
      SystemInstance.get().setComponent(XAResourceWrapper.class, new GeronimoXAResourceWrapper());

        // install security service
        SecurityService securityService = new GeronimoSecurityService();
        SecurityServiceInfo securityServiceInfo = new SecurityServiceInfo();
        PassthroughFactory.add(securityServiceInfo, securityService);
        securityServiceInfo.id = "Default Security Service";
        securityServiceInfo.service = "SecurityService";
        assembler.createSecurityService(securityServiceInfo);
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

            }
        }
    }

    private TomcatSecurityService getSecurityService() {
        SecurityService securityService =  SystemInstance.get().getComponent(SecurityService.class);
        if (securityService instanceof TomcatSecurityService) {
            return (TomcatSecurityService) securityService;
        }
        return null;
    }
View Full Code Here

        String realmName = (String) properties.get("openejb.authentication.realmName");

        if (user != null && pass != null){
            try {
                logger.info("Logging in");
                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 (LoginException e) {
                throw (AuthenticationException) new AuthenticationException("User could not be authenticated: "+user).initCause(e);
            }
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.