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 AuthorizationType
28  {
29      /**
30       * Constant for the "null" authorization type.
31       */
32      NULL( 0 ),
33  
34      /**
35       * Constant for the "if relevant" authorization type.
36       * 
37       * RFC 4120
38       */
39      AD_IF_RELEVANT( 1 ),
40  
41      /**
42       * Constant for the "intended for server" authorization type.
43       * 
44       * RFC 4120
45       */
46      AD_INTENDED_FOR_SERVER( 2 ),
47  
48      /**
49       * Constant for the  "intended for application class" authorization type.
50       * 
51       * RFC 4120
52       */
53      AD_INTENDED_FOR_APPLICATION_CLASS( 3 ),
54  
55      /**
56       * Constant for the "kdc issued" authorization type.
57       * 
58       * RFC 4120
59       */
60      AD_KDC_ISSUED( 4 ),
61  
62      /**
63       * Constant for the "or" authorization type.
64       * 
65       * RFC 4120
66       */
67      AD_OR( 5 ),
68  
69      /**
70       * Constant for the "mandatory ticket extensions" authorization type.
71       * 
72       * RFC 4120
73       */
74      AD_MANDATORY_TICKET_EXTENSIONS( 6 ),
75  
76      /**
77       * Constant for the "in ticket extensions" authorization type.
78       * 
79       * RFC 4120
80       */
81      AD_IN_TICKET_EXTENSIONS( 7 ),
82  
83      /**
84       * Constant for the "mandatory-for-kdc" authorization type.
85       * 
86       * RFC 4120
87       */
88      AD_MANDATORY_FOR_KDC( 8 ),
89  
90      /**
91       * Constant for the "OSF DCE" authorization type.
92       * 
93       * RFC 1510
94       */
95      OSF_DCE( 64 ),
96  
97      /**
98       * Constant for the "sesame" authorization type.
99       * 
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 }