KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > umo > security > UnauthorisedException


1 /*
2  * $Id: UnauthorisedException.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.umo.security;
12
13 import org.mule.config.i18n.Message;
14 import org.mule.config.i18n.Messages;
15 import org.mule.impl.RequestContext;
16 import org.mule.umo.UMOMessage;
17 import org.mule.umo.endpoint.UMOImmutableEndpoint;
18
19 /**
20  * <code>UnauthorisedException</code> is thrown if authentication fails
21  *
22  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
23  * @version $Revision: 3798 $
24  */

25
26 public class UnauthorisedException extends SecurityException JavaDoc
27 {
28     /**
29      * Serial version
30      */

31     private static final long serialVersionUID = -6664384216189042672L;
32
33     public UnauthorisedException(Message message)
34     {
35         super(message, RequestContext.getEventContext().getMessage());
36     }
37
38     public UnauthorisedException(Message message, Throwable JavaDoc cause)
39     {
40         super(message, RequestContext.getEventContext().getMessage(), cause);
41     }
42
43     public UnauthorisedException(Message message, UMOMessage umoMessage)
44     {
45         super(message, umoMessage);
46     }
47
48     public UnauthorisedException(Message message, UMOMessage umoMessage, Throwable JavaDoc cause)
49     {
50         super(message, umoMessage, cause);
51     }
52
53     public UnauthorisedException(UMOMessage umoMessage,
54                                  UMOSecurityContext context,
55                                  UMOImmutableEndpoint endpoint,
56                                  UMOEndpointSecurityFilter filter)
57     {
58         super(constructMessage(context, endpoint, filter), umoMessage);
59     }
60
61     private static Message constructMessage(UMOSecurityContext context,
62                                             UMOImmutableEndpoint endpoint,
63                                             UMOEndpointSecurityFilter filter)
64     {
65
66         Message m = null;
67         if (context == null)
68         {
69             m = new Message(Messages.AUTH_SET_TO_X_BUT_NO_CONTEXT, filter.getClass().getName());
70         }
71         else
72         {
73             m = new Message(Messages.AUTH_FAILED_FOR_USER_X, context.getAuthentication().getPrincipal());
74         }
75         m.setNextMessage(new Message(Messages.AUTH_DENIED_ON_ENDPOINT_X, endpoint.getEndpointURI()));
76         return m;
77     }
78 }
79
Popular Tags