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 AuthorizationType
028    {
029        /**
030         * Constant for the "null" authorization type.
031         */
032        NULL( 0 ),
033    
034        /**
035         * Constant for the "if relevant" authorization type.
036         * 
037         * RFC 4120
038         */
039        AD_IF_RELEVANT( 1 ),
040    
041        /**
042         * Constant for the "intended for server" authorization type.
043         * 
044         * RFC 4120
045         */
046        AD_INTENDED_FOR_SERVER( 2 ),
047    
048        /**
049         * Constant for the  "intended for application class" authorization type.
050         * 
051         * RFC 4120
052         */
053        AD_INTENDED_FOR_APPLICATION_CLASS( 3 ),
054    
055        /**
056         * Constant for the "kdc issued" authorization type.
057         * 
058         * RFC 4120
059         */
060        AD_KDC_ISSUED( 4 ),
061    
062        /**
063         * Constant for the "or" authorization type.
064         * 
065         * RFC 4120
066         */
067        AD_OR( 5 ),
068    
069        /**
070         * Constant for the "mandatory ticket extensions" authorization type.
071         * 
072         * RFC 4120
073         */
074        AD_MANDATORY_TICKET_EXTENSIONS( 6 ),
075    
076        /**
077         * Constant for the "in ticket extensions" authorization type.
078         * 
079         * RFC 4120
080         */
081        AD_IN_TICKET_EXTENSIONS( 7 ),
082    
083        /**
084         * Constant for the "mandatory-for-kdc" authorization type.
085         * 
086         * RFC 4120
087         */
088        AD_MANDATORY_FOR_KDC( 8 ),
089    
090        /**
091         * Constant for the "OSF DCE" authorization type.
092         * 
093         * RFC 1510
094         */
095        OSF_DCE( 64 ),
096    
097        /**
098         * Constant for the "sesame" authorization type.
099         * 
100         * RFC 1510
101         */
102        SESAME( 65 ),
103    
104        /**
105         * Constant for the "OSF-DCE pki certid" authorization type.
106         * 
107         * RFC 1510
108         */
109        AD_OSF_DCE_PKI_CERTID( 66 ),
110    
111        /**
112         * Constant for the "sesame" authorization type.
113         * 
114         * RFC 1510
115         */
116        AD_WIN2K_PAC( 128 ),
117    
118        /**
119         * Constant for the "sesame" authorization type.
120         * 
121         * RFC 1510
122         */
123        AD_ETYPE_NEGOTIATION( 129 );
124    
125    
126        /**
127         * The value/code for the authorization type.
128         */
129        private final int ordinal;
130    
131    
132        /**
133         * Private constructor prevents construction outside of this class.
134         */
135        private AuthorizationType( int ordinal )
136        {
137            this.ordinal = ordinal;
138        }
139    
140    
141        /**
142         * Returns the authorization type when specified by its ordinal.
143         *
144         * @param type
145         * @return The authorization type.
146         */
147        public static AuthorizationType getTypeByOrdinal( int type )
148        {
149            switch ( type )
150            {
151                case 1 :    return AD_IF_RELEVANT;
152                case 2 :    return AD_INTENDED_FOR_SERVER;
153                case 3 :    return AD_INTENDED_FOR_APPLICATION_CLASS;
154                case 4 :    return AD_KDC_ISSUED;
155                case 5 :    return AD_OR;
156                case 6 :    return AD_MANDATORY_TICKET_EXTENSIONS;
157                case 7 :    return AD_IN_TICKET_EXTENSIONS;
158                case 8 :    return AD_MANDATORY_FOR_KDC;
159                case 64 :   return OSF_DCE;
160                case 65 :   return SESAME;
161                case 66 :   return AD_OSF_DCE_PKI_CERTID;
162                case 128 :  return AD_WIN2K_PAC;
163                case 129 :  return AD_ETYPE_NEGOTIATION;
164                default :   return NULL;
165            }
166        }
167    
168    
169        /**
170         * Returns the number associated with this authorization type.
171         *
172         * @return The authorization type ordinal.
173         */
174        public int getOrdinal()
175        {
176            return ordinal;
177        }
178        
179        /**
180         * @see Object#toString()
181         */
182        public String toString()
183        {
184            switch ( this )
185            {
186                case AD_IF_RELEVANT                     : 
187                    return "if relevant" + "(" + ordinal + ")";
188                
189                case AD_INTENDED_FOR_SERVER : 
190                    return "intended for server" + "(" + ordinal + ")";
191                
192                case AD_INTENDED_FOR_APPLICATION_CLASS : 
193                    return "intended for application class" + "(" + ordinal + ")";
194                
195                case AD_KDC_ISSUED : 
196                    return "kdc issued" + "(" + ordinal + ")";
197                
198                case AD_OR : 
199                    return "or" + "(" + ordinal + ")";
200                
201                case AD_MANDATORY_TICKET_EXTENSIONS : 
202                    return "mandatory ticket extensions" + "(" + ordinal + ")";
203                
204                case AD_IN_TICKET_EXTENSIONS : 
205                    return "in ticket extensions" + "(" + ordinal + ")";
206                
207                case AD_MANDATORY_FOR_KDC : 
208                    return "mandatory-for-kdc" + "(" + ordinal + ")";
209                
210                case OSF_DCE : 
211                    return "OSF DCE" + "(" + ordinal + ")";
212                
213                case SESAME : 
214                    return "sesame" + "(" + ordinal + ")";
215                    
216                case AD_OSF_DCE_PKI_CERTID :
217                    return "OSF DCE pki certid" + "(" + ordinal + ")";
218                
219                case AD_WIN2K_PAC :
220                    return "win 2000 PAC" + "(" + ordinal + ")";
221                
222                case AD_ETYPE_NEGOTIATION :
223                    return "etype negociation" + "(" + ordinal + ")";
224                
225                default : 
226                    return "null" + "(" + ordinal + ")";
227            }
228        }
229    }