01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.harmony.auth.internal.kerberos.v5;
19:
20: import java.io.IOException;
21:
22: import org.apache.harmony.security.asn1.ASN1Any;
23: import org.apache.harmony.security.asn1.ASN1Constants;
24: import org.apache.harmony.security.asn1.ASN1Explicit;
25: import org.apache.harmony.security.asn1.ASN1Integer;
26: import org.apache.harmony.security.asn1.ASN1Sequence;
27: import org.apache.harmony.security.asn1.ASN1StringType;
28: import org.apache.harmony.security.asn1.ASN1Type;
29: import org.apache.harmony.security.asn1.BerInputStream;
30:
31: /**
32: * @see http://www.ietf.org/rfc/rfc4120.txt
33: */
34: public class Ticket {
35:
36: private final PrincipalName sname;
37:
38: private final String realm;
39:
40: // ASN.1 encoding of this ticket
41: private byte[] encoded;
42:
43: private Ticket(String realm, PrincipalName sname) {
44: this .sname = sname;
45: this .realm = realm;
46: }
47:
48: public String getRealm() {
49: return realm;
50: }
51:
52: public PrincipalName getSname() {
53: return sname;
54: }
55:
56: public byte[] getEncoded() {
57: return encoded;
58: }
59:
60: /**
61: <pre>Ticket ::= [APPLICATION 1] SEQUENCE {
62: tkt-vno [0] INTEGER (5),
63: realm [1] Realm,
64: sname [2] PrincipalName,
65: enc-part [3] EncryptedData -- EncTicketPart
66: }</pre>
67: */
68: static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] {
69: new ASN1Explicit(0, ASN1Integer.getInstance()), // tkt-vno
70: // TODO should we define Realm type?
71: new ASN1Explicit(1, ASN1StringType.GENERALSTRING), // realm
72: new ASN1Explicit(2, PrincipalName.ASN1), // sname
73: // FIXME ignored
74: new ASN1Explicit(3, ASN1Any.getInstance()), // ticket
75: }) {
76:
77: @Override
78: protected Object getDecodedObject(BerInputStream in)
79: throws IOException {
80:
81: Object[] values = (Object[]) in.content;
82:
83: Ticket ticket = new Ticket((String) values[1],
84: (PrincipalName) values[2]);
85: ticket.encoded = in.getEncoded();
86:
87: return ticket;
88: }
89:
90: @Override
91: protected void getValues(Object object, Object[] values) {
92: throw new RuntimeException(); //FIXME message
93: }
94: };
95:
96: public static final ASN1Explicit TICKET_ASN1 = new ASN1Explicit(
97: ASN1Constants.CLASS_APPLICATION, 1, ASN1);
98: }
|