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.messages.value.types;
21  
22  
23  /**
24   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
25   * @version $Rev: 540371 $, $Date: 2007-05-22 02:00:43 +0200 (Tue, 22 May 2007) $
26   */
27  public enum PaDataType
28  {
29      /**
30       * Constant for the "null" pre-authentication data type.
31       */
32      NULL( 0 ),
33  
34      /**
35       * Constant for the "TGS request" pre-authentication data type.
36       */
37      PA_TGS_REQ( 1 ),
38  
39      /**
40       * Constant for the "encrypted timestamp" pre-authentication data type.
41       */
42      PA_ENC_TIMESTAMP( 2 ),
43  
44      /**
45       * Constant for the "password salt" pre-authentication data type.
46       */
47      PA_PW_SALT( 3 ),
48  
49      /**
50       * Constant for the "enc unix time" pre-authentication data type.
51       */
52      PA_ENC_UNIX_TIME( 5 ),
53  
54      /**
55       * Constant for the "sandia secureid" pre-authentication data type.
56       */
57      PA_SANDIA_SECUREID( 6 ),
58  
59      /**
60       * Constant for the "sesame" pre-authentication data type.
61       */
62      PA_SESAME( 7 ),
63  
64      /**
65       * Constant for the "OSF DCE" pre-authentication data type.
66       */
67      PA_OSF_DCE( 8 ),
68  
69      /**
70       * Constant for the "cybersafe secureid" pre-authentication data type.
71       */
72      PA_CYBERSAFE_SECUREID( 9 ),
73  
74      /**
75       * Constant for the "ASF3 salt" pre-authentication data type.
76       */
77      PA_ASF3_SALT( 10 ),
78  
79      /**
80       * Constant for the "encryption info" pre-authentication data type.
81       */
82      PA_ENCTYPE_INFO( 11 ),
83  
84      /**
85       * Constant for the "SAM challenge" pre-authentication data type.
86       */
87      SAM_CHALLENGE( 12 ),
88  
89      /**
90       * Constant for the "SAM response" pre-authentication data type.
91       */
92      SAM_RESPONSE( 13 ),
93  
94      /**
95       * Constant for the "PK as request" pre-authentication data type.
96       */
97      PA_PK_AS_REQ( 14 ),
98  
99      /**
100      * Constant for the "PK as response" pre-authentication data type.
101      */
102     PA_PK_AS_REP( 15 ),
103 
104     /**
105      * Constant for the "use specified key version" pre-authentication data type.
106      */
107     PA_USE_SPECIFIED_KVNO( 20 ),
108 
109     /**
110      * Constant for the "SAM redirect" pre-authentication data type.
111      */
112     SAM_REDIRECT( 21 ),
113 
114     /**
115      * Constant for the "get from typed data" pre-authentication data type.
116      */
117     PA_GET_FROM_TYPED_DATA( 22 );
118 
119 
120     /**
121      * The value/code for the pre-authentication type.
122      */
123     private final int ordinal;
124 
125 
126     /**
127      * Private constructor prevents construction outside of this class.
128      */
129     private PaDataType( int ordinal )
130     {
131         this.ordinal = ordinal;
132     }
133 
134 
135     /**
136      * Returns the number associated with this pre-authentication type.
137      *
138      * @return The pre-authentication type ordinal.
139      */
140     public int getOrdinal()
141     {
142         return ordinal;
143     }
144     
145     /**
146      * Returns the pre authentication data type when specified by its ordinal.
147      *
148      * @param type The ordinal
149      * @return The pre authentication type.
150      */
151     public static PaDataType getTypeByOrdinal( int type )
152     {
153         switch ( type )
154         {
155             case 1 :    return PA_TGS_REQ;
156             case 2 :    return PA_ENC_TIMESTAMP;
157             case 3 :    return PA_PW_SALT;
158             case 5 :    return PA_ENC_UNIX_TIME;
159             case 6 :    return PA_SANDIA_SECUREID;
160             case 7 :    return PA_SESAME;
161             case 8 :    return PA_OSF_DCE;
162             case 9 :    return PA_CYBERSAFE_SECUREID;
163             case 10 :   return PA_ASF3_SALT;
164             case 11 :   return PA_ENCTYPE_INFO;
165             case 12 :   return SAM_CHALLENGE;
166             case 13 :   return SAM_RESPONSE;
167             case 14 :   return PA_PK_AS_REQ;
168             case 15 :   return PA_PK_AS_REQ;
169             case 20 :   return PA_USE_SPECIFIED_KVNO;
170             case 21 :   return SAM_REDIRECT;
171             case 22 :   return PA_GET_FROM_TYPED_DATA;
172             default :   return NULL;
173         }
174     }
175 
176     /**
177      * @see Object#toString()
178      */
179     public String toString()
180     {
181         switch ( this )
182         {
183             case PA_TGS_REQ                     : 
184                 return "TGS request." + "(" + ordinal + ")";
185             
186             case PA_ENC_TIMESTAMP : 
187                 return "Encrypted timestamp." + "(" + ordinal + ")";
188             
189             case PA_PW_SALT : 
190                 return "password salt" + "(" + ordinal + ")";
191             
192             case PA_ENC_UNIX_TIME : 
193                 return "enc unix time" + "(" + ordinal + ")";
194             
195             case PA_SANDIA_SECUREID : 
196                 return "sandia secureid" + "(" + ordinal + ")";
197             
198             case PA_SESAME : 
199                 return "sesame" + "(" + ordinal + ")";
200             
201             case PA_OSF_DCE : 
202                 return "OSF DCE" + "(" + ordinal + ")";
203             
204             case PA_CYBERSAFE_SECUREID : 
205                 return "cybersafe secureid" + "(" + ordinal + ")";
206             
207             case PA_ASF3_SALT : 
208                 return "ASF3 salt" + "(" + ordinal + ")";
209             
210             case PA_ENCTYPE_INFO : 
211                 return "Encryption info." + "(" + ordinal + ")";
212             
213             case SAM_CHALLENGE : 
214                 return "SAM challenge." + "(" + ordinal + ")";
215             
216             case SAM_RESPONSE : 
217                 return "SAM response." + "(" + ordinal + ")";
218             
219             case PA_PK_AS_REQ : 
220                 return "PK as request" + "(" + ordinal + ")";
221             
222             case PA_PK_AS_REP : 
223                 return "PK as response" + "(" + ordinal + ")";
224                 
225             case PA_USE_SPECIFIED_KVNO :
226                 return "use specified key version" + "(" + ordinal + ")";
227             
228             case SAM_REDIRECT :
229                 return "SAM redirect." + "(" + ordinal + ")";
230             
231             case PA_GET_FROM_TYPED_DATA :
232                 return "Get from typed data" + "(" + ordinal + ")";
233             
234             default : 
235                 return "null" + "(" + ordinal + ")";
236         }
237     }
238 }