]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
730a7d2cb678864338518b1e860866f8b85c36ae
[tmp/jakarta-migration.git] /
1 /**
2  *  This document is a part of the source code and related artifacts
3  *  for CollectionSpace, an open source collections management system
4  *  for museums and related institutions:
5
6  *  http://www.collectionspace.org
7  *  http://wiki.collectionspace.org
8
9  *  Copyright 2009 University of California at Berkeley
10
11  *  Licensed under the Educational Community License (ECL), Version 2.0.
12  *  You may not use this file except in compliance with this License.
13
14  *  You may obtain a copy of the ECL 2.0 License at
15
16  *  https://source.collectionspace.org/collection-space/LICENSE.txt
17
18  *  Unless required by applicable law or agreed to in writing, software
19  *  distributed under the License is distributed on an "AS IS" BASIS,
20  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  *  See the License for the specific language governing permissions and
22  *  limitations under the License.
23  */
24 package org.collectionspace.services.common.security;
25
26 import org.collectionspace.services.common.ServiceException;
27
28 /**
29  * UnauthorizedException is thrown when authentication to the service fails. Usually
30  * this is thrown when 2nd step of authentication to the service fails. This step
31  * includes associating the user with tenant(s) and role(s).
32  * @author 
33  */
34 public class UnauthorizedException extends ServiceException {
35
36     final public static int HTTP_CODE = 401;
37
38     /**
39      * Creates a new instance of <code>UnauthorizedException</code> without detail message.
40      */
41     public UnauthorizedException() {
42         super(HTTP_CODE);
43     }
44
45     /**
46      * Constructs an instance of <code>UnauthorizedException</code> with the specified detail message.
47      * @param msg the detail message.
48      */
49     public UnauthorizedException(String msg) {
50         super(msg);
51         setErrorCode(HTTP_CODE);
52     }
53
54     /**
55      * Constructs a new exception with the specified detail message and
56      * cause.  <p>Note that the detail message associated with
57      * <code>cause</code> is <i>not</i> automatically incorporated in
58      * this exception's detail message.
59      *
60      * @param  message the detail message (which is saved for later retrieval
61      *         by the {@link #getMessage()} method).
62      * @param  cause the cause (which is saved for later retrieval by the
63      *         {@link #getCause()} method).  (A <tt>null</tt> value is
64      *         permitted, and indicates that the cause is nonexistent or
65      *         unknown.)
66      * @since  1.4
67      */
68     public UnauthorizedException(String message, Throwable cause) {
69         super(message, cause);
70         setErrorCode(HTTP_CODE);
71     }
72
73     /**
74      * Constructs a new exception with the specified cause and a detail
75      * message of <tt>(cause==null ? null : cause.toString())</tt> (which
76      * typically contains the class and detail message of <tt>cause</tt>).
77      * This constructor is useful for exceptions that are little more than
78      * wrappers for other throwables (for example, {@link
79      * java.security.PrivilegedActionException}).
80      *
81      * @param  cause the cause (which is saved for later retrieval by the
82      *         {@link #getCause()} method).  (A <tt>null</tt> value is
83      *         permitted, and indicates that the cause is nonexistent or
84      *         unknown.)
85      * @since  1.4
86      */
87     public UnauthorizedException(Throwable cause) {
88         super(cause);
89         setErrorCode(HTTP_CODE);
90     }
91 }