001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.server.kerberos.sam;
021
022
023 import org.apache.directory.server.kerberos.shared.messages.value.SamType;
024
025
026 /**
027 * Base class for all SAM subsystem errors.
028 *
029 * @warning this should extend from KerberosException in o.a.k.exception.
030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031 * @version $Rev: 437036 $
032 */
033 public class SamException extends Exception
034 {
035 private static final long serialVersionUID = -677444708375928227L;
036
037 /** the SAM type that caused this exception */
038 private final SamType type;
039
040
041 /**
042 * Creates a SamException for a specific SamType.
043 *
044 * @param type the type value for the SAM algorithm associated with this exception
045 */
046 public SamException(SamType type)
047 {
048 super();
049
050 this.type = type;
051 }
052
053
054 /**
055 * Creates a SamException for a specific SamType, with message.
056 *
057 * @param type the type value for the SAM algorithm associated with this exception
058 * @param message a message regarding the nature of the fault
059 */
060 public SamException(SamType type, String message)
061 {
062 super( message );
063
064 this.type = type;
065 }
066
067
068 /**
069 * Creates a SamException for a specific SamType, with the cause resulted in
070 * this exception.
071 *
072 * @param type the type value for the SAM algorithm associated with this exception
073 * @param cause the throwable that resulted in this exception being thrown
074 */
075 public SamException(SamType type, Throwable cause)
076 {
077 super( cause );
078
079 this.type = type;
080 }
081
082
083 /**
084 * Creates a SamException for a specific SamType, with a message and the
085 * cause that resulted in this exception.
086 *
087 *
088 * @param type the type value for the SAM algorithm associated with this exception
089 * @param message a message regarding the nature of the fault
090 * @param cause the throwable that resulted in this exception being thrown
091 */
092 public SamException(SamType type, String message, Throwable cause)
093 {
094 super( message, cause );
095
096 this.type = type;
097 }
098
099
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 }