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.io.decoder;
21
22
23 import java.io.IOException;
24 import java.util.Enumeration;
25
26 import org.apache.directory.server.kerberos.shared.messages.application.ApplicationReply;
27 import org.apache.directory.shared.asn1.der.ASN1InputStream;
28 import org.apache.directory.shared.asn1.der.DERApplicationSpecific;
29 import org.apache.directory.shared.asn1.der.DEREncodable;
30 import org.apache.directory.shared.asn1.der.DERSequence;
31 import org.apache.directory.shared.asn1.der.DERTaggedObject;
32
33
34
35
36
37
38 public class ApplicationReplyDecoder
39 {
40
41
42
43
44
45
46
47 public ApplicationReply decode( byte[] encodedAuthHeader ) throws IOException
48 {
49 ASN1InputStream ais = new ASN1InputStream( encodedAuthHeader );
50
51 DERApplicationSpecific app = ( DERApplicationSpecific ) ais.readObject();
52
53 DERSequence apreq = ( DERSequence ) app.getObject();
54
55 return decodeApplicationRequestSequence( apreq );
56 }
57
58
59
60
61
62
63
64
65
66 private ApplicationReply decodeApplicationRequestSequence( DERSequence sequence )
67 {
68 ApplicationReply authHeader = null;
69
70 for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
71 {
72 DERTaggedObject object = ( ( DERTaggedObject ) e.nextElement() );
73 int tag = object.getTagNo();
74 DEREncodable derObject = object.getObject();
75
76 switch ( tag )
77 {
78 case 0:
79
80
81 break;
82 case 1:
83
84
85 break;
86 case 2:
87 DERSequence tag2 = ( DERSequence ) derObject;
88 authHeader = new ApplicationReply( EncryptedDataDecoder.decode( tag2 ) );
89 break;
90 }
91 }
92
93 return authHeader;
94 }
95 }