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.shared;
021
022 /**
023 * An enum listing all the Kerberos V5 messages :
024 *
025 * AS-REQ (10) : Authentication Serveur Request
026 * AS-REP (11) : Authentication Serveur Response
027 * TGS-REQ (12) : Ticket Granting Server Request
028 * TGS-REP (13) : Ticket Granting Server Response
029 * AP-REQ (14) : Application Request
030 * AP-REP (15) : Application Response
031 * KRB-SAFE (20) : Safe (checksummed) application message
032 * KRB-PRIV (21) : Private (encrypted) application message
033 * KRB-CRED (22) : Private (encrypted) message to forward credentials
034 * ENC_AP_REP_PART (27) : Encrypted application reply part
035 * ENC_PRIV_PART (28) : Encrypted private message part
036 * KRB-ERROR (30) : A kerberos error response
037 *
038 *
039 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
040 * @version $Rev$, $Date$
041 */
042 public enum KerberosMessageType
043 {
044 AS_REQ( 10, "initial authentication request" ),
045 AS_REP( 11, "initial authentication response"),
046 TGS_REQ( 12, "request for authentication based on TGT" ),
047 TGS_REP( 13, "response to authentication based on TGT" ),
048 AP_REQ( 14, "application request" ),
049 AP_REP( 15, "application response" ),
050 KRB_SAFE( 20, "safe (checksummed) application message" ),
051 KRB_PRIV( 21, "private (encrypted) application message" ),
052 KRB_CRED( 22, "private (encrypted) message to forward credentials" ),
053 ENC_AP_REP_PART( 27, "encrypted application reply part" ),
054 ENC_PRIV_PART( 28, "encrypted private message part" ),
055 KRB_ERROR( 30, "error response" );
056
057 private int value;
058 private String message;
059
060 /**
061 * Creates a new instance of KerberosMessageType.
062 */
063 private KerberosMessageType( int value, String message )
064 {
065 this.value = value;
066 this.message = message;
067 }
068
069
070 /**
071 * Get the int value for this element
072 *
073 * @return The int value of this element
074 */
075 public int getOrdinal()
076 {
077 return value;
078 }
079
080
081 /**
082 * Get the message associated with this element
083 *
084 * @return The message associated with this element
085 */
086 public String getMessage()
087 {
088 return message;
089 }
090
091
092 /**
093 * Get the instance of a KerberosMessageType from an int value
094 *
095 * @param value The int value
096 * @return A KerberosMessageType associated with this value
097 */
098 public static KerberosMessageType getTypeByOrdinal( int value )
099 {
100 switch ( value )
101 {
102 case 10 : return AS_REQ;
103 case 11 : return AS_REP;
104 case 12 : return TGS_REQ;
105 case 13 : return TGS_REP;
106 case 14 : return AP_REQ;
107 case 15 : return AP_REP;
108 case 20 : return KRB_SAFE;
109 case 21 : return KRB_PRIV;
110 case 22 : return KRB_CRED;
111 case 27 : return ENC_AP_REP_PART;
112 case 28 : return ENC_PRIV_PART;
113 case 30 : return KRB_ERROR;
114 default : return null;
115 }
116 }
117 }