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/APOptions.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.krb5.Asn1Exception;
34
import sun.security.krb5.internal.util.KerberosFlags;
35
import sun.security.util.*;
36
import java.io.IOException;
37
38
/**
39
* Implements the ASN.1 APOptions type.
40
*
41
* <pre>{@code
42
* APOptions ::= KerberosFlags
43
* -- reserved(0),
44
* -- use-session-key(1),
45
* -- mutual-required(2)
46
*
47
* KerberosFlags ::= BIT STRING (SIZE (32..MAX))
48
* -- minimum number of bits shall be sent,
49
* -- but no fewer than 32
50
*
51
* }</pre>
52
* <p>
53
* This definition reflects the Network Working Group RFC4120
54
* specification available at
55
* <a href="http://www.ietf.org/rfc/rfc4120.txt">
56
* http://www.ietf.org/rfc/rfc4120.txt</a>.
57
*/
58
59
public class APOptions extends KerberosFlags {
60
public APOptions() {
61
super(Krb5.AP_OPTS_MAX + 1);
62
}
63
64
public APOptions(int oneBit) throws Asn1Exception {
65
super(Krb5.AP_OPTS_MAX + 1);
66
set(oneBit, true);
67
}
68
public APOptions(int size, byte[] data) throws Asn1Exception {
69
super(size, data);
70
if ((size > data.length * BITS_PER_UNIT) || (size > Krb5.AP_OPTS_MAX + 1)) {
71
throw new Asn1Exception(Krb5.BITSTRING_BAD_LENGTH);
72
}
73
}
74
75
public APOptions(boolean[] data) throws Asn1Exception {
76
super(data);
77
if (data.length > Krb5.AP_OPTS_MAX + 1) {
78
throw new Asn1Exception(Krb5.BITSTRING_BAD_LENGTH);
79
}
80
}
81
82
public APOptions(DerValue encoding) throws IOException, Asn1Exception {
83
this(encoding.getUnalignedBitString(true).toBooleanArray());
84
}
85
86
/**
87
* Parse (unmarshal) an APOptions from a DER input stream. This form
88
* parsing might be used when expanding a value which is part of
89
* a constructed sequence and uses explicitly tagged type.
90
*
91
* @param data the Der input stream value, which contains one or more marshaled value.
92
* @param explicitTag tag number.
93
* @param optional indicate if this data field is optional.
94
* @return an instance of APOptions.
95
* @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
96
* @exception IOException if an I/O error occurs while reading encoded data.
97
*
98
*/
99
public static APOptions parse(DerInputStream data, byte explicitTag, boolean optional) throws Asn1Exception, IOException {
100
if ((optional) && (((byte)data.peekByte() & (byte)0x1F) != explicitTag))
101
return null;
102
DerValue der = data.getDerValue();
103
if (explicitTag != (der.getTag() & (byte)0x1F)) {
104
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
105
} else {
106
DerValue subDer = der.getData().getDerValue();
107
return new APOptions(subDer);
108
}
109
}
110
}
111
112