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.crypto.encryption;
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
35
36
37
38
39
40
41
42 public final class KeyUsage implements Comparable<KeyUsage>
43 {
44
45
46
47 public static final KeyUsage NUMBER1 = new KeyUsage( 1,
48 "AS-REQ PA-ENC-TIMESTAMP padata timestamp, encrypted with the client key" );
49
50
51
52
53 public static final KeyUsage NUMBER2 = new KeyUsage(
54 2,
55 "AS-REP Ticket and TGS-REP Ticket (includes TGS session key or application session key), encrypted with the service key" );
56
57
58
59
60 public static final KeyUsage NUMBER3 = new KeyUsage( 3,
61 "AS-REP encrypted part (includes TGS session key or application session key), encrypted with the client key" );
62
63
64
65
66 public static final KeyUsage NUMBER4 = new KeyUsage( 4,
67 "TGS-REQ KDC-REQ-BODY AuthorizationData, encrypted with the TGS session key" );
68
69
70
71
72 public static final KeyUsage NUMBER5 = new KeyUsage( 5,
73 "TGS-REQ KDC-REQ-BODY AuthorizationData, encrypted with the TGS authenticator subkey" );
74
75
76
77
78 public static final KeyUsage NUMBER6 = new KeyUsage( 6,
79 "TGS-REQ PA-TGS-REQ padata AP-REQ Authenticator cksum, keyed with the TGS session key" );
80
81
82
83
84 public static final KeyUsage NUMBER7 = new KeyUsage(
85 7,
86 "TGS-REQ PA-TGS-REQ padata AP-REQ Authenticator (includes TGS authenticator subkey), encrypted with the TGS session key" );
87
88
89
90
91 public static final KeyUsage NUMBER8 = new KeyUsage( 8,
92 "TGS-REP encrypted part (includes application session key), encrypted with the TGS session key" );
93
94
95
96
97 public static final KeyUsage NUMBER9 = new KeyUsage( 9,
98 "TGS-REP encrypted part (includes application session key), encrypted with the TGS authenticator subkey" );
99
100
101
102
103 public static final KeyUsage NUMBER10 = new KeyUsage( 10,
104 "AP-REQ Authenticator cksum, keyed with the application session key" );
105
106
107
108
109 public static final KeyUsage NUMBER11 = new KeyUsage( 11,
110 "AP-REQ Authenticator (includes application authenticator subkey), encrypted with the application session key" );
111
112
113
114
115 public static final KeyUsage NUMBER12 = new KeyUsage( 12,
116 "AP-REP encrypted part (includes application session subkey), encrypted with the application session key" );
117
118
119
120
121 public static final KeyUsage NUMBER13 = new KeyUsage( 13,
122 "KRB-PRIV encrypted part, encrypted with a key chosen by the application" );
123
124
125
126
127 private static final KeyUsage[] values =
128 { NUMBER1, NUMBER2, NUMBER3, NUMBER4, NUMBER5, NUMBER6, NUMBER7, NUMBER8, NUMBER9, NUMBER10, NUMBER11,
129 NUMBER12, NUMBER13 };
130
131
132
133
134 public static final List<KeyUsage> VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
135
136 private final int ordinal;
137 private final String name;
138
139
140
141
142
143 private KeyUsage( int ordinal, String name )
144 {
145 this.ordinal = ordinal;
146 this.name = name;
147 }
148
149
150
151
152
153
154
155
156 public static KeyUsage getTypeByOrdinal( int type )
157 {
158 for ( int ii = 0; ii < values.length; ii++ )
159 {
160 if ( values[ii].ordinal == type )
161 {
162 return values[ii];
163 }
164 }
165
166 return NUMBER1;
167 }
168
169
170
171
172
173
174
175 public int getOrdinal()
176 {
177 return ordinal;
178 }
179
180
181 public int compareTo( KeyUsage that )
182 {
183 return ordinal - that.ordinal;
184 }
185
186
187 public String toString()
188 {
189 return name + " (" + ordinal + ")";
190 }
191 }