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.shared.kerberos;
21  
22  
23  /**
24   * An enum listing all the Kerberos V5 messages :
25   * 
26   *   AS-REQ    (10) : Authentication Serveur Request
27   *   AS-REP    (11) : Authentication Serveur Response
28   *   TGS-REQ   (12) : Ticket Granting Server Request
29   *   TGS-REP   (13) : Ticket Granting Server Response
30   *   AP-REQ    (14) : Application Request
31   *   AP-REP    (15) : Application Response
32   *   KRB-SAFE  (20) : Safe (checksummed) application message
33   *   KRB-PRIV  (21) : Private (encrypted) application message
34   *   KRB-CRED  (22) : Private (encrypted) message to forward credentials
35   *   ENC_AP_REP_PART (27) : Encrypted application reply part
36   *   ENC_PRIV_PART (28) : Encrypted private message part
37   *   KRB-ERROR (30) : A kerberos error response
38   *   
39   *
40   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
41   */
42  public enum KerberosMessageType
43  {
44      TICKET(1, "ticket"),
45      AUTHENTICATOR(2, "Authenticator"),
46      ENC_TICKET_PART(3, "EncTicketPart"),
47      AS_REQ(10, "initial authentication request"),
48      AS_REP(11, "initial authentication response"),
49      TGS_REQ(12, "request for authentication based on TGT"),
50      TGS_REP(13, "response to authentication based on TGT"),
51      AP_REQ(14, "application request"),
52      AP_REP(15, "application response"),
53      KRB_SAFE(20, "safe (checksummed) application message"),
54      KRB_PRIV(21, "private (encrypted) application message"),
55      KRB_CRED(22, "private (encrypted) message to forward credentials"),
56      ENC_AS_REP_PART(25, "encrypted authentication reply part"),
57      ENC_TGS_REP_PART(26, "encrypted TGT reply part"),
58      ENC_AP_REP_PART(27, "encrypted application reply part"),
59      ENC_PRIV_PART(28, "encrypted private message part"),
60      KRB_ERROR(30, "error response");
61  
62      private int value;
63      private String message;
64  
65  
66      /**
67       * Creates a new instance of KerberosMessageType.
68       */
69      private KerberosMessageType( int value, String message )
70      {
71          this.value = value;
72          this.message = message;
73      }
74  
75  
76      /**
77       * Get the int value for this element
78       *
79       * @return The int value of this element
80       */
81      public int getValue()
82      {
83          return value;
84      }
85  
86  
87      /**
88       * Get the message associated with this element
89       *
90       * @return The message associated with this element
91       */
92      public String getMessage()
93      {
94          return message;
95      }
96  
97  
98      /**
99       * Get the instance of a KerberosMessageType from an int value
100      *
101      * @param value The int value 
102      * @return A KerberosMessageType associated with this value
103      */
104     public static KerberosMessageType getTypeByValue( int value )
105     {
106         switch ( value )
107         {
108             case 1:
109                 return TICKET;
110             case 2:
111                 return AUTHENTICATOR;
112             case 3:
113                 return ENC_TICKET_PART;
114             case 10:
115                 return AS_REQ;
116             case 11:
117                 return AS_REP;
118             case 12:
119                 return TGS_REQ;
120             case 13:
121                 return TGS_REP;
122             case 14:
123                 return AP_REQ;
124             case 15:
125                 return AP_REP;
126             case 20:
127                 return KRB_SAFE;
128             case 21:
129                 return KRB_PRIV;
130             case 22:
131                 return KRB_CRED;
132             case 27:
133                 return ENC_AP_REP_PART;
134             case 28:
135                 return ENC_PRIV_PART;
136             case 30:
137                 return KRB_ERROR;
138             default:
139                 return null;
140         }
141     }
142 }