Package org.mule.api.security

Examples of org.mule.api.security.Authentication


            {
                return;
            }
        }

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

        StringBuffer header = new StringBuffer(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


    {
        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 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

        catch (Exception e1)
        {
            throw new UnauthorisedException(CoreMessages.failedToReadPayload(), event, e1);
        }

        Authentication authentication;
        try
        {
            authentication = new PGPAuthentication(userId, decodeMsgRaw(creds), event);
        }
        catch (Exception e1)
        {
            throw new UnauthorisedException(CoreMessages.failedToReadPayload(), event, e1);
        }

        final Authentication authResult;
        try
        {
            authResult = getSecurityManager().authenticate(authentication);
        }
        catch (Exception e)
        {
            // Authentication failed
            if (logger.isDebugEnabled())
            {
                logger.debug("Authentication request for user: " + userId + " failed: " + e.toString());
            }

            throw new UnauthorisedException(CoreMessages.authFailedForUser(userId), event, e);
        }

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

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

        assertNull(after.getProperty("foo"));
    }

    private SecurityContext createTestAuthentication()
    {
        Authentication auth = new DefaultMuleAuthentication(new MuleCredentials("dan", new char[] {'d', 'f'}));
        auth.setProperties(Collections.<String, Object>singletonMap("key1", "value1"));
        SecurityContext securityContext = new DefaultSecurityContextFactory().create(auth);
        return securityContext;
    }
View Full Code Here

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

        Credentials user = new MuleCredentials(userHeader, getSecurityManager());

        Authentication authentication;
        try
        {
            authentication = getSecurityManager().authenticate(new DefaultMuleAuthentication(user, event));
        }
        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: " + authentication.toString());
        }

        SecurityContext context = getSecurityManager().createSecurityContext(authentication);
        context.setAuthentication(authentication);
        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();
        String header = new String(strategy.encrypt(token.getBytes(), null));
        getCredentialsAccessor().setCredentials(event, header);

    }
View Full Code Here

     */
    @Override
    public void authenticate(MuleEvent event)
        throws SecurityException, SecurityProviderNotFoundException, UnknownAuthenticationTypeException
    {
        Authentication authentication = getAuthenticationToken(event);
        Authentication authResult;
        try
        {
            authResult = getSecurityManager().authenticate(authentication);
        }
        catch (UnauthorisedException e)
        {
            // Authentication failed
            if (logger.isDebugEnabled())
            {
                logger.debug("Authentication request for user: " + username + " failed: " + e.toString());
            }
            throw new UnauthorisedException(CoreMessages.authFailedForUser(authentication.getPrincipal().toString()), 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

                if (logger.isDebugEnabled())
                {
                    logger.debug("Authentication attempt using " + provider.getClass().getName());
                }

                Authentication result = null;
                try
                {
                    result = provider.authenticate(authentication);
                }
                catch (Exception e)
View Full Code Here

    public void doFilter(MuleEvent event)
        throws SecurityException, UnknownAuthenticationTypeException, CryptoFailureException,
        SecurityProviderNotFoundException, EncryptionStrategyNotFoundException, InitialisationException
    {
        Authentication auth = event.getSession().getSecurityContext().getAuthentication();
        if (auth == null)
        {
            throw new UnauthorisedException(CoreMessages.authNoCredentials());
        }
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.