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:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright 2009 University of California at Berkeley
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
16 * https://source.collectionspace.org/collection-space/LICENSE.txt
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.
24 package org.collectionspace.services.common.security;
26 import org.collectionspace.services.common.ServiceException;
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).
34 public class UnauthorizedException extends ServiceException {
36 final public static int HTTP_CODE = 401;
39 * Creates a new instance of <code>UnauthorizedException</code> without detail message.
41 public UnauthorizedException() {
46 * Constructs an instance of <code>UnauthorizedException</code> with the specified detail message.
47 * @param msg the detail message.
49 public UnauthorizedException(String msg) {
51 setErrorCode(HTTP_CODE);
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.
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
68 public UnauthorizedException(String message, Throwable cause) {
69 super(message, cause);
70 setErrorCode(HTTP_CODE);
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}).
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
87 public UnauthorizedException(Throwable cause) {
89 setErrorCode(HTTP_CODE);