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 */
020package org.apache.directory.shared.kerberos.codec.options;
021
022
023/**
024 * The list of possible KDC options.
025 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
026 */
027public class KdcOptions extends Options
028{
029    /**
030     * KDC option - reserved for future use.
031     */
032    public static final int RESERVED_0 = 0;
033
034    /**
035     * KDC option - forwardable.
036     */
037    public static final int FORWARDABLE = 1;
038
039    /**
040     * KDC option - forwarded.
041     */
042    public static final int FORWARDED = 2;
043
044    /**
045     * KDC option - proxiable.
046     */
047    public static final int PROXIABLE = 3;
048
049    /**
050     * KDC option - proxy.
051     */
052    public static final int PROXY = 4;
053
054    /**
055     * KDC option - allow postdate.
056     */
057    public static final int ALLOW_POSTDATE = 5;
058
059    /**
060     * KDC option - postdated.
061     */
062    public static final int POSTDATED = 6;
063
064    /**
065     * KDC option - reserved for future use.
066     */
067    public static final int RESERVED_7 = 7;
068
069    /**
070     * KDC option - renewable.
071     */
072    public static final int RENEWABLE = 8;
073
074    /**
075     * KDC option - reserved for future use.
076     */
077    public static final int RESERVED_9 = 9;
078
079    /**
080     * KDC option - reserved for future use.
081     */
082    public static final int RESERVED_10 = 10;
083
084    /**
085     * KDC option - reserved for future use.
086     */
087    public static final int RESERVED_11 = 11;
088
089    /**
090     * KDC option - reserved for future use.
091     */
092    public static final int RESERVED_12 = 12;
093
094    /**
095     * KDC option - reserved for future use.
096     */
097    public static final int RESERVED_13 = 13;
098
099    /**
100     * KDC option - reserved for future use.
101     */
102    public static final int RESERVED_14 = 14;
103
104    /**
105     * KDC option - reserved for future use.
106     */
107    public static final int RESERVED_15 = 15;
108
109    /**
110     * KDC option - reserved for future use.
111     */
112    public static final int RESERVED_16 = 16;
113
114    /**
115     * KDC option - reserved for future use.
116     */
117    public static final int RESERVED_17 = 17;
118
119    /**
120     * KDC option - reserved for future use.
121     */
122    public static final int RESERVED_18 = 18;
123
124    /**
125     * KDC option - reserved for future use.
126     */
127    public static final int RESERVED_19 = 19;
128
129    /**
130     * KDC option - reserved for future use.
131     */
132    public static final int RESERVED_20 = 20;
133
134    /**
135     * KDC option - reserved for future use.
136     */
137    public static final int RESERVED_21 = 21;
138
139    /**
140     * KDC option - reserved for future use.
141     */
142    public static final int RESERVED_22 = 22;
143
144    /**
145     * KDC option - reserved for future use.
146     */
147    public static final int RESERVED_23 = 23;
148
149    /**
150     * KDC option - reserved for future use.
151     */
152    public static final int RESERVED_24 = 24;
153
154    /**
155     * KDC option - reserved for future use.
156     */
157    public static final int RESERVED_25 = 25;
158
159    /**
160     * KDC option - disable transisted checked.
161     */
162    public static final int DISABLE_TRANSISTED_CHECKED = 26;
163
164    /**
165     * KDC option - renewable is ok.
166     */
167    public static final int RENEWABLE_OK = 27;
168
169    /**
170     * KDC option - encrypted key in skey.
171     */
172    public static final int ENC_TKT_IN_SKEY = 28;
173
174    /**
175     * KDC option - reserved for future use.
176     */
177    public static final int RESERVED_29 = 29;
178
179    /**
180     * KDC option - renew.
181     */
182    public static final int RENEW = 30;
183
184    /**
185     * KDC option - validate.
186     */
187    public static final int VALIDATE = 31;
188
189    /**
190     * KDC option - maximum value.
191     */
192    public static final int MAX_VALUE = 32;
193
194
195    /**
196     * Creates a new instance of KdcOptions.
197     */
198    public KdcOptions()
199    {
200        super( MAX_VALUE );
201    }
202
203
204    /**
205     * Creates a new instance of KdcOptions.
206     *
207     * @param bytes The list of all the bits as a byte[]
208     */
209    public KdcOptions( byte[] bytes )
210    {
211        super( MAX_VALUE );
212        setBytes( bytes );
213    }
214
215
216    /**
217     * Converts the object to a printable string.
218     */
219    @Override
220    public String toString()
221    {
222        StringBuilder result = new StringBuilder();
223
224        // 0
225        if ( get( RESERVED_0 ) )
226        {
227            result.append( "RESERVED_0 " );
228        }
229
230        // 1
231        if ( get( FORWARDABLE ) )
232        {
233            result.append( "FORWARDABLE " );
234        }
235
236        // 2
237        if ( get( FORWARDED ) )
238        {
239            result.append( "FORWARDED " );
240        }
241
242        // 3
243        if ( get( PROXIABLE ) )
244        {
245            result.append( "PROXIABLE " );
246        }
247
248        // 4
249        if ( get( PROXY ) )
250        {
251            result.append( "PROXY " );
252        }
253
254        // 5
255        if ( get( ALLOW_POSTDATE ) )
256        {
257            result.append( "ALLOW_POSTDATE " );
258        }
259
260        // 6
261        if ( get( POSTDATED ) )
262        {
263            result.append( "POSTDATED " );
264        }
265
266        // 7
267        if ( get( RESERVED_7 ) )
268        {
269            result.append( "RESERVED_7 " );
270        }
271
272        // 8
273        if ( get( RENEWABLE ) )
274        {
275            result.append( "RENEWABLE " );
276        }
277
278        // 9
279        if ( get( RESERVED_9 ) )
280        {
281            result.append( "RESERVED_9 " );
282        }
283
284        // 10
285        if ( get( RESERVED_10 ) )
286        {
287            result.append( "RESERVED_10 " );
288        }
289
290        // 11
291        if ( get( RESERVED_11 ) )
292        {
293            result.append( "RESERVED_11 " );
294        }
295
296        // 12
297        if ( get( RESERVED_12 ) )
298        {
299            result.append( "RESERVED_12 " );
300        }
301
302        // 13
303        if ( get( RESERVED_13 ) )
304        {
305            result.append( "RESERVED_13 " );
306        }
307
308        // 14
309        if ( get( RESERVED_14 ) )
310        {
311            result.append( "RESERVED_14 " );
312        }
313
314        // 15
315        if ( get( RESERVED_15 ) )
316        {
317            result.append( "RESERVED_15 " );
318        }
319
320        // 16
321        if ( get( RESERVED_16 ) )
322        {
323            result.append( "RESERVED_16 " );
324        }
325
326        // 17
327        if ( get( RESERVED_17 ) )
328        {
329            result.append( "RESERVED_17 " );
330        }
331
332        // 18
333        if ( get( RESERVED_18 ) )
334        {
335            result.append( "RESERVED_18 " );
336        }
337
338        // 19
339        if ( get( RESERVED_19 ) )
340        {
341            result.append( "RESERVED_19 " );
342        }
343
344        // 20
345        if ( get( RESERVED_20 ) )
346        {
347            result.append( "RESERVED_20 " );
348        }
349
350        // 21
351        if ( get( RESERVED_21 ) )
352        {
353            result.append( "RESERVED_21 " );
354        }
355
356        // 22
357        if ( get( RESERVED_22 ) )
358        {
359            result.append( "RESERVED_22 " );
360        }
361
362        // 23
363        if ( get( RESERVED_23 ) )
364        {
365            result.append( "RESERVED_23 " );
366        }
367
368        // 24
369        if ( get( RESERVED_24 ) )
370        {
371            result.append( "RESERVED_24 " );
372        }
373
374        // 25
375        if ( get( RESERVED_25 ) )
376        {
377            result.append( "RESERVED_25 " );
378        }
379
380        // 26
381        if ( get( DISABLE_TRANSISTED_CHECKED ) )
382        {
383            result.append( "DISABLE_TRANSISTED_CHECKED " );
384        }
385
386        // 27
387        if ( get( RENEWABLE_OK ) )
388        {
389            result.append( "RENEWABLE_OK " );
390        }
391
392        // 28
393        if ( get( ENC_TKT_IN_SKEY ) )
394        {
395            result.append( "ENC_TKT_IN_SKEY " );
396        }
397
398        // 29
399        if ( get( RESERVED_29 ) )
400        {
401            result.append( "RESERVED_29 " );
402        }
403
404        // 30
405        if ( get( RENEW ) )
406        {
407            result.append( "RENEW " );
408        }
409
410        // 31
411        if ( get( VALIDATE ) )
412        {
413            result.append( "VALIDATE " );
414        }
415
416        return result.toString().trim();
417    }
418}