DistinguishedNameParser.java
8.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
package com.squareup.okhttp.internal.tls;
import javax.security.auth.x500.X500Principal;
final class DistinguishedNameParser
{
private int beg;
private char[] chars;
private int cur;
private final String dn;
private int end;
private final int length;
private int pos;
public DistinguishedNameParser(X500Principal paramX500Principal)
{
this.dn = paramX500Principal.getName("RFC2253");
this.length = this.dn.length();
}
private String escapedAV()
{
this.beg = this.pos;
this.end = this.pos;
do
{
for (;;)
{
if (this.pos >= this.length) {
return new String(this.chars, this.beg, this.end - this.beg);
}
switch (this.chars[this.pos])
{
default:
arrayOfChar = this.chars;
i = this.end;
this.end = (i + 1);
arrayOfChar[i] = this.chars[this.pos];
this.pos += 1;
break;
case '+':
case ',':
case ';':
return new String(this.chars, this.beg, this.end - this.beg);
case '\\':
arrayOfChar = this.chars;
i = this.end;
this.end = (i + 1);
arrayOfChar[i] = getEscaped();
this.pos += 1;
}
}
this.cur = this.end;
this.pos += 1;
char[] arrayOfChar = this.chars;
int i = this.end;
this.end = (i + 1);
arrayOfChar[i] = ' ';
while ((this.pos < this.length) && (this.chars[this.pos] == ' '))
{
arrayOfChar = this.chars;
i = this.end;
this.end = (i + 1);
arrayOfChar[i] = ' ';
this.pos += 1;
}
} while ((this.pos != this.length) && (this.chars[this.pos] != ',') && (this.chars[this.pos] != '+') && (this.chars[this.pos] != ';'));
return new String(this.chars, this.beg, this.cur - this.beg);
}
private int getByte(int paramInt)
{
if (paramInt + 1 >= this.length) {
throw new IllegalStateException("Malformed DN: " + this.dn);
}
int i = this.chars[paramInt];
if ((i >= 48) && (i <= 57))
{
i -= 48;
paramInt = this.chars[(paramInt + 1)];
if ((paramInt < 48) || (paramInt > 57)) {
break label160;
}
paramInt -= 48;
}
for (;;)
{
return (i << 4) + paramInt;
if ((i >= 97) && (i <= 102))
{
i -= 87;
break;
}
if ((i >= 65) && (i <= 70))
{
i -= 55;
break;
}
throw new IllegalStateException("Malformed DN: " + this.dn);
label160:
if ((paramInt >= 97) && (paramInt <= 102))
{
paramInt -= 87;
}
else
{
if ((paramInt < 65) || (paramInt > 70)) {
break label200;
}
paramInt -= 55;
}
}
label200:
throw new IllegalStateException("Malformed DN: " + this.dn);
}
private char getEscaped()
{
this.pos += 1;
if (this.pos == this.length) {
throw new IllegalStateException("Unexpected end of DN: " + this.dn);
}
switch (this.chars[this.pos])
{
default:
return getUTF8();
}
return this.chars[this.pos];
}
private char getUTF8()
{
int i = getByte(this.pos);
this.pos += 1;
if (i < 128) {
return (char)i;
}
if ((i >= 192) && (i <= 247))
{
int j;
int m;
int k;
if (i <= 223)
{
j = 1;
i &= 0x1F;
m = 0;
k = i;
i = m;
}
for (;;)
{
if (i >= j) {
break label198;
}
this.pos += 1;
if ((this.pos == this.length) || (this.chars[this.pos] != '\\'))
{
return '?';
if (i <= 239)
{
j = 2;
i &= 0xF;
break;
}
j = 3;
i &= 0x7;
break;
}
this.pos += 1;
m = getByte(this.pos);
this.pos += 1;
if ((m & 0xC0) != 128) {
return '?';
}
k = (k << 6) + (m & 0x3F);
i += 1;
}
label198:
return (char)k;
}
return '?';
}
private String hexAV()
{
if (this.pos + 4 >= this.length) {
throw new IllegalStateException("Unexpected end of DN: " + this.dn);
}
this.beg = this.pos;
int k;
for (this.pos += 1;; this.pos += 1)
{
if ((this.pos == this.length) || (this.chars[this.pos] == '+') || (this.chars[this.pos] == ',') || (this.chars[this.pos] == ';')) {
this.end = this.pos;
}
for (;;)
{
k = this.end - this.beg;
if ((k >= 5) && ((k & 0x1) != 0)) {
break label301;
}
throw new IllegalStateException("Unexpected end of DN: " + this.dn);
if (this.chars[this.pos] != ' ') {
break;
}
this.end = this.pos;
for (this.pos += 1; (this.pos < this.length) && (this.chars[this.pos] == ' '); this.pos += 1) {}
}
if ((this.chars[this.pos] >= 'A') && (this.chars[this.pos] <= 'F'))
{
localObject = this.chars;
i = this.pos;
localObject[i] = ((char)(localObject[i] + ' '));
}
}
label301:
Object localObject = new byte[k / 2];
int i = 0;
int j = this.beg + 1;
while (i < localObject.length)
{
localObject[i] = ((byte)getByte(j));
j += 2;
i += 1;
}
return new String(this.chars, this.beg, k);
}
private String nextAT()
{
while ((this.pos < this.length) && (this.chars[this.pos] == ' ')) {
this.pos += 1;
}
if (this.pos == this.length) {
return null;
}
this.beg = this.pos;
for (this.pos += 1; (this.pos < this.length) && (this.chars[this.pos] != '=') && (this.chars[this.pos] != ' '); this.pos += 1) {}
if (this.pos >= this.length) {
throw new IllegalStateException("Unexpected end of DN: " + this.dn);
}
this.end = this.pos;
if (this.chars[this.pos] == ' ')
{
while ((this.pos < this.length) && (this.chars[this.pos] != '=') && (this.chars[this.pos] == ' ')) {
this.pos += 1;
}
if ((this.chars[this.pos] != '=') || (this.pos == this.length)) {
throw new IllegalStateException("Unexpected end of DN: " + this.dn);
}
}
do
{
this.pos += 1;
} while ((this.pos < this.length) && (this.chars[this.pos] == ' '));
if ((this.end - this.beg > 4) && (this.chars[(this.beg + 3)] == '.') && ((this.chars[this.beg] == 'O') || (this.chars[this.beg] == 'o')) && ((this.chars[(this.beg + 1)] == 'I') || (this.chars[(this.beg + 1)] == 'i')) && ((this.chars[(this.beg + 2)] == 'D') || (this.chars[(this.beg + 2)] == 'd'))) {
this.beg += 4;
}
return new String(this.chars, this.beg, this.end - this.beg);
}
private String quotedAV()
{
this.pos += 1;
this.beg = this.pos;
this.end = this.beg;
if (this.pos == this.length) {
throw new IllegalStateException("Unexpected end of DN: " + this.dn);
}
if (this.chars[this.pos] == '"') {
for (this.pos += 1; (this.pos < this.length) && (this.chars[this.pos] == ' '); this.pos += 1) {}
}
if (this.chars[this.pos] == '\\') {
this.chars[this.end] = getEscaped();
}
for (;;)
{
this.pos += 1;
this.end += 1;
break;
this.chars[this.end] = this.chars[this.pos];
}
return new String(this.chars, this.beg, this.end - this.beg);
}
public final String findMostSpecific(String paramString)
{
this.pos = 0;
this.beg = 0;
this.end = 0;
this.cur = 0;
this.chars = this.dn.toCharArray();
String str1 = nextAT();
String str2 = str1;
if (str1 == null)
{
str1 = null;
return str1;
}
label162:
do
{
str1 = "";
if (this.pos == this.length) {
return null;
}
switch (this.chars[this.pos])
{
default:
str1 = escapedAV();
}
while (!paramString.equalsIgnoreCase(str2))
{
if (this.pos < this.length) {
break label162;
}
return null;
str1 = quotedAV();
continue;
str1 = hexAV();
}
if ((this.chars[this.pos] != ',') && (this.chars[this.pos] != ';') && (this.chars[this.pos] != '+')) {
throw new IllegalStateException("Malformed DN: " + this.dn);
}
this.pos += 1;
str1 = nextAT();
str2 = str1;
} while (str1 != null);
throw new IllegalStateException("Malformed DN: " + this.dn);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/internal/tls/DistinguishedNameParser.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/