1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19 */
20 package org.apache.directory.server.kerberos.sam;
21
22
23 import org.apache.directory.server.kerberos.shared.messages.value.SamType;
24
25
26 /**
27 * Base class for all SAM subsystem errors.
28 *
29 * @warning this should extend from KerberosException in o.a.k.exception.
30 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
31 * @version $Rev: 437036 $
32 */
33 public class SamException extends Exception
34 {
35 private static final long serialVersionUID = -677444708375928227L;
36
37 /** the SAM type that caused this exception */
38 private final SamType type;
39
40
41 /**
42 * Creates a SamException for a specific SamType.
43 *
44 * @param type the type value for the SAM algorithm associated with this exception
45 */
46 public SamException(SamType type)
47 {
48 super();
49
50 this.type = type;
51 }
52
53
54 /**
55 * Creates a SamException for a specific SamType, with message.
56 *
57 * @param type the type value for the SAM algorithm associated with this exception
58 * @param message a message regarding the nature of the fault
59 */
60 public SamException(SamType type, String message)
61 {
62 super( message );
63
64 this.type = type;
65 }
66
67
68 /**
69 * Creates a SamException for a specific SamType, with the cause resulted in
70 * this exception.
71 *
72 * @param type the type value for the SAM algorithm associated with this exception
73 * @param cause the throwable that resulted in this exception being thrown
74 */
75 public SamException(SamType type, Throwable cause)
76 {
77 super( cause );
78
79 this.type = type;
80 }
81
82
83 /**
84 * Creates a SamException for a specific SamType, with a message and the
85 * cause that resulted in this exception.
86 *
87 *
88 * @param type the type value for the SAM algorithm associated with this exception
89 * @param message a message regarding the nature of the fault
90 * @param cause the throwable that resulted in this exception being thrown
91 */
92 public SamException(SamType type, String message, Throwable cause)
93 {
94 super( message, cause );
95
96 this.type = type;
97 }
98
99
100 /**
101 * Gets the registered SAM algorithm type associated with this SamException.
102 *
103 * @return the type value for the SAM algorithm associated with this exception
104 */
105 public SamType getSamType()
106 {
107 return this.type;
108 }
109 }