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.codec.types;
21  
22  
23  /**
24   * The Authorization types
25   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
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      * The value/code for the authorization type.
127      */
128     private final int value;
129 
130 
131     /**
132      * Private constructor prevents construction outside of this class.
133      */
134     private AuthorizationType( int value )
135     {
136         this.value = value;
137     }
138 
139 
140     /**
141      * Returns the authorization type when specified by its ordinal.
142      *
143      * @param type The numeric value
144      * @return The authorization type.
145      */
146     public static AuthorizationType getTypeByValue( int type )
147     {
148         switch ( type )
149         {
150             case 1:
151                 return AD_IF_RELEVANT;
152             case 2:
153                 return AD_INTENDED_FOR_SERVER;
154             case 3:
155                 return AD_INTENDED_FOR_APPLICATION_CLASS;
156             case 4:
157                 return AD_KDC_ISSUED;
158             case 5:
159                 return AD_OR;
160             case 6:
161                 return AD_MANDATORY_TICKET_EXTENSIONS;
162             case 7:
163                 return AD_IN_TICKET_EXTENSIONS;
164             case 8:
165                 return AD_MANDATORY_FOR_KDC;
166             case 64:
167                 return OSF_DCE;
168             case 65:
169                 return SESAME;
170             case 66:
171                 return AD_OSF_DCE_PKI_CERTID;
172             case 128:
173                 return AD_WIN2K_PAC;
174             case 129:
175                 return AD_ETYPE_NEGOTIATION;
176             default:
177                 return NULL;
178         }
179     }
180 
181 
182     /**
183      * Returns the number associated with this authorization type.
184      *
185      * @return The authorization type ordinal.
186      */
187     public int getValue()
188     {
189         return value;
190     }
191 
192 
193     /**
194      * @see Object#toString()
195      */
196     @Override
197     public String toString()
198     {
199         switch ( this )
200         {
201             case AD_IF_RELEVANT:
202                 return "if relevant" + "(" + value + ")";
203 
204             case AD_INTENDED_FOR_SERVER:
205                 return "intended for server" + "(" + value + ")";
206 
207             case AD_INTENDED_FOR_APPLICATION_CLASS:
208                 return "intended for application class" + "(" + value + ")";
209 
210             case AD_KDC_ISSUED:
211                 return "kdc issued" + "(" + value + ")";
212 
213             case AD_OR:
214                 return "or" + "(" + value + ")";
215 
216             case AD_MANDATORY_TICKET_EXTENSIONS:
217                 return "mandatory ticket extensions" + "(" + value + ")";
218 
219             case AD_IN_TICKET_EXTENSIONS:
220                 return "in ticket extensions" + "(" + value + ")";
221 
222             case AD_MANDATORY_FOR_KDC:
223                 return "mandatory-for-kdc" + "(" + value + ")";
224 
225             case OSF_DCE:
226                 return "OSF DCE" + "(" + value + ")";
227 
228             case SESAME:
229                 return "sesame" + "(" + value + ")";
230 
231             case AD_OSF_DCE_PKI_CERTID:
232                 return "OSF DCE pki certid" + "(" + value + ")";
233 
234             case AD_WIN2K_PAC:
235                 return "win 2000 PAC" + "(" + value + ")";
236 
237             case AD_ETYPE_NEGOTIATION:
238                 return "etype negociation" + "(" + value + ")";
239 
240             default:
241                 return "null" + "(" + value + ")";
242         }
243     }
244 }