1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.michaelo.tomcat.pac.asn1;
17
18 import java.math.BigInteger;
19 import java.util.ArrayList;
20 import java.util.List;
21 import java.util.Objects;
22
23 import org.apache.tomcat.util.buf.Asn1Parser;
24
25 import com.sun.security.jgss.AuthorizationDataEntry;
26
27
28
29
30
31
32
33 public class AdIfRelevantAsn1Parser {
34
35
36
37
38 public static final int AD_IF_RELEVANT = 1;
39 public static final int AD_WIN2K_PAC = 128;
40
41 private AdIfRelevantAsn1Parser() {
42 }
43
44
45
46
47
48
49
50
51
52
53
54
55 public static List<AuthorizationDataEntry> parse(byte[] adIfRelevant) {
56 Objects.requireNonNull(adIfRelevant, "adIfRelevant cannot be null");
57 if (adIfRelevant.length == 0)
58 throw new IllegalArgumentException("adIfRelevant cannot be empty");
59
60 List<AuthorizationDataEntry> adEntries = new ArrayList<>();
61
62 Asn1Parser parser = new Asn1Parser(adIfRelevant);
63 parser.parseTagSequence();
64 parser.parseFullLength();
65 while (!parser.eof()) {
66 parser.parseTagSequence();
67 parser.parseLength();
68 Asn1Parser p = new Asn1Parser(parser.parseAttributeAsBytes(0));
69 BigInteger type = p.parseInt();
70 p = new Asn1Parser(parser.parseAttributeAsBytes(1));
71 byte[] data = p.parseOctetString();
72 adEntries.add(new AuthorizationDataEntry(type.intValue(), data));
73 }
74
75 return adEntries;
76 }
77
78 }