Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.security.jgss/share/classes/sun/security/krb5/internal/LastReqEntry.java
41161 views
1
/*
2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3
*
4
* This code is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 2 only, as
6
* published by the Free Software Foundation. Oracle designates this
7
* particular file as subject to the "Classpath" exception as provided
8
* by Oracle in the LICENSE file that accompanied this code.
9
*
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
15
*
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*/
24
25
/*
26
*
27
* (C) Copyright IBM Corp. 1999 All Rights Reserved.
28
* Copyright 1997 The Open Group Research Institute. All rights reserved.
29
*/
30
31
package sun.security.krb5.internal;
32
33
import sun.security.util.*;
34
import sun.security.krb5.Asn1Exception;
35
import java.io.IOException;
36
37
public class LastReqEntry {
38
private int lrType;
39
private KerberosTime lrValue;
40
41
private LastReqEntry() {
42
}
43
44
public LastReqEntry(int Type, KerberosTime time){
45
lrType = Type;
46
lrValue = time;
47
// XXX check the type and time.
48
}
49
50
/**
51
* Constructs a LastReqEntry object.
52
* @param encoding a Der-encoded data.
53
* @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
54
* @exception IOException if an I/O error occurs while reading encoded data.
55
*/
56
public LastReqEntry(DerValue encoding) throws Asn1Exception, IOException {
57
if (encoding.getTag() != DerValue.tag_Sequence) {
58
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
59
}
60
DerValue der;
61
der = encoding.getData().getDerValue();
62
if ((der.getTag() & 0x1F) == 0x00){
63
lrType = der.getData().getBigInteger().intValue();
64
}
65
else
66
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
67
68
lrValue = KerberosTime.parse(encoding.getData(), (byte)0x01, false);
69
if (encoding.getData().available() > 0)
70
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
71
}
72
73
/**
74
* Encodes an LastReqEntry object.
75
* @return the byte array of encoded LastReqEntry object.
76
* @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
77
* @exception IOException if an I/O error occurs while reading encoded data.
78
*/
79
public byte[] asn1Encode() throws Asn1Exception, IOException {
80
DerOutputStream bytes = new DerOutputStream();
81
DerOutputStream temp = new DerOutputStream();
82
temp.putInteger(lrType);
83
bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp);
84
bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), lrValue.asn1Encode());
85
temp = new DerOutputStream();
86
temp.write(DerValue.tag_Sequence, bytes);
87
return temp.toByteArray();
88
}
89
90
public Object clone() {
91
LastReqEntry newEntry = new LastReqEntry();
92
newEntry.lrType = lrType;
93
newEntry.lrValue = lrValue;
94
return newEntry;
95
}
96
}
97
98