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.messages.value.types;
021    
022    
023    /**
024     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
025     * @version $Rev: 540371 $, $Date: 2007-05-22 02:00:43 +0200 (Tue, 22 May 2007) $
026     */
027    public enum PaDataType
028    {
029        /**
030         * Constant for the "null" pre-authentication data type.
031         */
032        NULL( 0 ),
033    
034        /**
035         * Constant for the "TGS request" pre-authentication data type.
036         */
037        PA_TGS_REQ( 1 ),
038    
039        /**
040         * Constant for the "encrypted timestamp" pre-authentication data type.
041         */
042        PA_ENC_TIMESTAMP( 2 ),
043    
044        /**
045         * Constant for the "password salt" pre-authentication data type.
046         */
047        PA_PW_SALT( 3 ),
048    
049        /**
050         * Constant for the "enc unix time" pre-authentication data type.
051         */
052        PA_ENC_UNIX_TIME( 5 ),
053    
054        /**
055         * Constant for the "sandia secureid" pre-authentication data type.
056         */
057        PA_SANDIA_SECUREID( 6 ),
058    
059        /**
060         * Constant for the "sesame" pre-authentication data type.
061         */
062        PA_SESAME( 7 ),
063    
064        /**
065         * Constant for the "OSF DCE" pre-authentication data type.
066         */
067        PA_OSF_DCE( 8 ),
068    
069        /**
070         * Constant for the "cybersafe secureid" pre-authentication data type.
071         */
072        PA_CYBERSAFE_SECUREID( 9 ),
073    
074        /**
075         * Constant for the "ASF3 salt" pre-authentication data type.
076         */
077        PA_ASF3_SALT( 10 ),
078    
079        /**
080         * Constant for the "encryption info" pre-authentication data type.
081         */
082        PA_ENCTYPE_INFO( 11 ),
083    
084        /**
085         * Constant for the "SAM challenge" pre-authentication data type.
086         */
087        SAM_CHALLENGE( 12 ),
088    
089        /**
090         * Constant for the "SAM response" pre-authentication data type.
091         */
092        SAM_RESPONSE( 13 ),
093    
094        /**
095         * Constant for the "PK as request" pre-authentication data type.
096         */
097        PA_PK_AS_REQ( 14 ),
098    
099        /**
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    }