Package org.mule.api.security

Source Code of org.mule.api.security.UnauthorisedException

/*
* $Id: UnauthorisedException.java 20866 2011-01-04 01:48:01Z dandiep $
* --------------------------------------------------------------------------------------
* Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
*
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/

package org.mule.api.security;

import org.mule.RequestContext;
import org.mule.api.MuleEvent;
import org.mule.api.endpoint.ImmutableEndpoint;
import org.mule.config.i18n.CoreMessages;
import org.mule.config.i18n.Message;

/**
* <code>UnauthorisedException</code> is thrown if authentication fails
*/

public class UnauthorisedException extends SecurityException
{
    /**
     * Serial version
     */
    private static final long serialVersionUID = -6664384216189042673L;

    public UnauthorisedException(Message message)
    {
        super(message, RequestContext.getEvent());
    }

    public UnauthorisedException(Message message, Throwable cause)
    {
        super(message, RequestContext.getEvent(), cause);
    }

    public UnauthorisedException(Message message, MuleEvent event)
    {
        super(message, event);
    }

    public UnauthorisedException(Message message, MuleEvent event, Throwable cause)
    {
        super(message, event, cause);
    }

    public UnauthorisedException(MuleEvent event, SecurityContext context, SecurityFilter filter)
    {
        super(constructMessage(context, event.getEndpoint(), filter), event);
    }

    @Deprecated
    public UnauthorisedException(MuleEvent event, SecurityContext context,
        ImmutableEndpoint endpoint, SecurityFilter filter)
    {
        super(constructMessage(context, endpoint, filter), event);
    }

    private static Message constructMessage(SecurityContext context, ImmutableEndpoint endpoint,
                                            SecurityFilter filter)
    {

        Message m;
        if (context == null)
        {
            m = CoreMessages.authSetButNoContext(filter.getClass().getName());
        }
        else
        {
            m = CoreMessages.authFailedForUser(context.getAuthentication().getPrincipal());
        }
        m.setNextMessage(CoreMessages.authDeniedOnEndpoint(endpoint.getEndpointURI()));
        return m;
    }
}
TOP

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

TOP
Copyright © 2018 www.massapi.com. 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.