KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > security > util > IASSecurityException


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.security.util;
25
26 import java.lang.*;
27
28 /**
29  * General exception class for iAS security failures.
30  *
31  * <P>This class takes advantage of the JDK1.4 Throwable objects which
32  * can carry the original cause of the exception. This prevents losing
33  * the information on what caused the problem to arise.
34  *
35  * <P>Ideally there should be common top level iAS Exceptions to extend.
36  *
37  */

38
39 public class IASSecurityException extends Exception JavaDoc
40 {
41   private boolean noMsg;
42   
43   /**
44    * Constructor.
45    *
46    * @param msg The detail message.
47    *
48    */

49   public IASSecurityException(String JavaDoc msg)
50   {
51     super(msg);
52     noMsg=false;
53   }
54
55
56   /**
57    * Constructor.
58    *
59    * @param msg The detail message.
60    * @param cause The cause (which is saved for later retrieval by the
61    * getCause() method).
62    *
63    */

64   public IASSecurityException(String JavaDoc msg, Throwable JavaDoc cause)
65   {
66     super(msg, cause);
67     noMsg=false;
68   }
69
70
71   /**
72    * Constructor.
73    *
74    * @param cause The cause (which is saved for later retrieval by the
75    * getCause() method).
76    *
77    */

78   public IASSecurityException(Throwable JavaDoc cause)
79   {
80     super(cause);
81     noMsg=true;
82   }
83
84
85   /**
86    * Returns a description of this exception. If a root cause was included
87    * during construction, its message is also included.
88    *
89    * @return Message containing information about the exception.
90    *
91    */

92   public String JavaDoc getMessage()
93   {
94     StringBuffer JavaDoc sb=new StringBuffer JavaDoc();
95     sb.append(super.getMessage());
96     Throwable JavaDoc cause=getCause();
97
98     if (!noMsg && cause!=null) {
99       sb.append(" [Cause: ");
100       sb.append(cause.toString());
101       sb.append("] ");
102     }
103
104     return sb.toString();
105   }
106
107
108
109
110 }
111
Popular Tags