Package org.apache.openejb.spi

Examples of org.apache.openejb.spi.SecurityService


            }

            //
            // Security Service
            //
            SecurityService securityService = getSecurityService();
            if (securityService == null) {
                securityService = getBeanForType(applicationContext, SecurityService.class);
            }
            if (securityService != null) {
                SecurityServiceInfo info = initPassthrough(new SecurityServiceInfo(), "SecurityService", securityService);
View Full Code Here


        assertSame(springTM, initialContext.lookup("openejb/TransactionManager"));

        //
        // SecurityService
        //
        SecurityService springSecurityService = (SecurityService) context.getBean("sec");
        assertNotNull("springSecurityService is null", springSecurityService);
        assertTrue("springSecurityService should be an instance of MockSecurityService", springSecurityService instanceof MockSecurityService);

        SecurityService systemSecurityService = SystemInstance.get().getComponent(SecurityService.class);
        assertNotNull("systemSecurityService is null", systemSecurityService);
        assertSame(springSecurityService, systemSecurityService);

        assertSame(springSecurityService, initialContext.lookup("openejb/SecurityService"));
View Full Code Here

            String securityRealm = req.getRealm();
            String username = req.getUsername();
            String password = req.getCredentials();

            SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
            Object token = securityService.login(securityRealm, username, password);

            ClientMetaData client = new ClientMetaData();
            client.setClientIdentity(token);

            res.setIdentity(client);
View Full Code Here

public class ServerPasswordHandler implements CallbackHandler {
    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
        WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];

        SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
        Object token = null;
        try {
            securityService.disassociate();

            token = securityService.login(pc.getIdentifer(), pc.getPassword());
            securityService.associate(token);
        } catch (LoginException e) {
            throw new SecurityException("wrong password");
        } finally {
//            if (token != null) {
//                securityService.disassociate();
View Full Code Here

        } catch (Throwable t) {
            replyWithFatalError(out, t, "Unable to set the thread context for this request");
            return;
        }

        SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
        try {
            Object clientIdentity = req.getClientIdentity();
            if (clientIdentity != null) securityService.associate(clientIdentity);
        } catch (Throwable t) {
            replyWithFatalError(out, t, "Security system failed to associate thread with the thread");
            return;
        }

        try {
            switch (req.getRequestMethod()) {
            // Remote interface methods
                case RequestMethodConstants.EJB_OBJECT_BUSINESS_METHOD:
                    doEjbObject_BUSINESS_METHOD(req, res);
                    updateServer(req, res);
                    break;

                // Home interface methods
                case RequestMethodConstants.EJB_HOME_CREATE:
                    doEjbHome_CREATE(req, res);
                    updateServer(req, res);
                    break;

                // Home interface methods
                case RequestMethodConstants.EJB_HOME_METHOD:
                    doEjbHome_METHOD(req, res);
                    updateServer(req, res);
                    break;

                case RequestMethodConstants.EJB_HOME_FIND:
                    doEjbHome_FIND(req, res);
                    updateServer(req, res);
                    break;

                // javax.ejb.EJBObject methods
                case RequestMethodConstants.EJB_OBJECT_GET_EJB_HOME:
                    doEjbObject_GET_EJB_HOME(req, res);
                    updateServer(req, res);
                    break;

                case RequestMethodConstants.EJB_OBJECT_GET_HANDLE:
                    doEjbObject_GET_HANDLE(req, res);
                    updateServer(req, res);
                    break;

                case RequestMethodConstants.EJB_OBJECT_GET_PRIMARY_KEY:
                    doEjbObject_GET_PRIMARY_KEY(req, res);
                    updateServer(req, res);
                    break;

                case RequestMethodConstants.EJB_OBJECT_IS_IDENTICAL:
                    doEjbObject_IS_IDENTICAL(req, res);
                    updateServer(req, res);
                    break;

                case RequestMethodConstants.EJB_OBJECT_REMOVE:
                    doEjbObject_REMOVE(req, res);
                    break;

                // javax.ejb.EJBHome methods
                case RequestMethodConstants.EJB_HOME_GET_EJB_META_DATA:
                    doEjbHome_GET_EJB_META_DATA(req, res);
                    updateServer(req, res);
                    break;

                case RequestMethodConstants.EJB_HOME_GET_HOME_HANDLE:
                    doEjbHome_GET_HOME_HANDLE(req, res);
                    updateServer(req, res);
                    break;

                case RequestMethodConstants.EJB_HOME_REMOVE_BY_HANDLE:
                    doEjbHome_REMOVE_BY_HANDLE(req, res);
                    break;

                case RequestMethodConstants.EJB_HOME_REMOVE_BY_PKEY:
                    doEjbHome_REMOVE_BY_PKEY(req, res);
                    break;
            }

        } catch (org.apache.openejb.InvalidateReferenceException e) {
            res.setResponse(ResponseCodes.EJB_SYS_EXCEPTION, new ThrowableArtifact(e.getRootCause()));
        } catch (org.apache.openejb.ApplicationException e) {
            res.setResponse(ResponseCodes.EJB_APP_EXCEPTION, new ThrowableArtifact(e.getRootCause()));
        } catch (org.apache.openejb.SystemException e) {
            res.setResponse(ResponseCodes.EJB_ERROR, new ThrowableArtifact(e.getRootCause()));

            logger.fatal(req + ": OpenEJB encountered an unknown system error in container: ", e);
        } catch (java.lang.Throwable t) {
            // todo this causes the response to be written twice but the code below
            replyWithFatalError
                    (out, t, "Unknown error in container");
            return;
        } finally {
            if (logger.isDebugEnabled()){
                try {
                    logger.debug("EJB REQUEST: "+req+" -- RESPONSE: " + res);
                } catch (Exception justInCase) {}
            }
            try {
                res.writeExternal(out);
            } catch (java.io.IOException ie) {
                logger.fatal("Couldn't write EjbResponse to output stream", ie);
            }
            securityService.disassociate();
            call.reset();
            EJBHomeProxyHandle.resolver.set(null);
            EJBObjectProxyHandle.resolver.set(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

                if (parts != null && parts.length == 2) {
                    String username = parts[0];
                    String password = parts[1];

                    try {
                        final SecurityService securityService = getSecurityService();
                        token = securityService.login(realmName, username, password);
                        if (token != null) {
                            securityService.associate(token);
                        }
                    } catch (LoginException e) {
                        // login failed, return 401
                    }
                }
View Full Code Here

           getSecurityService().disassociate();
        }
    }

    private SecurityService getSecurityService() {
        final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
        return securityService;
    }
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

        }
       
        if ((pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN)
          || (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN)) {
           
            SecurityService securityService = SystemInstance.get()
        .getComponent(SecurityService.class);
      Object token = null;
      try {
    securityService.disassociate();

    token = securityService.login(pc.getIdentifer(), pc.getPassword());
    securityService.associate(token);
   
      } catch (LoginException e) {
    e.printStackTrace();
    throw new SecurityException("wrong password");
      } finally {
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.