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 */ 020package org.apache.directory.server.kerberos.sam; 021 022 023import org.apache.directory.shared.kerberos.codec.types.SamType; 024 025 026/** 027 * Base class for all SAM subsystem errors. 028 * 029 * TODO this should extend from KerberosException in o.a.k.exception. 030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 031 */ 032public class SamException extends Exception 033{ 034 private static final long serialVersionUID = -677444708375928227L; 035 036 /** the SAM type that caused this exception */ 037 private final SamType type; 038 039 040 /** 041 * Creates a SamException for a specific SamType. 042 * 043 * @param type the type value for the SAM algorithm associated with this exception 044 */ 045 public SamException( SamType type ) 046 { 047 super(); 048 049 this.type = type; 050 } 051 052 053 /** 054 * Creates a SamException for a specific SamType, with message. 055 * 056 * @param type the type value for the SAM algorithm associated with this exception 057 * @param message a message regarding the nature of the fault 058 */ 059 public SamException( SamType type, String message ) 060 { 061 super( message ); 062 063 this.type = type; 064 } 065 066 067 /** 068 * Creates a SamException for a specific SamType, with the cause resulted in 069 * this exception. 070 * 071 * @param type the type value for the SAM algorithm associated with this exception 072 * @param cause the throwable that resulted in this exception being thrown 073 */ 074 public SamException( SamType type, Throwable cause ) 075 { 076 super( cause ); 077 078 this.type = type; 079 } 080 081 082 /** 083 * Creates a SamException for a specific SamType, with a message and the 084 * cause that resulted in this exception. 085 * 086 * 087 * @param type the type value for the SAM algorithm associated with this exception 088 * @param message a message regarding the nature of the fault 089 * @param cause the throwable that resulted in this exception being thrown 090 */ 091 public SamException( SamType type, String message, Throwable cause ) 092 { 093 super( message, cause ); 094 095 this.type = type; 096 } 097 098 099 /** 100 * Gets the registered SAM algorithm type associated with this SamException. 101 * 102 * @return the type value for the SAM algorithm associated with this exception 103 */ 104 public SamType getSamType() 105 { 106 return this.type; 107 } 108}