KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > cvsclient > connection > AuthenticationException


1 /*****************************************************************************
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14
15  * The Original Software is the CVS Client Library.
16  * The Initial Developer of the Original Software is Robert Greig.
17  * Portions created by Robert Greig are Copyright (C) 2000.
18  * All Rights Reserved.
19
20  * Contributor(s): Robert Greig.
21  *****************************************************************************/

22 package org.netbeans.lib.cvsclient.connection;
23
24 import java.util.*;
25
26 import org.netbeans.lib.cvsclient.util.*;
27
28 /**
29  * This exception is thrown when a connection with the server cannot be made,
30  * for whatever reason.
31  * It may be that the username and/or password are incorrect or it could be
32  * that the port number is incorrect. Note that authentication is not
33  * restricted here to mean security.
34  * @author Robert Greig
35  */

36 public class AuthenticationException extends Exception JavaDoc {
37     /**
38      * The underlying cause of this exception, if any.
39      */

40     private Throwable JavaDoc underlyingThrowable;
41
42     private String JavaDoc message;
43
44     private String JavaDoc localizedMessage;
45
46     /**
47      * Construct an AuthenticationException with a message giving more details
48      * of what went wrong.
49      * @param message the message describing the error
50      **/

51     public AuthenticationException(String JavaDoc message, String JavaDoc localizedMessage) {
52         super(message);
53         this.message = message;
54         this.localizedMessage = localizedMessage;
55     }
56
57     /**
58      * Construct an AuthenticationException with a message and an
59      * underlying exception.
60      * @param message the message describing what went wrong
61      * @param e the underlying exception
62      */

63     public AuthenticationException(String JavaDoc message,
64                                    Throwable JavaDoc underlyingThrowable,
65                                    String JavaDoc localizedMessage) {
66         this(message, localizedMessage);
67         initCause(underlyingThrowable);
68     }
69
70     /**
71      * Construct an AuthenticationException with an underlying
72      * exception.
73      * @param t the underlying throwable that caused this exception
74      */

75     public AuthenticationException(Throwable JavaDoc underlyingThrowable,
76                                    String JavaDoc localizedMessage) {
77         this.localizedMessage = localizedMessage;
78         initCause(underlyingThrowable);
79     }
80
81     /**
82      * Get the underlying throwable that is responsible for this exception.
83      * @return the underlying throwable, if any (may be null).
84      */

85     public Throwable JavaDoc getUnderlyingThrowable() {
86         return getCause();
87     }
88
89     public String JavaDoc getLocalizedMessage() {
90         if (localizedMessage == null) {
91             return message;
92         }
93         return localizedMessage;
94     }
95
96     public String JavaDoc getMessage() {
97         return message;
98     }
99
100     protected static String JavaDoc getBundleString(String JavaDoc key) {
101         String JavaDoc value = null;
102         try {
103             ResourceBundle bundle = BundleUtilities.getResourceBundle(AuthenticationException.class, "Bundle"); //NOI18N
104
if (bundle != null) {
105                 value = bundle.getString(key);
106             }
107         }
108         catch (MissingResourceException exc) {
109         }
110         return value;
111     }
112 }
113
Popular Tags