feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,107 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*
* (C) Copyright IBM Corp. 1999 All Rights Reserved.
* Copyright 1997 The Open Group Research Institute. All rights reserved.
*/
package sun.security.krb5.internal.util;
import java.io.IOException;
import java.util.Arrays;
import sun.security.krb5.internal.Krb5;
import sun.security.util.BitArray;
import sun.security.util.DerOutputStream;
/**
* A wrapper class around sun.security.util.BitArray, so that KDCOptions,
* TicketFlags and ApOptions in krb5 classes can utilize some functions
* in BitArray classes.
*
* The data type is defined in RFC 4120 as:
*
* 5.2.8. KerberosFlags
*
* For several message types, a specific constrained bit string type,
* KerberosFlags, is used.
*
* KerberosFlags ::= BIT STRING (SIZE (32..MAX))
* -- minimum number of bits shall be sent,
* -- but no fewer than 32
*
* @author Yanni Zhang
*/
public class KerberosFlags {
BitArray bits;
// This constant is used by child classes.
protected static final int BITS_PER_UNIT = 8;
public KerberosFlags(int length) throws IllegalArgumentException {
bits = new BitArray(length);
}
public KerberosFlags(int length, byte[] a) throws IllegalArgumentException {
bits = new BitArray(length, a);
if (length != Krb5.KRB_FLAGS_MAX+1) {
bits = new BitArray(Arrays.copyOf(bits.toBooleanArray(), Krb5.KRB_FLAGS_MAX+1));
}
}
public KerberosFlags(boolean[] bools) {
bits = new BitArray((bools.length==Krb5.KRB_FLAGS_MAX+1)?
bools:
Arrays.copyOf(bools, Krb5.KRB_FLAGS_MAX+1));
}
public void set(int index, boolean value) {
bits.set(index, value);
}
public boolean get(int index) {
return bits.get(index);
}
public boolean[] toBooleanArray() {
return bits.toBooleanArray();
}
/**
* Writes the encoded data.
*
* @exception IOException if an I/O error occurs while reading encoded data.
* @return an byte array of encoded KDCOptions.
*/
public byte[] asn1Encode() throws IOException {
DerOutputStream out = new DerOutputStream();
out.putUnalignedBitString(bits);
return out.toByteArray();
}
public String toString() {
return bits.toString();
}
}

View File

@@ -0,0 +1,82 @@
/*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.krb5.internal.util;
import java.io.IOException;
import java.security.AccessController;
import sun.security.action.GetBooleanAction;
import sun.security.util.DerValue;
/**
* Implements the ASN.1 KerberosString type.
*
* <pre>
* KerberosString ::= GeneralString (IA5String)
* </pre>
*
* This definition reflects the Network Working Group RFC 4120
* specification available at
* <a href="http://www.ietf.org/rfc/rfc4120.txt">
* http://www.ietf.org/rfc/rfc4120.txt</a>.
*/
public final class KerberosString {
/**
* RFC 4120 defines KerberosString as GeneralString (IA5String), which
* only includes ASCII characters. However, other implementations have been
* known to use GeneralString to contain UTF-8 encoding. To interop
* with these implementations, the following system property is defined.
* When set as true, KerberosString is encoded as UTF-8. Note that this
* only affects the byte encoding, the tag of the ASN.1 type is still
* GeneralString.
*/
public static final boolean MSNAME = AccessController.doPrivileged(
new GetBooleanAction("sun.security.krb5.msinterop.kstring"));
private final String s;
public KerberosString(String s) {
this.s = s;
}
public KerberosString(DerValue der) throws IOException {
if (der.tag != DerValue.tag_GeneralString) {
throw new IOException(
"KerberosString's tag is incorrect: " + der.tag);
}
s = new String(der.getDataBytes(), MSNAME?"UTF8":"ASCII");
}
public String toString() {
return s;
}
public DerValue toDerValue() throws IOException {
// No need to cache the result since this method is
// only called once.
return new DerValue(DerValue.tag_GeneralString,
s.getBytes(MSNAME?"UTF8":"ASCII"));
}
}

View File

@@ -0,0 +1,102 @@
/*
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*
* (C) Copyright IBM Corp. 1999 All Rights Reserved.
* Copyright 1997 The Open Group Research Institute. All rights reserved.
*/
package sun.security.krb5.internal.util;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.IOException;
/**
* This class implements a buffered input stream. It provides methods to read a chunck
* of data from underlying data stream.
*
* @author Yanni Zhang
*
*/
public class KrbDataInputStream extends BufferedInputStream{
private boolean bigEndian = true;
public void setNativeByteOrder() {
if (java.nio.ByteOrder.nativeOrder().
equals(java.nio.ByteOrder.BIG_ENDIAN)) {
bigEndian = true;
} else {
bigEndian = false;
}
}
public KrbDataInputStream(InputStream is){
super(is);
}
/**
* Reads a length value which is represented in 4 bytes from
* this input stream. The value must be positive.
* @return the length value represented by this byte array.
* @throws IOException if there are not enough bytes or it represents
* a negative value
*/
final public int readLength4() throws IOException {
int len = read(4);
if (len < 0) {
throw new IOException("Invalid encoding");
}
return len;
}
/**
* Reads up to the specific number of bytes from this input stream.
* @param num the number of bytes to be read.
* @return the int value of this byte array.
* @throws IOException if there are not enough bytes
*/
public int read(int num) throws IOException {
byte[] bytes = new byte[num];
if (read(bytes, 0, num) != num) {
throw new IOException("Premature end of stream reached");
}
int result = 0;
for (int i = 0; i < num; i++) {
if (bigEndian) {
result |= (bytes[i] & 0xff) << (num - i - 1) * 8;
} else {
result |= (bytes[i] & 0xff) << i * 8;
}
}
return result;
}
public int readVersion() throws IOException {
// always read in big-endian mode
int result = (read() & 0xff) << 8;
return result | (read() & 0xff);
}
}

View File

@@ -0,0 +1,67 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*
* (C) Copyright IBM Corp. 1999 All Rights Reserved.
* Copyright 1997 The Open Group Research Institute. All rights reserved.
*/
package sun.security.krb5.internal.util;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* This class implements a buffered output stream. It provides methods to write a chunck of
* bytes to underlying data stream.
*
* @author Yanni Zhang
*
*/
public class KrbDataOutputStream extends BufferedOutputStream {
public KrbDataOutputStream(OutputStream os) {
super(os);
}
public void write32(int num) throws IOException {
byte[] bytes = new byte[4];
bytes[0] = (byte)((num & 0xff000000) >> 24 & 0xff);
bytes[1] = (byte)((num & 0x00ff0000) >> 16 & 0xff);
bytes[2] = (byte)((num & 0x0000ff00) >> 8 & 0xff);
bytes[3] = (byte)(num & 0xff);
write(bytes, 0, 4);
}
public void write16(int num) throws IOException {
byte[] bytes = new byte[2];
bytes[0] = (byte)((num & 0xff00) >> 8 & 0xff);
bytes[1] = (byte)(num & 0xff);
write(bytes, 0, 2);
}
public void write8(int num) throws IOException {
write(num & 0xff);
}
}