View Javadoc

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.shared;
21  
22  /**
23   * An enum listing all the Kerberos V5 messages :
24   * 
25   *   AS-REQ    (10) : Authentication Serveur Request
26   *   AS-REP    (11) : Authentication Serveur Response
27   *   TGS-REQ   (12) : Ticket Granting Server Request
28   *   TGS-REP   (13) : Ticket Granting Server Response
29   *   AP-REQ    (14) : Application Request
30   *   AP-REP    (15) : Application Response
31   *   KRB-SAFE  (20) : Safe (checksummed) application message
32   *   KRB-PRIV  (21) : Private (encrypted) application message
33   *   KRB-CRED  (22) : Private (encrypted) message to forward credentials
34   *   ENC_AP_REP_PART (27) : Encrypted application reply part
35   *   ENC_PRIV_PART (28) : Encrypted private message part
36   *   KRB-ERROR (30) : A kerberos error response
37   *   
38   *
39   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
40   * @version $Rev$, $Date$
41   */
42  public enum KerberosMessageType
43  {
44      AS_REQ( 10, "initial authentication request" ),
45      AS_REP( 11, "initial authentication response"),
46      TGS_REQ( 12, "request for authentication based on TGT" ),
47      TGS_REP( 13, "response to authentication based on TGT" ),
48      AP_REQ( 14, "application request" ), 
49      AP_REP( 15, "application response" ), 
50      KRB_SAFE( 20, "safe (checksummed) application message" ), 
51      KRB_PRIV( 21,  "private (encrypted) application message" ), 
52      KRB_CRED( 22, "private (encrypted) message to forward credentials" ),
53      ENC_AP_REP_PART( 27, "encrypted application reply part" ),
54      ENC_PRIV_PART( 28, "encrypted private message part" ),
55      KRB_ERROR( 30, "error response" );
56      
57      private int value;
58      private String message;
59      
60      /**
61       * Creates a new instance of KerberosMessageType.
62       */
63      private KerberosMessageType( int value, String message )
64      {
65          this.value = value;
66          this.message = message;
67      }
68  
69      
70      /**
71       * Get the int value for this element
72       *
73       * @return The int value of this element
74       */
75      public int getOrdinal()
76      {
77          return value;
78      }
79      
80      
81      /**
82       * Get the message associated with this element
83       *
84       * @return The message associated with this element
85       */
86      public String getMessage()
87      {
88          return message;
89      }
90      
91      
92      /**
93       * Get the instance of a KerberosMessageType from an int value
94       *
95       * @param value The int value 
96       * @return A KerberosMessageType associated with this value
97       */
98      public static KerberosMessageType getTypeByOrdinal( int value )
99      {
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 }