1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.kerberos.shared.messages.components;
21
22
23 import java.util.Arrays;
24 import java.util.Collections;
25 import java.util.List;
26
27
28
29
30
31
32
33
34 public class MessageComponentType implements Comparable<MessageComponentType>
35 {
36
37
38
39 public static final MessageComponentType NULL = new MessageComponentType( 0, "null" );
40
41
42
43
44 public static final MessageComponentType KRB_TKT = new MessageComponentType( 1, "ticket" );
45
46
47
48
49 public static final MessageComponentType KRB_AUTHENTICATOR = new MessageComponentType( 2, "authenticator" );
50
51
52
53
54 public static final MessageComponentType KRB_ENC_TKT_PART = new MessageComponentType( 3, "encrypted ticket part" );
55
56
57
58
59 public static final MessageComponentType KRB_ENC_AS_REP_PART = new MessageComponentType( 25,
60 "encrypted initial authentication part" );
61
62
63
64
65 public static final MessageComponentType KRB_ENC_TGS_REP_PART = new MessageComponentType( 26,
66 "encrypted TGS request part" );
67
68
69
70
71 public static final MessageComponentType KRB_ENC_AP_REP_PART = new MessageComponentType( 27,
72 "encrypted application request part" );
73
74
75
76
77 public static final MessageComponentType KRB_ENC_KRB_PRIV_PART = new MessageComponentType( 28,
78 "encrypted application message part" );
79
80
81
82
83 public static final MessageComponentType KRB_ENC_KRB_CRED_PART = new MessageComponentType( 29,
84 "encrypted credentials forward part" );
85
86
87
88
89 private static final MessageComponentType[] values =
90 { NULL, KRB_TKT, KRB_AUTHENTICATOR, KRB_ENC_TKT_PART, KRB_ENC_AS_REP_PART, KRB_ENC_TGS_REP_PART,
91 KRB_ENC_AP_REP_PART, KRB_ENC_KRB_PRIV_PART, KRB_ENC_KRB_CRED_PART };
92
93
94
95
96 public static final List<MessageComponentType> VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
97
98
99
100
101 private final String name;
102
103
104
105
106 private final int ordinal;
107
108
109
110
111
112 private MessageComponentType( int ordinal, String name )
113 {
114 this.ordinal = ordinal;
115 this.name = name;
116 }
117
118
119
120
121
122
123
124
125 public static MessageComponentType getTypeByOrdinal( int type )
126 {
127 for ( int ii = 0; ii < values.length; ii++ )
128 {
129 if ( values[ii].ordinal == type )
130 {
131 return values[ii];
132 }
133 }
134
135 return NULL;
136 }
137
138
139
140
141
142
143
144 public int getOrdinal()
145 {
146 return ordinal;
147 }
148
149
150 public int compareTo( MessageComponentType that )
151 {
152 return ordinal - that.ordinal;
153 }
154
155
156 public String toString()
157 {
158 return name + " (" + ordinal + ")";
159 }
160 }