%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
nl.toolforge.karma.core.vc.AuthenticationException |
|
|
1 | /* |
|
2 | Karma core - Core of the Karma application |
|
3 | Copyright (C) 2004 Toolforge <www.toolforge.nl> |
|
4 | ||
5 | This library is free software; you can redistribute it and/or |
|
6 | modify it under the terms of the GNU Lesser General Public |
|
7 | License as published by the Free Software Foundation; either |
|
8 | version 2.1 of the License, or (at your option) any later version. |
|
9 | ||
10 | This library is distributed in the hope that it will be useful, |
|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 | Lesser General Public License for more details. |
|
14 | ||
15 | You should have received a copy of the GNU Lesser General Public |
|
16 | License along with this library; if not, write to the Free Software |
|
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | */ |
|
19 | package nl.toolforge.karma.core.vc; |
|
20 | ||
21 | import nl.toolforge.karma.core.ErrorCode; |
|
22 | ||
23 | /** |
|
24 | * @author D.A. Smedes |
|
25 | * @version $Id: AuthenticationException.java,v 1.7 2004/11/02 22:26:44 asmedes Exp $ |
|
26 | */ |
|
27 | public class AuthenticationException extends Exception { |
|
28 | ||
29 | 0 | private ErrorCode errorCode = null; |
30 | 690 | private Object[] messageArguments = null; |
31 | 690 | |
32 | /** |
|
33 | * This is the prefix that is shown when displaying the error. |
|
34 | */ |
|
35 | public static final String EXCEPTION_PREFIX = "AUT-"; |
|
36 | /** |
|
37 | * When the authenticator configuration is invalid. This is due to functional errors in the content of the |
|
38 | * <code><&authenticator></code>-element. Some locations require certain data to be available (username and |
|
39 | * password for a <code>pserver</code> location for instance). |
|
40 | */ |
|
41 | 0 | public static final ErrorCode INVALID_AUTHENTICATOR_CONFIGURATION = new ErrorCode(EXCEPTION_PREFIX + "00001"); |
42 | 120 | /** |
43 | * When the location-type requires authentication configuration to be present. |
|
44 | */ |
|
45 | 0 | public static final ErrorCode MISSING_AUTHENTICATOR_CONFIGURATION = new ErrorCode(EXCEPTION_PREFIX + "00002"); |
46 | 120 | /** |
47 | * No authenticator entry is configured that matches the location alias (the <code>id</code>-attribute). |
|
48 | */ |
|
49 | 0 | public static final ErrorCode DUPLICATE_AUTHENTICATOR_KEY = new ErrorCode(EXCEPTION_PREFIX + "00003"); |
50 | 120 | /** |
51 | * When the <code>authenticators.xml</code> file could not be read properly. |
|
52 | */ |
|
53 | 0 | public static final ErrorCode AUTHENTICATOR_LOAD_ERROR = new ErrorCode(EXCEPTION_PREFIX + "00004"); |
54 | 120 | /** |
55 | * No authenticator entry is configured that matches the location alias (the <code>id</code>-attribute). |
|
56 | */ |
|
57 | 0 | public static final ErrorCode AUTHENTICATOR_NOT_FOUND = new ErrorCode(EXCEPTION_PREFIX + "00005"); |
58 | 120 | /** Could not write <code>authenticators.xml</code> */ |
59 | 0 | public static final ErrorCode AUTHENTICATOR_WRITE_ERROR = new ErrorCode(EXCEPTION_PREFIX + "00006"); |
60 | 120 | /** Username is missing while configuring a new authenticator. */ |
61 | 0 | public static final ErrorCode MISSING_USERNAME = new ErrorCode(EXCEPTION_PREFIX + "00007"); |
62 | 120 | |
63 | public AuthenticationException(ErrorCode errorCode) { |
|
64 | 0 | this(errorCode, null); |
65 | 0 | } |
66 | ||
67 | public AuthenticationException(Throwable t, ErrorCode errorCode) { |
|
68 | 0 | this(t, errorCode, null); |
69 | 0 | } |
70 | ||
71 | public AuthenticationException(ErrorCode errorCode, Object[] messageArguments) { |
|
72 | 0 | super(); |
73 | 690 | this.errorCode = errorCode; |
74 | 690 | this.messageArguments = messageArguments; |
75 | 690 | } |
76 | 690 | |
77 | public AuthenticationException(Throwable t, ErrorCode errorCode, Object[] messageArguments) { |
|
78 | 0 | super(t); |
79 | 0 | this.errorCode = errorCode; |
80 | 0 | this.messageArguments = messageArguments; |
81 | 0 | } |
82 | ||
83 | public String getMessage() { |
|
84 | 0 | if (messageArguments != null && messageArguments.length > 0) { |
85 | 0 | errorCode.setMessageArguments(messageArguments); |
86 | } |
|
87 | 0 | return errorCode.getErrorMessage(); |
88 | } |
|
89 | ||
90 | /** |
|
91 | * Gets the exceptions' {@link nl.toolforge.karma.core.ErrorCode}. |
|
92 | */ |
|
93 | public final ErrorCode getErrorCode() { |
|
94 | 0 | return errorCode; |
95 | 690 | } |
96 | ||
97 | /** |
|
98 | * Retrieves the message arguments for this exception. |
|
99 | */ |
|
100 | public final Object[] getMessageArguments() { |
|
101 | 0 | return messageArguments; |
102 | } |
|
103 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |