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 list of possible value for the TransitedEncoding type
25   * 
26   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
27   */
28  public enum TransitedEncodingType
29  {
30      /** Constant for the "null" transited encoding type. */
31      NULL(0),
32  
33      /** Constant for the "Domain X500 compress" transited encoding type. */
34      DOMAIN_X500_COMPRESS(1);
35  
36      /**
37       * The value/code for the transited encoding type.
38       */
39      private final int value;
40  
41  
42      /**
43       * Private constructor prevents construction outside of this class.
44       */
45      private TransitedEncodingType( int value )
46      {
47          this.value = value;
48      }
49  
50  
51      /**
52       * Returns the transited encoding type when specified by its value.
53       *
54       * @param type The type we are looking for
55       * @return The transited encoding type.
56       */
57      public static TransitedEncodingType getTypeByOrdinal( int type )
58      {
59          if ( type == 1 )
60          {
61              return DOMAIN_X500_COMPRESS;
62          }
63          else
64          {
65              return NULL;
66          }
67      }
68  
69  
70      /**
71       * Returns the number associated with this transited encoding type.
72       *
73       * @return The transited encoding type value.
74       */
75      public int getValue()
76      {
77          return value;
78      }
79  
80  
81      /**
82       * @see Object#toString()
83       */
84      @Override
85      public String toString()
86      {
87          if ( this == DOMAIN_X500_COMPRESS )
88          {
89              return "Domain X500 compress (1)";
90          }
91          else
92          {
93                  return "null (0)";
94          }
95      }
96  }