Package org.mule.api.security

Examples of org.mule.api.security.Authentication


        {
            throw new CredentialsNotSetException(event, event.getSession().getSecurityContext(), this);
        }

        Credentials user = new MuleCredentials(userHeader, getSecurityManager());
        Authentication authResult;
        JaasAuthentication authentication = new JaasAuthentication(user);
        authentication.setEvent(event);
        try
        {
            authResult = getSecurityManager().authenticate(authentication);
        }
        catch (SecurityException se)
        {
            // Security Exception occurred
            if (logger.isDebugEnabled())
            {
                logger.debug("Security Exception raised. Authentication request for user: " + user.getUsername()
                    + " failed: " + se.toString());
            }
            throw se;
        }
        catch (Exception e)
        {
            // Authentication failed
            if (logger.isDebugEnabled())
            {
                logger.debug("Authentication request for user: " + user.getUsername()
                    + " failed: " + e.toString());
            }
            throw new UnauthorisedException(
                CoreMessages.authFailedForUser(user.getUsername()), event, e);
        }

        // Authentication success
        if (logger.isDebugEnabled())
        {
            logger.debug("Authentication success: " + authResult.toString());
        }

        SecurityContext context = getSecurityManager().createSecurityContext(authResult);
        context.setAuthentication(authResult);
        event.getSession().setSecurityContext(context);
View Full Code Here


            {
                return;
            }
        }

        Authentication auth = securityContext.getAuthentication();
        if (isAuthenticate())
        {
            auth = getSecurityManager().authenticate(auth);
            if (logger.isDebugEnabled())
            {
                logger.debug("Authentication success: " + auth.toString());
            }
        }

        String token = auth.getCredentials().toString();
        getCredentialsAccessor().setCredentials(event, token);

    }
View Full Code Here

    {
        String user = (String) authentication.getPrincipal();
        logger.debug("Authenticating user: " + user);

        // Check to see if user has already been authenticated
        Authentication oldAuth = authentications.get(user);
        if (oldAuth != null)
        {
            authentication = oldAuth;
            Map<String, Object> props = authentication.getProperties();
            int numberLogins = (Integer) props.get(PROPERTY_NUMBER_LOGINS);
View Full Code Here

    protected static final Log logger = LogFactory.getLog(TestSecurityComponent.class);
   
    public Object onCall(MuleEventContext eventContext) throws Exception
    {
        SecurityContext securityContext = eventContext.getSession().getSecurityContext();
        Authentication authentication = securityContext.getAuthentication();

        int numberLogins = (Integer) authentication.getProperties().get(TestSingleUserSecurityProvider.PROPERTY_NUMBER_LOGINS);
        String favoriteColor = (String) authentication.getProperties().get(TestSingleUserSecurityProvider.PROPERTY_FAVORITE_COLOR);

        String msg = "user = " + authentication.getPrincipal() + ", logins = " + numberLogins + ", color = " + favoriteColor;
        logger.debug(msg);
        return msg;
    }
View Full Code Here

            {
                username = token.substring(0, delim);
                password = token.substring(delim + 1);
            }

            Authentication authResult;
            Authentication authentication = createAuthentication(username, password, event);

            try
            {
                authResult = getSecurityManager().authenticate(authentication);
            }
View Full Code Here

            {
                return;
            }
        }

        Authentication auth = securityContext.getAuthentication();
        if (isAuthenticate())
        {
            auth = getSecurityManager().authenticate(auth);
            if (logger.isDebugEnabled())
            {
                logger.debug("Authentication success: " + auth.toString());
            }
        }

        StringBuilder header = new StringBuilder(128);
        header.append("Basic ");
        String token = auth.getCredentials().toString();
        header.append(new String(Base64.encodeBase64(token.getBytes())));

        event.getMessage().setOutboundProperty(HttpConstants.HEADER_AUTHORIZATION, header.toString());
    }
View Full Code Here

    }

    @Test
    public void testAuthenticate() throws Exception
    {
        Authentication auth = new PGPAuthentication("Mule client <mule_client@mule.com>", message);
        auth = securityProvider.authenticate(auth);
        assertTrue(auth.isAuthenticated());
    }
View Full Code Here

TOP

Related Classes of org.mule.api.security.Authentication

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.