Merge
This commit is contained in:
commit
b53399446c
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 1997, 2015, 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
|
||||
@ -27,7 +27,6 @@
|
||||
|
||||
SUNWprivate_1.1 {
|
||||
global:
|
||||
Java_java_util_jar_JarFile_getMetaInfEntryNames;
|
||||
Java_java_util_zip_Adler32_update;
|
||||
Java_java_util_zip_Adler32_updateBytes;
|
||||
Java_java_util_zip_Adler32_updateByteBuffer;
|
||||
@ -48,25 +47,6 @@ SUNWprivate_1.1 {
|
||||
Java_java_util_zip_Inflater_initIDs;
|
||||
Java_java_util_zip_Inflater_reset;
|
||||
Java_java_util_zip_Inflater_setDictionary;
|
||||
Java_java_util_zip_ZipFile_close;
|
||||
Java_java_util_zip_ZipFile_getCommentBytes;
|
||||
Java_java_util_zip_ZipFile_freeEntry;
|
||||
Java_java_util_zip_ZipFile_getEntry;
|
||||
Java_java_util_zip_ZipFile_getEntryBytes;
|
||||
Java_java_util_zip_ZipFile_getEntryCrc;
|
||||
Java_java_util_zip_ZipFile_getEntryCSize;
|
||||
Java_java_util_zip_ZipFile_getEntryFlag;
|
||||
Java_java_util_zip_ZipFile_getEntryMethod;
|
||||
Java_java_util_zip_ZipFile_getEntrySize;
|
||||
Java_java_util_zip_ZipFile_getEntryTime;
|
||||
Java_java_util_zip_ZipFile_getNextEntry;
|
||||
Java_java_util_zip_ZipFile_getZipMessage;
|
||||
Java_java_util_zip_ZipFile_getTotal;
|
||||
Java_java_util_zip_ZipFile_initIDs;
|
||||
Java_java_util_zip_ZipFile_open;
|
||||
Java_java_util_zip_ZipFile_read;
|
||||
Java_java_util_zip_ZipFile_startsWithLOC;
|
||||
|
||||
ZIP_Close;
|
||||
ZIP_CRC32;
|
||||
ZIP_FindEntry;
|
||||
|
@ -16,30 +16,14 @@ text: .text%ZIP_InflateFully;
|
||||
text: .text%ZIP_Lock;
|
||||
text: .text%ZIP_Unlock;
|
||||
text: .text%ZIP_FreeEntry;
|
||||
text: .text%Java_java_util_zip_ZipFile_initIDs;
|
||||
text: .text%Java_java_util_zip_ZipFile_open;
|
||||
text: .text%Java_java_util_zip_ZipFile_getTotal;
|
||||
text: .text%Java_java_util_zip_ZipFile_startsWithLOC;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntry;
|
||||
text: .text%Java_java_util_zip_ZipFile_freeEntry;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryTime;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryCrc;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryCSize;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntrySize;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryFlag;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryMethod;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryBytes;
|
||||
text: .text%Java_java_util_zip_Inflater_initIDs;
|
||||
text: .text%Java_java_util_zip_Inflater_init;
|
||||
text: .text%inflateInit2_;
|
||||
text: .text%zcalloc;
|
||||
text: .text%Java_java_util_zip_Inflater_inflateBytes;
|
||||
text: .text%Java_java_util_zip_ZipFile_read;
|
||||
text: .text%ZIP_Read;
|
||||
text: .text%zcfree;
|
||||
text: .text%Java_java_util_jar_JarFile_getMetaInfEntryNames;
|
||||
text: .text%Java_java_util_zip_Inflater_reset;
|
||||
text: .text%Java_java_util_zip_Inflater_end;
|
||||
text: .text%inflateEnd;
|
||||
text: .text%Java_java_util_zip_ZipFile_close;
|
||||
text: .text%ZIP_Close;
|
||||
|
@ -15,19 +15,6 @@ text: .text%ZIP_InflateFully;
|
||||
text: .text%ZIP_Lock;
|
||||
text: .text%ZIP_Unlock;
|
||||
text: .text%ZIP_FreeEntry;
|
||||
text: .text%Java_java_util_zip_ZipFile_initIDs;
|
||||
text: .text%Java_java_util_zip_ZipFile_open;
|
||||
text: .text%Java_java_util_zip_ZipFile_getTotal;
|
||||
text: .text%Java_java_util_zip_ZipFile_startsWithLOC;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntry;
|
||||
text: .text%Java_java_util_zip_ZipFile_freeEntry;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryTime;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryCrc;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryCSize;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntrySize;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryFlag;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryMethod;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryBytes;
|
||||
text: .text%Java_java_util_zip_Inflater_initIDs;
|
||||
text: .text%Java_java_util_zip_Inflater_init;
|
||||
text: .text%inflateInit2_;
|
||||
@ -35,7 +22,6 @@ text: .text%zcalloc;
|
||||
text: .text%inflateReset;
|
||||
text: .text%Java_java_util_zip_Inflater_inflateBytes;
|
||||
text: .text%inflate;
|
||||
text: .text%Java_java_util_zip_ZipFile_read;
|
||||
text: .text%ZIP_Read;
|
||||
text: .text%zcfree;
|
||||
text: .text%Java_java_util_jar_JarFile_getMetaInfEntryNames;
|
||||
@ -43,6 +29,5 @@ text: .text%ZIP_ReadEntry;
|
||||
text: .text%InflateFully;
|
||||
text: .text%inflateEnd;
|
||||
text: .text%Java_java_util_zip_Inflater_reset;
|
||||
text: .text%Java_java_util_zip_ZipFile_close;
|
||||
text: .text%ZIP_Close;
|
||||
text: .text%Java_java_util_zip_Inflater_end;
|
||||
|
@ -16,34 +16,16 @@ text: .text%ZIP_InflateFully;
|
||||
text: .text%ZIP_Lock;
|
||||
text: .text%ZIP_Unlock;
|
||||
text: .text%ZIP_FreeEntry;
|
||||
text: .text%Java_java_util_zip_ZipFile_initIDs;
|
||||
text: .text%Java_java_util_zip_ZipFile_open;
|
||||
text: .text%Java_java_util_zip_ZipFile_getTotal;
|
||||
text: .text%Java_java_util_zip_ZipFile_startsWithLOC;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntry;
|
||||
text: .text%Java_java_util_zip_ZipFile_freeEntry;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryTime;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryCrc;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryCSize;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntrySize;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryFlag;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryMethod;
|
||||
text: .text%Java_java_util_zip_ZipFile_getEntryBytes;
|
||||
text: .text%Java_java_util_zip_Inflater_initIDs;
|
||||
text: .text%Java_java_util_zip_Inflater_init;
|
||||
text: .text%inflateInit2_;
|
||||
text: .text%zcalloc;
|
||||
text: .text%inflateReset;
|
||||
text: .text%Java_java_util_zip_Inflater_inflateBytes;
|
||||
text: .text%inflate;
|
||||
text: .text%Java_java_util_zip_ZipFile_read;
|
||||
text: .text%ZIP_Read;
|
||||
text: .text%zcfree;
|
||||
text: .text%Java_java_util_jar_JarFile_getMetaInfEntryNames;
|
||||
text: .text%ZIP_ReadEntry;
|
||||
text: .text%InflateFully;
|
||||
text: .text%inflateEnd;
|
||||
text: .text%Java_java_util_zip_Inflater_reset;
|
||||
text: .text%Java_java_util_zip_ZipFile_close;
|
||||
text: .text%ZIP_Close;
|
||||
text: .text%Java_java_util_zip_Inflater_end;
|
||||
|
@ -27,7 +27,7 @@ package com.sun.crypto.provider;
|
||||
|
||||
import java.io.*;
|
||||
import sun.security.util.*;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.security.spec.InvalidParameterSpecException;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
|
@ -30,7 +30,7 @@ import java.security.AlgorithmParametersSpi;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.security.spec.InvalidParameterSpecException;
|
||||
import javax.crypto.spec.GCMParameterSpec;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.*;
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ import java.security.AlgorithmParametersSpi;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.security.spec.InvalidParameterSpecException;
|
||||
import javax.crypto.spec.PBEParameterSpec;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.*;
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.security.spec.InvalidParameterSpecException;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.PBEParameterSpec;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.*;
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ import java.security.AlgorithmParametersSpi;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.security.spec.InvalidParameterSpecException;
|
||||
import javax.crypto.spec.RC2ParameterSpec;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.*;
|
||||
|
||||
/**
|
||||
|
@ -118,7 +118,7 @@ class NTLM {
|
||||
public void debug(byte[] bytes) {
|
||||
if (DEBUG) {
|
||||
try {
|
||||
new sun.misc.HexDumpEncoder().encodeBuffer(bytes, System.out);
|
||||
new sun.security.util.HexDumpEncoder().encodeBuffer(bytes, System.out);
|
||||
} catch (IOException ioe) {
|
||||
// Impossible
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ package java.security.cert;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.DerValue;
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ import java.security.PublicKey;
|
||||
import java.util.*;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.Debug;
|
||||
import sun.security.util.DerInputStream;
|
||||
import sun.security.util.DerValue;
|
||||
|
@ -1856,6 +1856,7 @@ public class SimpleDateFormat extends DateFormat {
|
||||
if (patternCharIndex == PATTERN_HOUR_OF_DAY1 ||
|
||||
patternCharIndex == PATTERN_HOUR1 ||
|
||||
(patternCharIndex == PATTERN_MONTH && count <= 2) ||
|
||||
(patternCharIndex == PATTERN_MONTH_STANDALONE && count <= 2) ||
|
||||
patternCharIndex == PATTERN_YEAR ||
|
||||
patternCharIndex == PATTERN_WEEK_YEAR) {
|
||||
// It would be good to unify this with the obeyCount logic below,
|
||||
@ -1976,6 +1977,20 @@ public class SimpleDateFormat extends DateFormat {
|
||||
}
|
||||
break parsing;
|
||||
|
||||
case PATTERN_MONTH_STANDALONE: // 'L'
|
||||
if (count <= 2) {
|
||||
// Don't want to parse the month if it is a string
|
||||
// while pattern uses numeric style: L or LL
|
||||
//[we computed 'value' above.]
|
||||
calb.set(Calendar.MONTH, value - 1);
|
||||
return pos.index;
|
||||
}
|
||||
Map<String, Integer> maps = getDisplayNamesMap(field, locale);
|
||||
if ((index = matchString(text, start, field, maps, calb)) > 0) {
|
||||
return index;
|
||||
}
|
||||
break parsing;
|
||||
|
||||
case PATTERN_HOUR_OF_DAY1: // 'k' 1-based. eg, 23:59 + 1 hour =>> 24:59
|
||||
if (!isLenient()) {
|
||||
// Validate the hour value in non-lenient
|
||||
|
@ -203,7 +203,10 @@ class JarFile extends ZipFile {
|
||||
return man;
|
||||
}
|
||||
|
||||
private native String[] getMetaInfEntryNames();
|
||||
private String[] getMetaInfEntryNames() {
|
||||
return jdk.internal.misc.SharedSecrets.getJavaUtilZipFileAccess()
|
||||
.getMetaInfEntryNames((ZipFile)this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@code JarEntry} for the given entry name or
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2015, 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
|
||||
@ -5814,7 +5814,7 @@ NEXT: while (i <= last) {
|
||||
*/
|
||||
public Stream<String> splitAsStream(final CharSequence input) {
|
||||
class MatcherIterator implements Iterator<String> {
|
||||
private final Matcher matcher;
|
||||
private Matcher matcher;
|
||||
// The start position of the next sub-sequence of input
|
||||
// when current == input.length there are no more elements
|
||||
private int current;
|
||||
@ -5823,14 +5823,6 @@ NEXT: while (i <= last) {
|
||||
// > 0 if there are N next empty elements
|
||||
private int emptyElementCount;
|
||||
|
||||
MatcherIterator() {
|
||||
this.matcher = matcher(input);
|
||||
// If the input is an empty string then the result can only be a
|
||||
// stream of the input. Induce that by setting the empty
|
||||
// element count to 1
|
||||
this.emptyElementCount = input.length() == 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
public String next() {
|
||||
if (!hasNext())
|
||||
throw new NoSuchElementException();
|
||||
@ -5846,6 +5838,13 @@ NEXT: while (i <= last) {
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
if (matcher == null) {
|
||||
matcher = matcher(input);
|
||||
// If the input is an empty string then the result can only be a
|
||||
// stream of the input. Induce that by setting the empty
|
||||
// element count to 1
|
||||
emptyElementCount = input.length() == 0 ? 1 : 0;
|
||||
}
|
||||
if (nextElement != null || emptyElementCount > 0)
|
||||
return true;
|
||||
|
||||
|
@ -434,7 +434,7 @@ public final class Collectors {
|
||||
* stream returned by mapper
|
||||
* @return a collector which applies the mapping function to the input
|
||||
* elements and provides the flat mapped results to the downstream collector
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public static <T, U, A, R>
|
||||
Collector<T, ?, R> flatMapping(Function<? super T, ? extends Stream<? extends U>> mapper,
|
||||
@ -451,6 +451,53 @@ public final class Collectors {
|
||||
downstream.characteristics());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapts a {@code Collector} to one accepting elements of the same type
|
||||
* {@code T} by applying the predicate to each input element and only
|
||||
* accumulating if the predicate returns {@code true}.
|
||||
*
|
||||
* @apiNote
|
||||
* The {@code filtering()} collectors are most useful when used in a
|
||||
* multi-level reduction, such as downstream of a {@code groupingBy} or
|
||||
* {@code partitioningBy}. For example, given a stream of
|
||||
* {@code Employee}, to accumulate the employees in each department that have a
|
||||
* salary above a certain threshold:
|
||||
* <pre>{@code
|
||||
* Map<Department, Set<Employee>> wellPaidEmployeesByDepartment
|
||||
* = employees.stream().collect(groupingBy(Employee::getDepartment,
|
||||
* filtering(e -> e.getSalary() > 2000, toSet())));
|
||||
* }</pre>
|
||||
* A filtering collector differs from a stream's {@code filter()} operation.
|
||||
* In this example, suppose there are no employees whose salary is above the
|
||||
* threshold in some department. Using a filtering collector as shown above
|
||||
* would result in a mapping from that department to an empty {@code Set}.
|
||||
* If a stream {@code filter()} operation were done instead, there would be
|
||||
* no mapping for that department at all.
|
||||
*
|
||||
* @param <T> the type of the input elements
|
||||
* @param <A> intermediate accumulation type of the downstream collector
|
||||
* @param <R> result type of collector
|
||||
* @param predicate a predicate to be applied to the input elements
|
||||
* @param downstream a collector which will accept values that match the
|
||||
* predicate
|
||||
* @return a collector which applies the predicate to the input elements
|
||||
* and provides matching elements to the downstream collector
|
||||
* @since 9
|
||||
*/
|
||||
public static <T, A, R>
|
||||
Collector<T, ?, R> filtering(Predicate<? super T> predicate,
|
||||
Collector<? super T, A, R> downstream) {
|
||||
BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator();
|
||||
return new CollectorImpl<>(downstream.supplier(),
|
||||
(r, t) -> {
|
||||
if (predicate.test(t)) {
|
||||
downstreamAccumulator.accept(r, t);
|
||||
}
|
||||
},
|
||||
downstream.combiner(), downstream.finisher(),
|
||||
downstream.characteristics());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapts a {@code Collector} to perform an additional finishing
|
||||
* transformation. For example, one could adapt the {@link #toList()}
|
||||
|
@ -43,7 +43,7 @@ import sun.nio.cs.ArrayEncoder;
|
||||
|
||||
final class ZipCoder {
|
||||
|
||||
String toString(byte[] ba, int length) {
|
||||
String toString(byte[] ba, int off, int length) {
|
||||
CharsetDecoder cd = decoder().reset();
|
||||
int len = (int)(length * cd.maxCharsPerByte());
|
||||
char[] ca = new char[len];
|
||||
@ -53,12 +53,12 @@ final class ZipCoder {
|
||||
// CodingErrorAction.REPLACE mode. ZipCoder uses
|
||||
// REPORT mode.
|
||||
if (isUTF8 && cd instanceof ArrayDecoder) {
|
||||
int clen = ((ArrayDecoder)cd).decode(ba, 0, length, ca);
|
||||
int clen = ((ArrayDecoder)cd).decode(ba, off, length, ca);
|
||||
if (clen == -1) // malformed
|
||||
throw new IllegalArgumentException("MALFORMED");
|
||||
return new String(ca, 0, clen);
|
||||
}
|
||||
ByteBuffer bb = ByteBuffer.wrap(ba, 0, length);
|
||||
ByteBuffer bb = ByteBuffer.wrap(ba, off, length);
|
||||
CharBuffer cb = CharBuffer.wrap(ca);
|
||||
CoderResult cr = cd.decode(bb, cb, true);
|
||||
if (!cr.isUnderflow())
|
||||
@ -69,8 +69,12 @@ final class ZipCoder {
|
||||
return new String(ca, 0, cb.position());
|
||||
}
|
||||
|
||||
String toString(byte[] ba, int length) {
|
||||
return toString(ba, 0, length);
|
||||
}
|
||||
|
||||
String toString(byte[] ba) {
|
||||
return toString(ba, ba.length);
|
||||
return toString(ba, 0, ba.length);
|
||||
}
|
||||
|
||||
byte[] getBytes(String s) {
|
||||
@ -111,13 +115,16 @@ final class ZipCoder {
|
||||
return utf8.getBytes(s);
|
||||
}
|
||||
|
||||
|
||||
String toStringUTF8(byte[] ba, int len) {
|
||||
return toStringUTF8(ba, 0, len);
|
||||
}
|
||||
|
||||
String toStringUTF8(byte[] ba, int off, int len) {
|
||||
if (isUTF8)
|
||||
return toString(ba, len);
|
||||
return toString(ba, off, len);
|
||||
if (utf8 == null)
|
||||
utf8 = new ZipCoder(StandardCharsets.UTF_8);
|
||||
return utf8.toString(ba, len);
|
||||
return utf8.toString(ba, off, len);
|
||||
}
|
||||
|
||||
boolean isUTF8() {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,6 +31,8 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static java.util.zip.ZipConstants.ENDHDR;
|
||||
|
||||
class ZipUtils {
|
||||
|
||||
// used to adjust values between Windows and java epoch
|
||||
@ -133,7 +135,7 @@ class ZipUtils {
|
||||
* The bytes are assumed to be in Intel (little-endian) byte order.
|
||||
*/
|
||||
public static final int get16(byte b[], int off) {
|
||||
return Byte.toUnsignedInt(b[off]) | (Byte.toUnsignedInt(b[off+1]) << 8);
|
||||
return (b[off] & 0xff) | ((b[off + 1] & 0xff) << 8);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,4 +162,79 @@ class ZipUtils {
|
||||
public static final int get32S(byte b[], int off) {
|
||||
return (get16(b, off) | (get16(b, off+2) << 16));
|
||||
}
|
||||
|
||||
// fields access methods
|
||||
static final int CH(byte[] b, int n) {
|
||||
return b[n] & 0xff ;
|
||||
}
|
||||
|
||||
static final int SH(byte[] b, int n) {
|
||||
return (b[n] & 0xff) | ((b[n + 1] & 0xff) << 8);
|
||||
}
|
||||
|
||||
static final long LG(byte[] b, int n) {
|
||||
return ((SH(b, n)) | (SH(b, n + 2) << 16)) & 0xffffffffL;
|
||||
}
|
||||
|
||||
static final long LL(byte[] b, int n) {
|
||||
return (LG(b, n)) | (LG(b, n + 4) << 32);
|
||||
}
|
||||
|
||||
static final long GETSIG(byte[] b) {
|
||||
return LG(b, 0);
|
||||
}
|
||||
|
||||
// local file (LOC) header fields
|
||||
static final long LOCSIG(byte[] b) { return LG(b, 0); } // signature
|
||||
static final int LOCVER(byte[] b) { return SH(b, 4); } // version needed to extract
|
||||
static final int LOCFLG(byte[] b) { return SH(b, 6); } // general purpose bit flags
|
||||
static final int LOCHOW(byte[] b) { return SH(b, 8); } // compression method
|
||||
static final long LOCTIM(byte[] b) { return LG(b, 10);} // modification time
|
||||
static final long LOCCRC(byte[] b) { return LG(b, 14);} // crc of uncompressed data
|
||||
static final long LOCSIZ(byte[] b) { return LG(b, 18);} // compressed data size
|
||||
static final long LOCLEN(byte[] b) { return LG(b, 22);} // uncompressed data size
|
||||
static final int LOCNAM(byte[] b) { return SH(b, 26);} // filename length
|
||||
static final int LOCEXT(byte[] b) { return SH(b, 28);} // extra field length
|
||||
|
||||
// extra local (EXT) header fields
|
||||
static final long EXTCRC(byte[] b) { return LG(b, 4);} // crc of uncompressed data
|
||||
static final long EXTSIZ(byte[] b) { return LG(b, 8);} // compressed size
|
||||
static final long EXTLEN(byte[] b) { return LG(b, 12);} // uncompressed size
|
||||
|
||||
// end of central directory header (END) fields
|
||||
static final int ENDSUB(byte[] b) { return SH(b, 8); } // number of entries on this disk
|
||||
static final int ENDTOT(byte[] b) { return SH(b, 10);} // total number of entries
|
||||
static final long ENDSIZ(byte[] b) { return LG(b, 12);} // central directory size
|
||||
static final long ENDOFF(byte[] b) { return LG(b, 16);} // central directory offset
|
||||
static final int ENDCOM(byte[] b) { return SH(b, 20);} // size of zip file comment
|
||||
static final int ENDCOM(byte[] b, int off) { return SH(b, off + 20);}
|
||||
|
||||
// zip64 end of central directory recoder fields
|
||||
static final long ZIP64_ENDTOD(byte[] b) { return LL(b, 24);} // total number of entries on disk
|
||||
static final long ZIP64_ENDTOT(byte[] b) { return LL(b, 32);} // total number of entries
|
||||
static final long ZIP64_ENDSIZ(byte[] b) { return LL(b, 40);} // central directory size
|
||||
static final long ZIP64_ENDOFF(byte[] b) { return LL(b, 48);} // central directory offset
|
||||
static final long ZIP64_LOCOFF(byte[] b) { return LL(b, 8);} // zip64 end offset
|
||||
|
||||
// central directory header (CEN) fields
|
||||
static final long CENSIG(byte[] b, int pos) { return LG(b, pos + 0); }
|
||||
static final int CENVEM(byte[] b, int pos) { return SH(b, pos + 4); }
|
||||
static final int CENVER(byte[] b, int pos) { return SH(b, pos + 6); }
|
||||
static final int CENFLG(byte[] b, int pos) { return SH(b, pos + 8); }
|
||||
static final int CENHOW(byte[] b, int pos) { return SH(b, pos + 10);}
|
||||
static final long CENTIM(byte[] b, int pos) { return LG(b, pos + 12);}
|
||||
static final long CENCRC(byte[] b, int pos) { return LG(b, pos + 16);}
|
||||
static final long CENSIZ(byte[] b, int pos) { return LG(b, pos + 20);}
|
||||
static final long CENLEN(byte[] b, int pos) { return LG(b, pos + 24);}
|
||||
static final int CENNAM(byte[] b, int pos) { return SH(b, pos + 28);}
|
||||
static final int CENEXT(byte[] b, int pos) { return SH(b, pos + 30);}
|
||||
static final int CENCOM(byte[] b, int pos) { return SH(b, pos + 32);}
|
||||
static final int CENDSK(byte[] b, int pos) { return SH(b, pos + 34);}
|
||||
static final int CENATT(byte[] b, int pos) { return SH(b, pos + 36);}
|
||||
static final long CENATX(byte[] b, int pos) { return LG(b, pos + 38);}
|
||||
static final long CENOFF(byte[] b, int pos) { return LG(b, pos + 42);}
|
||||
|
||||
// The END header is followed by a variable length comment of size < 64k.
|
||||
static final long END_MAXLEN = 0xFFFF + ENDHDR;
|
||||
static final int READBLOCKSZ = 128;
|
||||
}
|
||||
|
@ -29,5 +29,6 @@ import java.util.zip.ZipFile;
|
||||
|
||||
public interface JavaUtilZipFileAccess {
|
||||
public boolean startsWithLocHeader(ZipFile zip);
|
||||
public String[] getMetaInfEntryNames(ZipFile zip);
|
||||
}
|
||||
|
||||
|
@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 1997, 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.misc;
|
||||
import java.io.PrintStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* This class encodes a buffer into the classic: "Hexadecimal Dump" format of
|
||||
* the past. It is useful for analyzing the contents of binary buffers.
|
||||
* The format produced is as follows:
|
||||
* <pre>
|
||||
* xxxx: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff ................
|
||||
* </pre>
|
||||
* Where xxxx is the offset into the buffer in 16 byte chunks, followed
|
||||
* by ascii coded hexadecimal bytes followed by the ASCII representation of
|
||||
* the bytes or '.' if they are not valid bytes.
|
||||
*
|
||||
* @author Chuck McManis
|
||||
*/
|
||||
|
||||
public class HexDumpEncoder extends CharacterEncoder {
|
||||
|
||||
private int offset;
|
||||
private int thisLineLength;
|
||||
private int currentByte;
|
||||
private byte thisLine[] = new byte[16];
|
||||
|
||||
static void hexDigit(PrintStream p, byte x) {
|
||||
char c;
|
||||
|
||||
c = (char) ((x >> 4) & 0xf);
|
||||
if (c > 9)
|
||||
c = (char) ((c-10) + 'A');
|
||||
else
|
||||
c = (char)(c + '0');
|
||||
p.write(c);
|
||||
c = (char) (x & 0xf);
|
||||
if (c > 9)
|
||||
c = (char)((c-10) + 'A');
|
||||
else
|
||||
c = (char)(c + '0');
|
||||
p.write(c);
|
||||
}
|
||||
|
||||
protected int bytesPerAtom() {
|
||||
return (1);
|
||||
}
|
||||
|
||||
protected int bytesPerLine() {
|
||||
return (16);
|
||||
}
|
||||
|
||||
protected void encodeBufferPrefix(OutputStream o) throws IOException {
|
||||
offset = 0;
|
||||
super.encodeBufferPrefix(o);
|
||||
}
|
||||
|
||||
protected void encodeLinePrefix(OutputStream o, int len) throws IOException {
|
||||
hexDigit(pStream, (byte)((offset >>> 8) & 0xff));
|
||||
hexDigit(pStream, (byte)(offset & 0xff));
|
||||
pStream.print(": ");
|
||||
currentByte = 0;
|
||||
thisLineLength = len;
|
||||
}
|
||||
|
||||
protected void encodeAtom(OutputStream o, byte buf[], int off, int len) throws IOException {
|
||||
thisLine[currentByte] = buf[off];
|
||||
hexDigit(pStream, buf[off]);
|
||||
pStream.print(" ");
|
||||
currentByte++;
|
||||
if (currentByte == 8)
|
||||
pStream.print(" ");
|
||||
}
|
||||
|
||||
protected void encodeLineSuffix(OutputStream o) throws IOException {
|
||||
if (thisLineLength < 16) {
|
||||
for (int i = thisLineLength; i < 16; i++) {
|
||||
pStream.print(" ");
|
||||
if (i == 7)
|
||||
pStream.print(" ");
|
||||
}
|
||||
}
|
||||
pStream.print(" ");
|
||||
for (int i = 0; i < thisLineLength; i++) {
|
||||
if ((thisLine[i] < ' ') || (thisLine[i] > 'z')) {
|
||||
pStream.print(".");
|
||||
} else {
|
||||
pStream.write(thisLine[i]);
|
||||
}
|
||||
}
|
||||
pStream.println();
|
||||
offset += thisLineLength;
|
||||
}
|
||||
|
||||
}
|
@ -1,214 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2011, 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.misc;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
* Queue: implements a simple queue mechanism. Allows for enumeration of the
|
||||
* elements.
|
||||
*
|
||||
* @author Herb Jellinek
|
||||
*/
|
||||
|
||||
public class Queue<T> {
|
||||
|
||||
int length = 0;
|
||||
|
||||
QueueElement<T> head = null;
|
||||
QueueElement<T> tail = null;
|
||||
|
||||
public Queue() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue an object.
|
||||
*/
|
||||
public synchronized void enqueue(T obj) {
|
||||
|
||||
QueueElement<T> newElt = new QueueElement<>(obj);
|
||||
|
||||
if (head == null) {
|
||||
head = newElt;
|
||||
tail = newElt;
|
||||
length = 1;
|
||||
} else {
|
||||
newElt.next = head;
|
||||
head.prev = newElt;
|
||||
head = newElt;
|
||||
length++;
|
||||
}
|
||||
notify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dequeue the oldest object on the queue. Will wait indefinitely.
|
||||
*
|
||||
* @return the oldest object on the queue.
|
||||
* @exception java.lang.InterruptedException if any thread has
|
||||
* interrupted this thread.
|
||||
*/
|
||||
public T dequeue() throws InterruptedException {
|
||||
return dequeue(0L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dequeue the oldest object on the queue.
|
||||
* @param timeOut the number of milliseconds to wait for something
|
||||
* to arrive.
|
||||
*
|
||||
* @return the oldest object on the queue.
|
||||
* @exception java.lang.InterruptedException if any thread has
|
||||
* interrupted this thread.
|
||||
*/
|
||||
public synchronized T dequeue(long timeOut)
|
||||
throws InterruptedException {
|
||||
|
||||
while (tail == null) {
|
||||
wait(timeOut);
|
||||
}
|
||||
QueueElement<T> elt = tail;
|
||||
tail = elt.prev;
|
||||
if (tail == null) {
|
||||
head = null;
|
||||
} else {
|
||||
tail.next = null;
|
||||
}
|
||||
length--;
|
||||
return elt.obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the queue empty?
|
||||
* @return true if the queue is empty.
|
||||
*/
|
||||
public synchronized boolean isEmpty() {
|
||||
return (tail == null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an enumeration of the elements in Last-In, First-Out
|
||||
* order. Use the Enumeration methods on the returned object to
|
||||
* fetch the elements sequentially.
|
||||
*/
|
||||
public final synchronized Enumeration<T> elements() {
|
||||
return new LIFOQueueEnumerator<>(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an enumeration of the elements in First-In, First-Out
|
||||
* order. Use the Enumeration methods on the returned object to
|
||||
* fetch the elements sequentially.
|
||||
*/
|
||||
public final synchronized Enumeration<T> reverseElements() {
|
||||
return new FIFOQueueEnumerator<>(this);
|
||||
}
|
||||
|
||||
public synchronized void dump(String msg) {
|
||||
System.err.println(">> "+msg);
|
||||
System.err.println("["+length+" elt(s); head = "+
|
||||
(head == null ? "null" : (head.obj)+"")+
|
||||
" tail = "+(tail == null ? "null" : (tail.obj)+""));
|
||||
QueueElement<T> cursor = head;
|
||||
QueueElement<T> last = null;
|
||||
while (cursor != null) {
|
||||
System.err.println(" "+cursor);
|
||||
last = cursor;
|
||||
cursor = cursor.next;
|
||||
}
|
||||
if (last != tail) {
|
||||
System.err.println(" tail != last: "+tail+", "+last);
|
||||
}
|
||||
System.err.println("]");
|
||||
}
|
||||
}
|
||||
|
||||
final class FIFOQueueEnumerator<T> implements Enumeration<T> {
|
||||
Queue<T> queue;
|
||||
QueueElement<T> cursor;
|
||||
|
||||
FIFOQueueEnumerator(Queue<T> q) {
|
||||
queue = q;
|
||||
cursor = q.tail;
|
||||
}
|
||||
|
||||
public boolean hasMoreElements() {
|
||||
return (cursor != null);
|
||||
}
|
||||
|
||||
public T nextElement() {
|
||||
synchronized (queue) {
|
||||
if (cursor != null) {
|
||||
QueueElement<T> result = cursor;
|
||||
cursor = cursor.prev;
|
||||
return result.obj;
|
||||
}
|
||||
}
|
||||
throw new NoSuchElementException("FIFOQueueEnumerator");
|
||||
}
|
||||
}
|
||||
|
||||
final class LIFOQueueEnumerator<T> implements Enumeration<T> {
|
||||
Queue<T> queue;
|
||||
QueueElement<T> cursor;
|
||||
|
||||
LIFOQueueEnumerator(Queue<T> q) {
|
||||
queue = q;
|
||||
cursor = q.head;
|
||||
}
|
||||
|
||||
public boolean hasMoreElements() {
|
||||
return (cursor != null);
|
||||
}
|
||||
|
||||
public T nextElement() {
|
||||
synchronized (queue) {
|
||||
if (cursor != null) {
|
||||
QueueElement<T> result = cursor;
|
||||
cursor = cursor.next;
|
||||
return result.obj;
|
||||
}
|
||||
}
|
||||
throw new NoSuchElementException("LIFOQueueEnumerator");
|
||||
}
|
||||
}
|
||||
|
||||
class QueueElement<T> {
|
||||
QueueElement<T> next = null;
|
||||
QueueElement<T> prev = null;
|
||||
|
||||
T obj = null;
|
||||
|
||||
QueueElement(T obj) {
|
||||
this.obj = obj;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "QueueElement[obj="+obj+(prev == null ? " null" : " prev")+
|
||||
(next == null ? " null" : " next")+"]";
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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.misc;
|
||||
|
||||
/**
|
||||
* Requests are functor objects; that is, they provide part of the mechanism
|
||||
* for deferred function application.
|
||||
*
|
||||
* @author Steven B. Byrne
|
||||
*/
|
||||
|
||||
public abstract class Request {
|
||||
/**
|
||||
* The main task of the Request object is to be exectuted from a request
|
||||
* queue.
|
||||
*/
|
||||
public abstract void execute();
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2011, 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.misc;
|
||||
|
||||
/**
|
||||
* The request processor allows functors (Request instances) to be created
|
||||
* in arbitrary threads, and to be posted for execution in a non-restricted
|
||||
* thread.
|
||||
*
|
||||
* @author Steven B. Byrne
|
||||
*/
|
||||
|
||||
|
||||
public class RequestProcessor implements Runnable {
|
||||
|
||||
private static Queue<Request> requestQueue;
|
||||
private static Thread dispatcher;
|
||||
|
||||
/**
|
||||
* Queues a Request instance for execution by the request procesor
|
||||
* thread.
|
||||
*/
|
||||
public static void postRequest(Request req) {
|
||||
lazyInitialize();
|
||||
requestQueue.enqueue(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process requests as they are queued.
|
||||
*/
|
||||
public void run() {
|
||||
lazyInitialize();
|
||||
while (true) {
|
||||
try {
|
||||
Request req = requestQueue.dequeue();
|
||||
try {
|
||||
req.execute();
|
||||
} catch (Throwable t) {
|
||||
// do nothing at the moment...maybe report an error
|
||||
// in the future
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
// do nothing at the present time.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method initiates the request processor thread. It is safe
|
||||
* to call it after the thread has been started. It provides a way for
|
||||
* clients to deliberately control the context in which the request
|
||||
* processor thread is created
|
||||
*/
|
||||
public static synchronized void startProcessing() {
|
||||
if (dispatcher == null) {
|
||||
dispatcher = new ManagedLocalsThread(new RequestProcessor(), "Request Processor");
|
||||
dispatcher.setPriority(Thread.NORM_PRIORITY + 2);
|
||||
dispatcher.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method performs lazy initialization.
|
||||
*/
|
||||
private static synchronized void lazyInitialize() {
|
||||
if (requestQueue == null) {
|
||||
requestQueue = new Queue<Request>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -274,9 +274,6 @@ public class VM {
|
||||
// used by java.lang.Integer.IntegerCache
|
||||
props.remove("java.lang.Integer.IntegerCache.high");
|
||||
|
||||
// used by java.util.zip.ZipFile
|
||||
props.remove("sun.zip.disableMemoryMapping");
|
||||
|
||||
// used by sun.launcher.LauncherHelper
|
||||
props.remove("sun.java.launcher.diag");
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.x509.*;
|
||||
import sun.security.util.*;
|
||||
|
||||
|
@ -38,7 +38,7 @@ import sun.security.util.DerValue;
|
||||
import sun.security.util.DerInputStream;
|
||||
import sun.security.util.DerOutputStream;
|
||||
import sun.security.util.ObjectIdentifier;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
/**
|
||||
* Class supporting any PKCS9 attributes.
|
||||
|
@ -41,7 +41,7 @@ import sun.security.util.*;
|
||||
import sun.security.x509.AlgorithmId;
|
||||
import sun.security.x509.X500Name;
|
||||
import sun.security.x509.KeyUsageExtension;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
/**
|
||||
* A SignerInfo, as defined in PKCS#7's signedData type.
|
||||
|
@ -28,7 +28,7 @@ package sun.security.pkcs;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.DerInputStream;
|
||||
import sun.security.util.DerValue;
|
||||
import sun.security.x509.GeneralNames;
|
||||
|
@ -33,7 +33,7 @@ import java.security.PublicKey;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Arrays;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.x509.*;
|
||||
import sun.security.util.*;
|
||||
|
||||
|
@ -30,7 +30,7 @@ import java.security.cert.Extension;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.*;
|
||||
import sun.security.x509.PKIXExtensions;
|
||||
|
||||
|
@ -44,7 +44,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.action.GetIntegerAction;
|
||||
import sun.security.x509.*;
|
||||
import sun.security.util.*;
|
||||
|
@ -42,7 +42,7 @@ import sun.security.ssl.CipherSuite.*;
|
||||
import static sun.security.ssl.CipherSuite.*;
|
||||
import static sun.security.ssl.CipherSuite.CipherType.*;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -32,7 +32,7 @@ import javax.crypto.BadPaddingException;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import static sun.security.ssl.HandshakeMessage.*;
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ import javax.crypto.BadPaddingException;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import static sun.security.ssl.Ciphertext.RecordType;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ import java.io.PrintStream;
|
||||
import java.security.AccessController;
|
||||
import java.util.Locale;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
@ -41,7 +41,7 @@ import javax.crypto.*;
|
||||
import javax.crypto.spec.*;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
import sun.security.internal.spec.*;
|
||||
import sun.security.internal.interfaces.TlsMasterSecret;
|
||||
|
@ -33,7 +33,7 @@ import javax.crypto.BadPaddingException;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ import java.nio.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -32,7 +32,7 @@ import javax.crypto.BadPaddingException;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ import java.util.*;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
import javax.net.ssl.SSLHandshakeException;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import static sun.security.ssl.Ciphertext.RecordType;
|
||||
|
||||
/**
|
||||
|
@ -32,7 +32,7 @@ import javax.crypto.BadPaddingException;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ import java.util.Arrays;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
import javax.net.ssl.SSLHandshakeException;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -2956,7 +2956,7 @@ public final class Main {
|
||||
if (v.length == 0) {
|
||||
out.println(rb.getString(".Empty.value."));
|
||||
} else {
|
||||
new sun.misc.HexDumpEncoder().encodeBuffer(ext.getExtensionValue(), out);
|
||||
new sun.security.util.HexDumpEncoder().encodeBuffer(ext.getExtensionValue(), out);
|
||||
out.println();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,331 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2015, 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.util;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* This class encodes a buffer into the classic: "Hexadecimal Dump" format of
|
||||
* the past. It is useful for analyzing the contents of binary buffers.
|
||||
* The format produced is as follows:
|
||||
* <pre>
|
||||
* xxxx: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff ................
|
||||
* </pre>
|
||||
* Where xxxx is the offset into the buffer in 16 byte chunks, followed
|
||||
* by ascii coded hexadecimal bytes followed by the ASCII representation of
|
||||
* the bytes or '.' if they are not valid bytes.
|
||||
*
|
||||
* @author Chuck McManis
|
||||
*/
|
||||
|
||||
public class HexDumpEncoder {
|
||||
|
||||
private int offset;
|
||||
private int thisLineLength;
|
||||
private int currentByte;
|
||||
private byte thisLine[] = new byte[16];
|
||||
|
||||
static void hexDigit(PrintStream p, byte x) {
|
||||
char c;
|
||||
|
||||
c = (char) ((x >> 4) & 0xf);
|
||||
if (c > 9)
|
||||
c = (char) ((c-10) + 'A');
|
||||
else
|
||||
c = (char)(c + '0');
|
||||
p.write(c);
|
||||
c = (char) (x & 0xf);
|
||||
if (c > 9)
|
||||
c = (char)((c-10) + 'A');
|
||||
else
|
||||
c = (char)(c + '0');
|
||||
p.write(c);
|
||||
}
|
||||
|
||||
protected int bytesPerAtom() {
|
||||
return (1);
|
||||
}
|
||||
|
||||
protected int bytesPerLine() {
|
||||
return (16);
|
||||
}
|
||||
|
||||
protected void encodeBufferPrefix(OutputStream o) throws IOException {
|
||||
offset = 0;
|
||||
pStream = new PrintStream(o);
|
||||
}
|
||||
|
||||
protected void encodeLinePrefix(OutputStream o, int len) throws IOException {
|
||||
hexDigit(pStream, (byte)((offset >>> 8) & 0xff));
|
||||
hexDigit(pStream, (byte)(offset & 0xff));
|
||||
pStream.print(": ");
|
||||
currentByte = 0;
|
||||
thisLineLength = len;
|
||||
}
|
||||
|
||||
protected void encodeAtom(OutputStream o, byte buf[], int off, int len) throws IOException {
|
||||
thisLine[currentByte] = buf[off];
|
||||
hexDigit(pStream, buf[off]);
|
||||
pStream.print(" ");
|
||||
currentByte++;
|
||||
if (currentByte == 8)
|
||||
pStream.print(" ");
|
||||
}
|
||||
|
||||
protected void encodeLineSuffix(OutputStream o) throws IOException {
|
||||
if (thisLineLength < 16) {
|
||||
for (int i = thisLineLength; i < 16; i++) {
|
||||
pStream.print(" ");
|
||||
if (i == 7)
|
||||
pStream.print(" ");
|
||||
}
|
||||
}
|
||||
pStream.print(" ");
|
||||
for (int i = 0; i < thisLineLength; i++) {
|
||||
if ((thisLine[i] < ' ') || (thisLine[i] > 'z')) {
|
||||
pStream.print(".");
|
||||
} else {
|
||||
pStream.write(thisLine[i]);
|
||||
}
|
||||
}
|
||||
pStream.println();
|
||||
offset += thisLineLength;
|
||||
}
|
||||
|
||||
/** Stream that understands "printing" */
|
||||
protected PrintStream pStream;
|
||||
|
||||
/**
|
||||
* This method works around the bizarre semantics of BufferedInputStream's
|
||||
* read method.
|
||||
*/
|
||||
protected int readFully(InputStream in, byte buffer[])
|
||||
throws java.io.IOException {
|
||||
for (int i = 0; i < buffer.length; i++) {
|
||||
int q = in.read();
|
||||
if (q == -1)
|
||||
return i;
|
||||
buffer[i] = (byte)q;
|
||||
}
|
||||
return buffer.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode bytes from the input stream, and write them as text characters
|
||||
* to the output stream. This method will run until it exhausts the
|
||||
* input stream, but does not print the line suffix for a final
|
||||
* line that is shorter than bytesPerLine().
|
||||
*/
|
||||
public void encode(InputStream inStream, OutputStream outStream)
|
||||
throws IOException
|
||||
{
|
||||
int j;
|
||||
int numBytes;
|
||||
byte tmpbuffer[] = new byte[bytesPerLine()];
|
||||
|
||||
encodeBufferPrefix(outStream);
|
||||
|
||||
while (true) {
|
||||
numBytes = readFully(inStream, tmpbuffer);
|
||||
if (numBytes == 0) {
|
||||
break;
|
||||
}
|
||||
encodeLinePrefix(outStream, numBytes);
|
||||
for (j = 0; j < numBytes; j += bytesPerAtom()) {
|
||||
|
||||
if ((j + bytesPerAtom()) <= numBytes) {
|
||||
encodeAtom(outStream, tmpbuffer, j, bytesPerAtom());
|
||||
} else {
|
||||
encodeAtom(outStream, tmpbuffer, j, (numBytes)- j);
|
||||
}
|
||||
}
|
||||
if (numBytes < bytesPerLine()) {
|
||||
break;
|
||||
} else {
|
||||
encodeLineSuffix(outStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A 'streamless' version of encode that simply takes a buffer of
|
||||
* bytes and returns a string containing the encoded buffer.
|
||||
*/
|
||||
public String encode(byte aBuffer[]) {
|
||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||
ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
|
||||
String retVal = null;
|
||||
try {
|
||||
encode(inStream, outStream);
|
||||
// explicit ascii->unicode conversion
|
||||
retVal = outStream.toString("ISO-8859-1");
|
||||
} catch (Exception IOException) {
|
||||
// This should never happen.
|
||||
throw new Error("CharacterEncoder.encode internal error");
|
||||
}
|
||||
return (retVal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a byte array from the remaining bytes in this ByteBuffer.
|
||||
* <P>
|
||||
* The ByteBuffer's position will be advanced to ByteBuffer's limit.
|
||||
* <P>
|
||||
* To avoid an extra copy, the implementation will attempt to return the
|
||||
* byte array backing the ByteBuffer. If this is not possible, a
|
||||
* new byte array will be created.
|
||||
*/
|
||||
private byte [] getBytes(ByteBuffer bb) {
|
||||
/*
|
||||
* This should never return a BufferOverflowException, as we're
|
||||
* careful to allocate just the right amount.
|
||||
*/
|
||||
byte [] buf = null;
|
||||
|
||||
/*
|
||||
* If it has a usable backing byte buffer, use it. Use only
|
||||
* if the array exactly represents the current ByteBuffer.
|
||||
*/
|
||||
if (bb.hasArray()) {
|
||||
byte [] tmp = bb.array();
|
||||
if ((tmp.length == bb.capacity()) &&
|
||||
(tmp.length == bb.remaining())) {
|
||||
buf = tmp;
|
||||
bb.position(bb.limit());
|
||||
}
|
||||
}
|
||||
|
||||
if (buf == null) {
|
||||
/*
|
||||
* This class doesn't have a concept of encode(buf, len, off),
|
||||
* so if we have a partial buffer, we must reallocate
|
||||
* space.
|
||||
*/
|
||||
buf = new byte[bb.remaining()];
|
||||
|
||||
/*
|
||||
* position() automatically updated
|
||||
*/
|
||||
bb.get(buf);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* A 'streamless' version of encode that simply takes a ByteBuffer
|
||||
* and returns a string containing the encoded buffer.
|
||||
* <P>
|
||||
* The ByteBuffer's position will be advanced to ByteBuffer's limit.
|
||||
*/
|
||||
public String encode(ByteBuffer aBuffer) {
|
||||
byte [] buf = getBytes(aBuffer);
|
||||
return encode(buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode bytes from the input stream, and write them as text characters
|
||||
* to the output stream. This method will run until it exhausts the
|
||||
* input stream. It differs from encode in that it will add the
|
||||
* line at the end of a final line that is shorter than bytesPerLine().
|
||||
*/
|
||||
public void encodeBuffer(InputStream inStream, OutputStream outStream)
|
||||
throws IOException
|
||||
{
|
||||
int j;
|
||||
int numBytes;
|
||||
byte tmpbuffer[] = new byte[bytesPerLine()];
|
||||
|
||||
encodeBufferPrefix(outStream);
|
||||
|
||||
while (true) {
|
||||
numBytes = readFully(inStream, tmpbuffer);
|
||||
if (numBytes == 0) {
|
||||
break;
|
||||
}
|
||||
encodeLinePrefix(outStream, numBytes);
|
||||
for (j = 0; j < numBytes; j += bytesPerAtom()) {
|
||||
if ((j + bytesPerAtom()) <= numBytes) {
|
||||
encodeAtom(outStream, tmpbuffer, j, bytesPerAtom());
|
||||
} else {
|
||||
encodeAtom(outStream, tmpbuffer, j, (numBytes)- j);
|
||||
}
|
||||
}
|
||||
encodeLineSuffix(outStream);
|
||||
if (numBytes < bytesPerLine()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the buffer in <i>aBuffer</i> and write the encoded
|
||||
* result to the OutputStream <i>aStream</i>.
|
||||
*/
|
||||
public void encodeBuffer(byte aBuffer[], OutputStream aStream)
|
||||
throws IOException
|
||||
{
|
||||
ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
|
||||
encodeBuffer(inStream, aStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* A 'streamless' version of encode that simply takes a buffer of
|
||||
* bytes and returns a string containing the encoded buffer.
|
||||
*/
|
||||
public String encodeBuffer(byte aBuffer[]) {
|
||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||
ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
|
||||
try {
|
||||
encodeBuffer(inStream, outStream);
|
||||
} catch (Exception IOException) {
|
||||
// This should never happen.
|
||||
throw new Error("CharacterEncoder.encodeBuffer internal error");
|
||||
}
|
||||
return (outStream.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the <i>aBuffer</i> ByteBuffer and write the encoded
|
||||
* result to the OutputStream <i>aStream</i>.
|
||||
* <P>
|
||||
* The ByteBuffer's position will be advanced to ByteBuffer's limit.
|
||||
*/
|
||||
public void encodeBuffer(ByteBuffer aBuffer, OutputStream aStream)
|
||||
throws IOException
|
||||
{
|
||||
byte [] buf = getBytes(aBuffer);
|
||||
encodeBuffer(buf, aStream);
|
||||
}
|
||||
|
||||
}
|
@ -443,7 +443,7 @@ public class SignatureFileVerifier {
|
||||
|
||||
if (sfAttr != null) {
|
||||
|
||||
//sun.misc.HexDumpEncoder hex = new sun.misc.HexDumpEncoder();
|
||||
//sun.security.util.HexDumpEncoder hex = new sun.security.util.HexDumpEncoder();
|
||||
//hex.encodeBuffer(data, System.out);
|
||||
|
||||
// go through all the attributes and process *-Digest entries
|
||||
|
@ -33,7 +33,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.*;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
import sun.security.util.*;
|
||||
|
||||
@ -376,6 +376,6 @@ class UnparseableExtension extends Extension {
|
||||
@Override public String toString() {
|
||||
return super.toString() +
|
||||
"Unparseable " + name + "extension due to\n" + why + "\n\n" +
|
||||
new sun.misc.HexDumpEncoder().encodeBuffer(getExtensionValue());
|
||||
new HexDumpEncoder().encodeBuffer(getExtensionValue());
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import java.io.IOException;
|
||||
import java.lang.Integer;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Arrays;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.BitArray;
|
||||
import sun.security.util.DerOutputStream;
|
||||
import sun.security.util.DerValue;
|
||||
|
@ -30,7 +30,7 @@ import java.security.PublicKey;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.*;
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,7 @@ package sun.security.x509;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.*;
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ import java.util.*;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
import sun.security.util.*;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
/**
|
||||
* <p>Abstract class for a revoked certificate in a CRL.
|
||||
|
@ -49,7 +49,7 @@ import javax.security.auth.x500.X500Principal;
|
||||
|
||||
import sun.security.provider.X509Factory;
|
||||
import sun.security.util.*;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -41,7 +41,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import java.util.Base64;
|
||||
import sun.security.util.*;
|
||||
import sun.security.provider.X509Factory;
|
||||
|
@ -32,7 +32,7 @@ import java.security.cert.*;
|
||||
import java.util.*;
|
||||
|
||||
import sun.security.util.*;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -38,7 +38,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.*;
|
||||
|
||||
/**
|
||||
|
@ -1,406 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2015, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Native method support for java.util.zip.ZipFile
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include "jlong.h"
|
||||
#include "jvm.h"
|
||||
#include "jni.h"
|
||||
#include "jni_util.h"
|
||||
#include "zip_util.h"
|
||||
#ifdef WIN32
|
||||
#include "io_util_md.h"
|
||||
#else
|
||||
#include "io_util.h"
|
||||
#endif
|
||||
|
||||
#include "java_util_zip_ZipFile.h"
|
||||
#include "java_util_jar_JarFile.h"
|
||||
|
||||
#define DEFLATED 8
|
||||
#define STORED 0
|
||||
|
||||
static jfieldID jzfileID;
|
||||
|
||||
static int OPEN_READ = java_util_zip_ZipFile_OPEN_READ;
|
||||
static int OPEN_DELETE = java_util_zip_ZipFile_OPEN_DELETE;
|
||||
|
||||
|
||||
/*
|
||||
* Declare library specific JNI_Onload entry if static build
|
||||
*/
|
||||
DEF_STATIC_JNI_OnLoad
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_util_zip_ZipFile_initIDs(JNIEnv *env, jclass cls)
|
||||
{
|
||||
jzfileID = (*env)->GetFieldID(env, cls, "jzfile", "J");
|
||||
assert(jzfileID != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
ThrowZipException(JNIEnv *env, const char *msg)
|
||||
{
|
||||
jstring s = NULL;
|
||||
jobject x;
|
||||
|
||||
if (msg != NULL) {
|
||||
s = JNU_NewStringPlatform(env, msg);
|
||||
}
|
||||
if (s != NULL) {
|
||||
x = JNU_NewObjectByName(env,
|
||||
"java/util/zip/ZipException",
|
||||
"(Ljava/lang/String;)V", s);
|
||||
if (x != NULL) {
|
||||
(*env)->Throw(env, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_java_util_zip_ZipFile_open(JNIEnv *env, jclass cls, jstring name,
|
||||
jint mode, jlong lastModified,
|
||||
jboolean usemmap)
|
||||
{
|
||||
const char *path = JNU_GetStringPlatformChars(env, name, 0);
|
||||
char *msg = 0;
|
||||
jlong result = 0;
|
||||
int flag = 0;
|
||||
jzfile *zip = 0;
|
||||
|
||||
if (mode & OPEN_READ) flag |= O_RDONLY;
|
||||
|
||||
if (path != 0) {
|
||||
zip = ZIP_Get_From_Cache(path, &msg, lastModified);
|
||||
if (zip == 0 && msg == 0) {
|
||||
ZFILE zfd = 0;
|
||||
#ifdef WIN32
|
||||
if (mode & OPEN_DELETE) flag |= O_TEMPORARY;
|
||||
zfd = winFileHandleOpen(env, name, flag);
|
||||
if (zfd == -1) {
|
||||
/* Exception already pending. */
|
||||
goto finally;
|
||||
}
|
||||
#else
|
||||
zfd = open(path, flag, 0);
|
||||
if (zfd < 0) {
|
||||
throwFileNotFoundException(env, name);
|
||||
goto finally;
|
||||
}
|
||||
if (mode & OPEN_DELETE) {
|
||||
unlink(path);
|
||||
}
|
||||
#endif
|
||||
zip = ZIP_Put_In_Cache0(path, zfd, &msg, lastModified, usemmap);
|
||||
}
|
||||
|
||||
if (zip != 0) {
|
||||
result = ptr_to_jlong(zip);
|
||||
} else if (msg != 0) {
|
||||
ThrowZipException(env, msg);
|
||||
free(msg);
|
||||
} else if (errno == ENOMEM) {
|
||||
JNU_ThrowOutOfMemoryError(env, 0);
|
||||
} else {
|
||||
ThrowZipException(env, "error in opening zip file");
|
||||
}
|
||||
finally:
|
||||
JNU_ReleaseStringPlatformChars(env, name, path);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_java_util_zip_ZipFile_getTotal(JNIEnv *env, jclass cls, jlong zfile)
|
||||
{
|
||||
jzfile *zip = jlong_to_ptr(zfile);
|
||||
|
||||
return zip->total;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_java_util_zip_ZipFile_startsWithLOC(JNIEnv *env, jclass cls, jlong zfile)
|
||||
{
|
||||
jzfile *zip = jlong_to_ptr(zfile);
|
||||
|
||||
return zip->locsig;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_util_zip_ZipFile_close(JNIEnv *env, jclass cls, jlong zfile)
|
||||
{
|
||||
ZIP_Close(jlong_to_ptr(zfile));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_java_util_zip_ZipFile_getEntry(JNIEnv *env, jclass cls, jlong zfile,
|
||||
jbyteArray name, jboolean addSlash)
|
||||
{
|
||||
#define MAXNAME 1024
|
||||
jzfile *zip = jlong_to_ptr(zfile);
|
||||
jsize ulen = (*env)->GetArrayLength(env, name);
|
||||
char buf[MAXNAME+2], *path;
|
||||
jzentry *ze;
|
||||
|
||||
if (ulen > MAXNAME) {
|
||||
path = malloc(ulen + 2);
|
||||
if (path == 0) {
|
||||
JNU_ThrowOutOfMemoryError(env, 0);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
path = buf;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, name, 0, ulen, (jbyte *)path);
|
||||
path[ulen] = '\0';
|
||||
ze = ZIP_GetEntry2(zip, path, (jint)ulen, addSlash);
|
||||
if (path != buf) {
|
||||
free(path);
|
||||
}
|
||||
return ptr_to_jlong(ze);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_util_zip_ZipFile_freeEntry(JNIEnv *env, jclass cls, jlong zfile,
|
||||
jlong zentry)
|
||||
{
|
||||
jzfile *zip = jlong_to_ptr(zfile);
|
||||
jzentry *ze = jlong_to_ptr(zentry);
|
||||
ZIP_FreeEntry(zip, ze);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_java_util_zip_ZipFile_getNextEntry(JNIEnv *env, jclass cls, jlong zfile,
|
||||
jint n)
|
||||
{
|
||||
jzentry *ze = ZIP_GetNextEntry(jlong_to_ptr(zfile), n);
|
||||
return ptr_to_jlong(ze);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_java_util_zip_ZipFile_getEntryMethod(JNIEnv *env, jclass cls, jlong zentry)
|
||||
{
|
||||
jzentry *ze = jlong_to_ptr(zentry);
|
||||
return ze->csize != 0 ? DEFLATED : STORED;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_java_util_zip_ZipFile_getEntryFlag(JNIEnv *env, jclass cls, jlong zentry)
|
||||
{
|
||||
jzentry *ze = jlong_to_ptr(zentry);
|
||||
return ze->flag;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_java_util_zip_ZipFile_getEntryCSize(JNIEnv *env, jclass cls, jlong zentry)
|
||||
{
|
||||
jzentry *ze = jlong_to_ptr(zentry);
|
||||
return ze->csize != 0 ? ze->csize : ze->size;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_java_util_zip_ZipFile_getEntrySize(JNIEnv *env, jclass cls, jlong zentry)
|
||||
{
|
||||
jzentry *ze = jlong_to_ptr(zentry);
|
||||
return ze->size;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_java_util_zip_ZipFile_getEntryTime(JNIEnv *env, jclass cls, jlong zentry)
|
||||
{
|
||||
jzentry *ze = jlong_to_ptr(zentry);
|
||||
return (jlong)ze->time & 0xffffffffUL;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_java_util_zip_ZipFile_getEntryCrc(JNIEnv *env, jclass cls, jlong zentry)
|
||||
{
|
||||
jzentry *ze = jlong_to_ptr(zentry);
|
||||
return (jlong)ze->crc & 0xffffffffUL;
|
||||
}
|
||||
|
||||
JNIEXPORT jbyteArray JNICALL
|
||||
Java_java_util_zip_ZipFile_getCommentBytes(JNIEnv *env,
|
||||
jclass cls,
|
||||
jlong zfile)
|
||||
{
|
||||
jzfile *zip = jlong_to_ptr(zfile);
|
||||
jbyteArray jba = NULL;
|
||||
|
||||
if (zip->comment != NULL) {
|
||||
if ((jba = (*env)->NewByteArray(env, zip->clen)) == NULL)
|
||||
return NULL;
|
||||
(*env)->SetByteArrayRegion(env, jba, 0, zip->clen, (jbyte*)zip->comment);
|
||||
}
|
||||
return jba;
|
||||
}
|
||||
|
||||
JNIEXPORT jbyteArray JNICALL
|
||||
Java_java_util_zip_ZipFile_getEntryBytes(JNIEnv *env,
|
||||
jclass cls,
|
||||
jlong zentry, jint type)
|
||||
{
|
||||
jzentry *ze = jlong_to_ptr(zentry);
|
||||
int len = 0;
|
||||
jbyteArray jba = NULL;
|
||||
switch (type) {
|
||||
case java_util_zip_ZipFile_JZENTRY_NAME:
|
||||
if (ze->name != 0) {
|
||||
len = (int)ze->nlen;
|
||||
// Unlike for extra and comment, we never return null for
|
||||
// an (extremely rarely seen) empty name
|
||||
if ((jba = (*env)->NewByteArray(env, len)) == NULL)
|
||||
break;
|
||||
(*env)->SetByteArrayRegion(env, jba, 0, len, (jbyte *)ze->name);
|
||||
}
|
||||
break;
|
||||
case java_util_zip_ZipFile_JZENTRY_EXTRA:
|
||||
if (ze->extra != 0) {
|
||||
unsigned char *bp = (unsigned char *)&ze->extra[0];
|
||||
len = (bp[0] | (bp[1] << 8));
|
||||
if (len <= 0 || (jba = (*env)->NewByteArray(env, len)) == NULL)
|
||||
break;
|
||||
(*env)->SetByteArrayRegion(env, jba, 0, len, &ze->extra[2]);
|
||||
}
|
||||
break;
|
||||
case java_util_zip_ZipFile_JZENTRY_COMMENT:
|
||||
if (ze->comment != 0) {
|
||||
len = (int)strlen(ze->comment);
|
||||
if (len == 0 || (jba = (*env)->NewByteArray(env, len)) == NULL)
|
||||
break;
|
||||
(*env)->SetByteArrayRegion(env, jba, 0, len, (jbyte*)ze->comment);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return jba;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_java_util_zip_ZipFile_read(JNIEnv *env, jclass cls, jlong zfile,
|
||||
jlong zentry, jlong pos, jbyteArray bytes,
|
||||
jint off, jint len)
|
||||
{
|
||||
jzfile *zip = jlong_to_ptr(zfile);
|
||||
char *msg;
|
||||
|
||||
#define BUFSIZE 8192
|
||||
/* copy via tmp stack buffer: */
|
||||
jbyte buf[BUFSIZE];
|
||||
|
||||
if (len > BUFSIZE) {
|
||||
len = BUFSIZE;
|
||||
}
|
||||
|
||||
ZIP_Lock(zip);
|
||||
len = ZIP_Read(zip, jlong_to_ptr(zentry), pos, buf, len);
|
||||
msg = zip->msg;
|
||||
ZIP_Unlock(zip);
|
||||
if (len != -1) {
|
||||
(*env)->SetByteArrayRegion(env, bytes, off, len, buf);
|
||||
}
|
||||
|
||||
if (len == -1) {
|
||||
if (msg != 0) {
|
||||
ThrowZipException(env, msg);
|
||||
} else {
|
||||
char errmsg[128];
|
||||
sprintf(errmsg, "errno: %d, error: %s\n",
|
||||
errno, "Error reading ZIP file");
|
||||
JNU_ThrowIOExceptionWithLastError(env, errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns an array of strings representing the names of all entries
|
||||
* that begin with "META-INF/" (case ignored). This native method is
|
||||
* used in JarFile as an optimization when looking up manifest and
|
||||
* signature file entries. Returns null if no entries were found.
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL
|
||||
Java_java_util_jar_JarFile_getMetaInfEntryNames(JNIEnv *env, jobject obj)
|
||||
{
|
||||
jlong zfile = (*env)->GetLongField(env, obj, jzfileID);
|
||||
jzfile *zip;
|
||||
int i, count;
|
||||
jobjectArray result = 0;
|
||||
|
||||
if (zfile == 0) {
|
||||
JNU_ThrowByName(env,
|
||||
"java/lang/IllegalStateException", "zip file closed");
|
||||
return NULL;
|
||||
}
|
||||
zip = jlong_to_ptr(zfile);
|
||||
|
||||
/* count the number of valid ZIP metanames */
|
||||
count = 0;
|
||||
if (zip->metanames != 0) {
|
||||
for (i = 0; i < zip->metacount; i++) {
|
||||
if (zip->metanames[i] != 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If some names were found then build array of java strings */
|
||||
if (count > 0) {
|
||||
jclass cls = JNU_ClassString(env);
|
||||
CHECK_NULL_RETURN(cls, NULL);
|
||||
result = (*env)->NewObjectArray(env, count, cls, 0);
|
||||
CHECK_NULL_RETURN(result, NULL);
|
||||
if (result != 0) {
|
||||
for (i = 0; i < count; i++) {
|
||||
jstring str = (*env)->NewStringUTF(env, zip->metanames[i]);
|
||||
if (str == 0) {
|
||||
break;
|
||||
}
|
||||
(*env)->SetObjectArrayElement(env, result, i, str);
|
||||
(*env)->DeleteLocalRef(env, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_java_util_zip_ZipFile_getZipMessage(JNIEnv *env, jclass cls, jlong zfile)
|
||||
{
|
||||
jzfile *zip = jlong_to_ptr(zfile);
|
||||
char *msg = zip->msg;
|
||||
if (msg == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return JNU_NewStringPlatform(env, msg);
|
||||
}
|
@ -38,6 +38,7 @@ import java.net.URL;
|
||||
import java.security.*;
|
||||
import java.util.*;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.EmbeddedFrame;
|
||||
@ -45,7 +46,6 @@ import sun.awt.SunToolkit;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.misc.MessageUtils;
|
||||
import sun.misc.PerformanceLogger;
|
||||
import sun.misc.Queue;
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
/**
|
||||
@ -247,8 +247,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
|
||||
/**
|
||||
* AppletEvent Queue
|
||||
*/
|
||||
private Queue<Integer> queue = null;
|
||||
|
||||
private LinkedBlockingQueue<Integer> queue = null;
|
||||
|
||||
public synchronized void addAppletListener(AppletListener l) {
|
||||
listeners = AppletEventMulticaster.add(listeners, l);
|
||||
@ -276,10 +275,9 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
|
||||
synchronized(this) {
|
||||
if (queue == null) {
|
||||
//System.out.println("SEND0= " + id);
|
||||
queue = new Queue<>();
|
||||
queue = new LinkedBlockingQueue<>();
|
||||
}
|
||||
Integer eventId = Integer.valueOf(id);
|
||||
queue.enqueue(eventId);
|
||||
boolean inserted = queue.add(id);
|
||||
notifyAll();
|
||||
}
|
||||
if (id == APPLET_QUIT) {
|
||||
@ -303,8 +301,8 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
|
||||
while (queue == null || queue.isEmpty()) {
|
||||
wait();
|
||||
}
|
||||
Integer eventId = queue.dequeue();
|
||||
return new AppletEvent(this, eventId.intValue(), null);
|
||||
int eventId = queue.take();
|
||||
return new AppletEvent(this, eventId, null);
|
||||
}
|
||||
|
||||
boolean emptyEventQueue() {
|
||||
|
@ -156,8 +156,6 @@ public final class MarlinCache implements MarlinConst {
|
||||
// rewritten to avoid division:
|
||||
|| (width * heightSubPixel) >
|
||||
((edgeSumDeltaY - heightSubPixel) << BLOCK_SIZE_LG);
|
||||
// ((edgeSumDeltaY - heightSubPixel) * RLE_THRESHOLD);
|
||||
// ((edgeSumDeltaY - heightSubPixel) << BLOCK_TH_LG);
|
||||
|
||||
if (doTrace && !useRLE) {
|
||||
final float meanCrossings
|
||||
@ -293,8 +291,10 @@ public final class MarlinCache implements MarlinConst {
|
||||
// update row index to current position:
|
||||
rowAAChunkIndex[row] = pos;
|
||||
|
||||
// determine need array size (may overflow):
|
||||
final long needSize = pos + (px_bbox1 - px0);
|
||||
// determine need array size:
|
||||
// for RLE encoding, position must be aligned to 4 bytes (int):
|
||||
// align - 1 = 3 so add +3 and round-off by mask ~3 = -4
|
||||
final long needSize = pos + ((px_bbox1 - px0 + 3) & -4);
|
||||
|
||||
// update next position (bytes):
|
||||
rowAAChunkPos = needSize;
|
||||
@ -401,8 +401,7 @@ public final class MarlinCache implements MarlinConst {
|
||||
|
||||
// determine need array size:
|
||||
// pessimistic: max needed size = deltaX x 4 (1 int)
|
||||
final int maxLen = (to - from);
|
||||
final long needSize = initialPos + (maxLen << 2);
|
||||
final long needSize = initialPos + ((to - from) << 2);
|
||||
|
||||
// update row data:
|
||||
OffHeapArray _rowAAChunk = rowAAChunk;
|
||||
@ -465,6 +464,13 @@ public final class MarlinCache implements MarlinConst {
|
||||
// note: last pixel exclusive (>= 0)
|
||||
// note: it should check X is smaller than 23bits (overflow)!
|
||||
|
||||
// check address alignment to 4 bytes:
|
||||
if (doCheckUnsafe) {
|
||||
if ((addr_off & 3) != 0) {
|
||||
MarlinUtils.logInfo("Misaligned Unsafe address: " + addr_off);
|
||||
}
|
||||
}
|
||||
|
||||
// special case to encode entries into a single int:
|
||||
if (val == 0) {
|
||||
_unsafe.putInt(addr_off,
|
||||
@ -521,6 +527,13 @@ public final class MarlinCache implements MarlinConst {
|
||||
// note: last pixel exclusive (>= 0)
|
||||
// note: it should check X is smaller than 23bits (overflow)!
|
||||
|
||||
// check address alignment to 4 bytes:
|
||||
if (doCheckUnsafe) {
|
||||
if ((addr_off & 3) != 0) {
|
||||
MarlinUtils.logInfo("Misaligned Unsafe address: " + addr_off);
|
||||
}
|
||||
}
|
||||
|
||||
// special case to encode entries into a single int:
|
||||
if (val == 0) {
|
||||
_unsafe.putInt(addr_off,
|
||||
|
@ -40,6 +40,8 @@ interface MarlinConst {
|
||||
// log misc.Unsafe alloc/realloc/free
|
||||
static final boolean logUnsafeMalloc = enableLogs
|
||||
&& MarlinProperties.isLogUnsafeMalloc();
|
||||
// do check unsafe alignment:
|
||||
static final boolean doCheckUnsafe = false;
|
||||
|
||||
// do statistics
|
||||
static final boolean doStats = enableLogs && MarlinProperties.isDoStats();
|
||||
|
@ -29,7 +29,7 @@ import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
/**
|
||||
* Base class that defines common fields, constants, and debug method.
|
||||
|
@ -44,7 +44,7 @@ import javax.naming.ldap.InitialLdapContext;
|
||||
import javax.naming.ldap.LdapContext;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.provider.certpath.X509CertificatePair;
|
||||
import sun.security.util.Cache;
|
||||
import sun.security.util.Debug;
|
||||
|
@ -34,7 +34,7 @@ import javax.security.auth.Refreshable;
|
||||
import javax.security.auth.Destroyable;
|
||||
import javax.security.auth.RefreshFailedException;
|
||||
import javax.security.auth.DestroyFailedException;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
/**
|
||||
* This class encapsulates a Kerberos ticket and associated
|
||||
|
@ -30,7 +30,7 @@ import java.util.Arrays;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.security.auth.Destroyable;
|
||||
import javax.security.auth.DestroyFailedException;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.krb5.Asn1Exception;
|
||||
import sun.security.krb5.PrincipalName;
|
||||
import sun.security.krb5.EncryptionKey;
|
||||
|
@ -26,7 +26,7 @@
|
||||
package sun.security.jgss.krb5;
|
||||
|
||||
import org.ietf.jgss.*;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.jgss.GSSUtil;
|
||||
import sun.security.jgss.GSSCaller;
|
||||
import sun.security.jgss.spi.*;
|
||||
@ -1415,7 +1415,7 @@ class Krb5Context implements GSSContextSpi {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Kerberos session key: etype: " + key.getEType() + "\n" +
|
||||
new sun.misc.HexDumpEncoder().encodeBuffer(key.getBytes());
|
||||
new HexDumpEncoder().encodeBuffer(key.getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,7 +227,7 @@ public class KRBError implements java.io.Serializable {
|
||||
} catch (Exception e) {
|
||||
if (DEBUG) {
|
||||
System.out.println("Unable to parse eData field of KRB-ERROR:\n" +
|
||||
new sun.misc.HexDumpEncoder().encodeBuffer(data));
|
||||
new sun.security.util.HexDumpEncoder().encodeBuffer(data));
|
||||
}
|
||||
IOException ioe = new IOException(
|
||||
"Unable to parse eData field of KRB-ERROR");
|
||||
@ -237,7 +237,7 @@ public class KRBError implements java.io.Serializable {
|
||||
} else {
|
||||
if (DEBUG) {
|
||||
System.out.println("Unknown eData field of KRB-ERROR:\n" +
|
||||
new sun.misc.HexDumpEncoder().encodeBuffer(data));
|
||||
new sun.security.util.HexDumpEncoder().encodeBuffer(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,8 +306,8 @@ public class Krb5 {
|
||||
public static final boolean DEBUG =
|
||||
java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetBooleanAction("sun.security.krb5.debug"));
|
||||
public static final sun.misc.HexDumpEncoder hexDumper =
|
||||
new sun.misc.HexDumpEncoder();
|
||||
public static final sun.security.util.HexDumpEncoder hexDumper =
|
||||
new sun.security.util.HexDumpEncoder();
|
||||
|
||||
static {
|
||||
errMsgList = new Hashtable<Integer,String> ();
|
||||
|
@ -306,7 +306,7 @@ public class PAData {
|
||||
} else if (s2kparams.length == 0) {
|
||||
sb.append("empty\n");
|
||||
} else {
|
||||
sb.append(new sun.misc.HexDumpEncoder()
|
||||
sb.append(new sun.security.util.HexDumpEncoder()
|
||||
.encodeBuffer(s2kparams));
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.krb5.Confounder;
|
||||
import sun.security.krb5.internal.crypto.KeyUsage;
|
||||
import sun.security.krb5.KrbCryptoException;
|
||||
|
@ -33,7 +33,7 @@ import java.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
/**
|
||||
* The base class used by client and server implementations of SASL
|
||||
|
@ -44,7 +44,7 @@ import javax.security.auth.spi.*;
|
||||
import sun.security.krb5.*;
|
||||
import sun.security.jgss.krb5.Krb5Util;
|
||||
import sun.security.krb5.Credentials;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
/**
|
||||
* This {@code LoginModule} authenticates users using
|
||||
|
@ -64,6 +64,6 @@ public final class AuthorizationDataEntry {
|
||||
public String toString() {
|
||||
return "AuthorizationDataEntry: type="+type+", data=" +
|
||||
data.length + " bytes:\n" +
|
||||
new sun.misc.HexDumpEncoder().encodeBuffer(data);
|
||||
new sun.security.util.HexDumpEncoder().encodeBuffer(data);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
* @test
|
||||
* @bug 7146728
|
||||
* @summary DHKeyAgreement2
|
||||
* @modules java.base/sun.misc
|
||||
* @author Jan Luehe
|
||||
*/
|
||||
|
||||
@ -38,8 +37,6 @@ import javax.crypto.*;
|
||||
import javax.crypto.spec.*;
|
||||
import javax.crypto.interfaces.*;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
|
||||
/**
|
||||
* This test utility executes the Diffie-Hellman key agreement protocol
|
||||
* between 2 parties: Alice and Bob.
|
||||
|
@ -164,7 +164,7 @@ public class Base64Test {
|
||||
private static void deserialize(byte[] bytes) throws Exception {
|
||||
|
||||
//System.out.println("\nSerialized RefAddr object: ");
|
||||
//System.out.println(new sun.misc.HexDumpEncoder().encode(bytes));
|
||||
//System.out.println(new sun.security.util.HexDumpEncoder().encode(bytes));
|
||||
|
||||
ObjectInputStream objectStream =
|
||||
new ObjectInputStream(new ByteArrayInputStream(bytes));
|
||||
|
@ -25,13 +25,14 @@
|
||||
* @test
|
||||
* @bug 6911951 7150092
|
||||
* @summary NTLM should be a supported Java SASL mechanism
|
||||
* @modules java.base/sun.misc
|
||||
* @modules java.base/sun.security.util
|
||||
* java.security.sasl
|
||||
*/
|
||||
import java.io.IOException;
|
||||
import javax.security.sasl.*;
|
||||
import javax.security.auth.callback.*;
|
||||
import java.util.*;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
public class NTLMTest {
|
||||
|
||||
@ -311,7 +312,7 @@ public class NTLMTest {
|
||||
byte[] response = (clnt.hasInitialResponse()
|
||||
? clnt.evaluateChallenge(EMPTY) : EMPTY);
|
||||
System.out.println("Initial:");
|
||||
new sun.misc.HexDumpEncoder().encodeBuffer(response, System.out);
|
||||
new HexDumpEncoder().encodeBuffer(response, System.out);
|
||||
byte[] challenge;
|
||||
|
||||
while (!clnt.isComplete() || !srv.isComplete()) {
|
||||
@ -319,12 +320,12 @@ public class NTLMTest {
|
||||
response = null;
|
||||
if (challenge != null) {
|
||||
System.out.println("Challenge:");
|
||||
new sun.misc.HexDumpEncoder().encodeBuffer(challenge, System.out);
|
||||
new HexDumpEncoder().encodeBuffer(challenge, System.out);
|
||||
response = clnt.evaluateChallenge(challenge);
|
||||
}
|
||||
if (response != null) {
|
||||
System.out.println("Response:");
|
||||
new sun.misc.HexDumpEncoder().encodeBuffer(response, System.out);
|
||||
new HexDumpEncoder().encodeBuffer(response, System.out);
|
||||
}
|
||||
}
|
||||
|
||||
|
120
jdk/test/java/text/Format/DateFormat/Bug8139572.java
Normal file
120
jdk/test/java/text/Format/DateFormat/Bug8139572.java
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8139572
|
||||
* @summary SimpleDateFormat parse month stand-alone format bug
|
||||
* @compile -encoding utf-8 Bug8139572.java
|
||||
* @run main Bug8139572
|
||||
*/
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Bug8139572 {
|
||||
|
||||
private static final Locale RUSSIAN = new Locale("ru");
|
||||
private static final Date SEPT12 = new GregorianCalendar(2015, Calendar.SEPTEMBER, 12).getTime();
|
||||
|
||||
private static final String[] PATTERNS = {
|
||||
"L",
|
||||
"dd L",
|
||||
"dd L yy",
|
||||
"dd L yyyy",
|
||||
"LL",
|
||||
"dd LL",
|
||||
"dd LL yy",
|
||||
"dd LL yyyy",
|
||||
"LLL",
|
||||
"dd LLL",
|
||||
"dd LLL yy",
|
||||
"dd LLL yyyy",
|
||||
"LLLL",
|
||||
"dd LLLL",
|
||||
"dd LLLL yy",
|
||||
"dd LLLL yyyy"
|
||||
};
|
||||
|
||||
private static final String[] APPLIED = {
|
||||
"9",
|
||||
"12 09",
|
||||
"12 09 15",
|
||||
"12 09 2015",
|
||||
"09",
|
||||
"12 09",
|
||||
"12 09 15",
|
||||
"12 09 2015",
|
||||
"сентября",
|
||||
"12 сентября",
|
||||
"12 сентября 15",
|
||||
"12 сентября 2015",
|
||||
"сентября",
|
||||
"12 сентября",
|
||||
"12 сентября 15",
|
||||
"12 сентября 2015"
|
||||
};
|
||||
|
||||
private static final String[] EXPECTED = {
|
||||
"9",
|
||||
"12 9",
|
||||
"12 9 15",
|
||||
"12 9 2015",
|
||||
"09",
|
||||
"12 09",
|
||||
"12 09 15",
|
||||
"12 09 2015",
|
||||
"сент.",
|
||||
"12 сент.",
|
||||
"12 сент. 15",
|
||||
"12 сент. 2015",
|
||||
"сентябрь",
|
||||
"12 сентябрь",
|
||||
"12 сентябрь 15",
|
||||
"12 сентябрь 2015"
|
||||
};
|
||||
|
||||
public static void main(String[] args) throws ParseException {
|
||||
|
||||
for (int i = 0; i < PATTERNS.length; i++) {
|
||||
SimpleDateFormat fmt = new SimpleDateFormat(PATTERNS[i], RUSSIAN);
|
||||
Date standAloneDate = fmt.parse(APPLIED[i]);
|
||||
String str = fmt.format(standAloneDate);
|
||||
if (!EXPECTED[i].equals(str)) {
|
||||
throw new RuntimeException("bad result: got '" + str + "', expected '" + EXPECTED[i] + "'");
|
||||
}
|
||||
}
|
||||
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("", RUSSIAN);
|
||||
for (int j = 0; j < PATTERNS.length; j++) {
|
||||
fmt.applyPattern(PATTERNS[j]);
|
||||
String str = fmt.format(SEPT12);
|
||||
if (!EXPECTED[j].equals(str)) {
|
||||
throw new RuntimeException("bad result: got '" + str + "', expected '" + EXPECTED[j] + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8016846 8024341 8071479
|
||||
* @bug 8016846 8024341 8071479 8145006
|
||||
* @summary Unit tests stream and lambda-based methods on Pattern and Matcher
|
||||
* @library ../stream/bootlib/java.base
|
||||
* @build java.util.stream.OpTestCase
|
||||
@ -42,6 +42,7 @@ import java.util.function.Supplier;
|
||||
import java.util.regex.MatchResult;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.LambdaTestHelpers;
|
||||
import java.util.stream.OpTestCase;
|
||||
import java.util.stream.Stream;
|
||||
@ -185,6 +186,20 @@ public class PatternStreamTest extends OpTestCase {
|
||||
.exercise();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLateBinding() {
|
||||
Pattern pattern = Pattern.compile(",");
|
||||
|
||||
StringBuilder sb = new StringBuilder("a,b,c,d,e");
|
||||
Stream<String> stream = pattern.splitAsStream(sb);
|
||||
sb.setLength(3);
|
||||
assertEquals(Arrays.asList("a", "b"), stream.collect(Collectors.toList()));
|
||||
|
||||
stream = pattern.splitAsStream(sb);
|
||||
sb.append(",f,g");
|
||||
assertEquals(Arrays.asList("a", "b", "f", "g"), stream.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public void testFailfastMatchResults() {
|
||||
Pattern p = Pattern.compile("X");
|
||||
Matcher m = p.matcher("XX");
|
||||
|
@ -56,6 +56,7 @@ import org.testng.annotations.Test;
|
||||
|
||||
import static java.util.stream.Collectors.collectingAndThen;
|
||||
import static java.util.stream.Collectors.flatMapping;
|
||||
import static java.util.stream.Collectors.filtering;
|
||||
import static java.util.stream.Collectors.groupingBy;
|
||||
import static java.util.stream.Collectors.groupingByConcurrent;
|
||||
import static java.util.stream.Collectors.mapping;
|
||||
@ -72,7 +73,7 @@ import static java.util.stream.LambdaTestHelpers.mDoubler;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8071600
|
||||
* @bug 8071600 8144675
|
||||
* @summary Test for collectors.
|
||||
*/
|
||||
public class CollectorsTest extends OpTestCase {
|
||||
@ -118,6 +119,23 @@ public class CollectorsTest extends OpTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
static class FilteringAssertion<T, R> extends CollectorAssertion<T, R> {
|
||||
private final Predicate<T> filter;
|
||||
private final CollectorAssertion<T, R> downstream;
|
||||
|
||||
public FilteringAssertion(Predicate<T> filter, CollectorAssertion<T, R> downstream) {
|
||||
this.filter = filter;
|
||||
this.downstream = downstream;
|
||||
}
|
||||
|
||||
@Override
|
||||
void assertValue(R value, Supplier<Stream<T>> source, boolean ordered) throws ReflectiveOperationException {
|
||||
downstream.assertValue(value,
|
||||
() -> source.get().filter(filter),
|
||||
ordered);
|
||||
}
|
||||
}
|
||||
|
||||
static class GroupingByAssertion<T, K, V, M extends Map<K, ? extends V>> extends CollectorAssertion<T, M> {
|
||||
private final Class<? extends Map> clazz;
|
||||
private final Function<T, K> classifier;
|
||||
@ -550,6 +568,36 @@ public class CollectorsTest extends OpTestCase {
|
||||
new ToListAssertion<>())));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class)
|
||||
public void testGroupingByWithFiltering(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException {
|
||||
Function<Integer, Integer> classifier = i -> i % 3;
|
||||
Predicate<Integer> filteringByMod2 = i -> i % 2 == 0;
|
||||
Predicate<Integer> filteringByUnder100 = i -> i % 2 < 100;
|
||||
Predicate<Integer> filteringByTrue = i -> true;
|
||||
Predicate<Integer> filteringByFalse = i -> false;
|
||||
|
||||
exerciseMapCollection(data,
|
||||
groupingBy(classifier, filtering(filteringByMod2, toList())),
|
||||
new GroupingByAssertion<>(classifier, HashMap.class,
|
||||
new FilteringAssertion<>(filteringByMod2,
|
||||
new ToListAssertion<>())));
|
||||
exerciseMapCollection(data,
|
||||
groupingBy(classifier, filtering(filteringByUnder100, toList())),
|
||||
new GroupingByAssertion<>(classifier, HashMap.class,
|
||||
new FilteringAssertion<>(filteringByUnder100,
|
||||
new ToListAssertion<>())));
|
||||
exerciseMapCollection(data,
|
||||
groupingBy(classifier, filtering(filteringByTrue, toList())),
|
||||
new GroupingByAssertion<>(classifier, HashMap.class,
|
||||
new FilteringAssertion<>(filteringByTrue,
|
||||
new ToListAssertion<>())));
|
||||
exerciseMapCollection(data,
|
||||
groupingBy(classifier, filtering(filteringByFalse, toList())),
|
||||
new GroupingByAssertion<>(classifier, HashMap.class,
|
||||
new FilteringAssertion<>(filteringByFalse,
|
||||
new ToListAssertion<>())));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class)
|
||||
public void testTwoLevelGroupingBy(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException {
|
||||
Function<Integer, Integer> classifier = i -> i % 6;
|
||||
|
@ -84,9 +84,10 @@ public class TestZipError {
|
||||
try {
|
||||
while (entries.hasMoreElements()) {
|
||||
ze = entries.nextElement();
|
||||
zf.getInputStream(ze).readAllBytes();
|
||||
}
|
||||
fail("Did not get expected exception");
|
||||
} catch (ZipError e) {
|
||||
} catch (ZipException e) {
|
||||
pass();
|
||||
} catch (InternalError e) {
|
||||
fail("Caught InternalError instead of expected ZipError");
|
||||
|
@ -30,6 +30,7 @@
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.zip.*;
|
||||
@ -110,6 +111,6 @@ public class ReadZip {
|
||||
"input"
|
||||
+ String.valueOf(new java.util.Random().nextInt())
|
||||
+ ".zip")));
|
||||
} catch (FileNotFoundException fnfe) {}
|
||||
} catch (NoSuchFileException nsfe) {}
|
||||
}
|
||||
}
|
||||
|
361
jdk/test/java/util/zip/ZipFile/TestZipFile.java
Normal file
361
jdk/test/java/util/zip/ZipFile/TestZipFile.java
Normal file
@ -0,0 +1,361 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8142508
|
||||
* @summary Tests various ZipFile apis
|
||||
* @run main/manual TestZipFile
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.*;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
public class TestZipFile {
|
||||
|
||||
private static Random r = new Random();
|
||||
private static int N = 50;
|
||||
private static int NN = 10;
|
||||
private static int ENUM = 10000;
|
||||
private static int ESZ = 10000;
|
||||
private static ExecutorService executor = Executors.newFixedThreadPool(20);
|
||||
private static Set<Path> paths = new HashSet<>();
|
||||
|
||||
static void realMain (String[] args) throws Throwable {
|
||||
|
||||
try {
|
||||
for (int i = 0; i < N; i++) {
|
||||
test(r.nextInt(ENUM), r.nextInt(ESZ), false, true);
|
||||
test(r.nextInt(ENUM), r.nextInt(ESZ), true, true);
|
||||
}
|
||||
|
||||
for (int i = 0; i < NN; i++) {
|
||||
test(r.nextInt(ENUM), 100000 + r.nextInt(ESZ), false, true);
|
||||
test(r.nextInt(ENUM), 100000 + r.nextInt(ESZ), true, true);
|
||||
testCachedDelete();
|
||||
testCachedOverwrite();
|
||||
//test(r.nextInt(ENUM), r.nextInt(ESZ), false, true);
|
||||
}
|
||||
|
||||
test(70000, 1000, false, true); // > 65536 entry number;
|
||||
testDelete(); // OPEN_DELETE
|
||||
|
||||
executor.shutdown();
|
||||
executor.awaitTermination(10, TimeUnit.MINUTES);
|
||||
} finally {
|
||||
for (Path path : paths) {
|
||||
Files.deleteIfExists(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test(int numEntry, int szMax, boolean addPrefix, boolean cleanOld) {
|
||||
String name = "zftest" + r.nextInt() + ".zip";
|
||||
Zip zip = new Zip(name, numEntry, szMax, addPrefix, cleanOld);
|
||||
for (int i = 0; i < NN; i++) {
|
||||
executor.submit(() -> doTest(zip));
|
||||
}
|
||||
}
|
||||
|
||||
// test scenario:
|
||||
// (1) open the ZipFile(zip) with OPEN_READ | OPEN_DELETE
|
||||
// (2) test the ZipFile works correctly
|
||||
// (3) check the zip is deleted after ZipFile gets closed
|
||||
static void testDelete() throws Throwable {
|
||||
String name = "zftest" + r.nextInt() + ".zip";
|
||||
Zip zip = new Zip(name, r.nextInt(ENUM), r.nextInt(ESZ), false, true);
|
||||
try (ZipFile zf = new ZipFile(new File(zip.name),
|
||||
ZipFile.OPEN_READ | ZipFile.OPEN_DELETE ))
|
||||
{
|
||||
doTest0(zip, zf);
|
||||
}
|
||||
Path p = Paths.get(name);
|
||||
if (Files.exists(p)) {
|
||||
fail("Failed to delete " + name + " with OPEN_DELETE");
|
||||
}
|
||||
}
|
||||
|
||||
// test scenario:
|
||||
// (1) keep a ZipFile(zip1) alive (in ZipFile's cache), dont close it
|
||||
// (2) delete zip1 and create zip2 with the same name the zip1 with zip2
|
||||
// (3) zip1 tests should fail, but no crash
|
||||
// (4) zip2 tasks should all get zip2, then pass normal testing.
|
||||
static void testCachedDelete() throws Throwable {
|
||||
String name = "zftest" + r.nextInt() + ".zip";
|
||||
Zip zip1 = new Zip(name, r.nextInt(ENUM), r.nextInt(ESZ), false, true);
|
||||
|
||||
try (ZipFile zf = new ZipFile(zip1.name)) {
|
||||
for (int i = 0; i < NN; i++) {
|
||||
executor.submit(() -> verifyNoCrash(zip1));
|
||||
}
|
||||
// delete the "zip1" and create a new one to test
|
||||
Zip zip2 = new Zip(name, r.nextInt(ENUM), r.nextInt(ESZ), false, true);
|
||||
/*
|
||||
System.out.println("========================================");
|
||||
System.out.printf(" zip1=%s, mt=%d, enum=%d%n ->attrs=[key=%s, sz=%d, mt=%d]%n",
|
||||
zip1.name, zip1.lastModified, zip1.entries.size(),
|
||||
zip1.attrs.fileKey(), zip1.attrs.size(), zip1.attrs.lastModifiedTime().toMillis());
|
||||
System.out.printf(" zip2=%s, mt=%d, enum=%d%n ->attrs=[key=%s, sz=%d, mt=%d]%n",
|
||||
zip2.name, zip2.lastModified, zip2.entries.size(),
|
||||
zip2.attrs.fileKey(), zip2.attrs.size(), zip2.attrs.lastModifiedTime().toMillis());
|
||||
*/
|
||||
for (int i = 0; i < NN; i++) {
|
||||
executor.submit(() -> doTest(zip2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// overwrite the "zip1" and create a new one to test. So the two zip files
|
||||
// have the same fileKey, but probably different lastModified()
|
||||
static void testCachedOverwrite() throws Throwable {
|
||||
String name = "zftest" + r.nextInt() + ".zip";
|
||||
Zip zip1 = new Zip(name, r.nextInt(ENUM), r.nextInt(ESZ), false, true);
|
||||
try (ZipFile zf = new ZipFile(zip1.name)) {
|
||||
for (int i = 0; i < NN; i++) {
|
||||
executor.submit(() -> verifyNoCrash(zip1));
|
||||
}
|
||||
// overwrite the "zip1" with new contents
|
||||
Zip zip2 = new Zip(name, r.nextInt(ENUM), r.nextInt(ESZ), false, false);
|
||||
for (int i = 0; i < NN; i++) {
|
||||
executor.submit(() -> doTest(zip2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// just check the entries and contents. since the file has been either overwritten
|
||||
// or deleted/rewritten, we only care if it crahes or not.
|
||||
static void verifyNoCrash(Zip zip) throws RuntimeException {
|
||||
try (ZipFile zf = new ZipFile(zip.name)) {
|
||||
List<ZipEntry> zlist = new ArrayList(zip.entries.keySet());
|
||||
String[] elist = zf.stream().map( e -> e.getName()).toArray(String[]::new);
|
||||
if (!Arrays.equals(elist,
|
||||
zlist.stream().map( e -> e.getName()).toArray(String[]::new)))
|
||||
{
|
||||
//System.out.printf("++++++ LIST NG [%s] entries.len=%d, expected=%d+++++++%n",
|
||||
// zf.getName(), elist.length, zlist.size());
|
||||
return;
|
||||
}
|
||||
for (ZipEntry ze : zlist) {
|
||||
byte[] zdata = zip.entries.get(ze);
|
||||
ZipEntry e = zf.getEntry(ze.getName());
|
||||
if (e != null) {
|
||||
checkEqual(e, ze);
|
||||
if (!e.isDirectory()) {
|
||||
// check with readAllBytes
|
||||
try (InputStream is = zf.getInputStream(e)) {
|
||||
if (!Arrays.equals(zdata, is.readAllBytes())) {
|
||||
//System.out.printf("++++++ BYTES NG [%s]/[%s] ++++++++%n",
|
||||
// zf.getName(), ze.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// t.printStackTrace();
|
||||
// fail(t.toString());
|
||||
}
|
||||
}
|
||||
|
||||
static void checkEqual(ZipEntry x, ZipEntry y) {
|
||||
if (x.getName().equals(y.getName()) &&
|
||||
x.isDirectory() == y.isDirectory() &&
|
||||
x.getMethod() == y.getMethod() &&
|
||||
(x.getTime() / 2000) == y.getTime() / 2000 &&
|
||||
x.getSize() == y.getSize() &&
|
||||
x.getCompressedSize() == y.getCompressedSize() &&
|
||||
x.getCrc() == y.getCrc() &&
|
||||
x.getComment().equals(y.getComment())
|
||||
) {
|
||||
pass();
|
||||
} else {
|
||||
fail(x + " not equal to " + y);
|
||||
System.out.printf(" %s %s%n", x.getName(), y.getName());
|
||||
System.out.printf(" %d %d%n", x.getMethod(), y.getMethod());
|
||||
System.out.printf(" %d %d%n", x.getTime(), y.getTime());
|
||||
System.out.printf(" %d %d%n", x.getSize(), y.getSize());
|
||||
System.out.printf(" %d %d%n", x.getCompressedSize(), y.getCompressedSize());
|
||||
System.out.printf(" %d %d%n", x.getCrc(), y.getCrc());
|
||||
System.out.println("-----------------");
|
||||
}
|
||||
}
|
||||
|
||||
static void doTest(Zip zip) throws RuntimeException {
|
||||
//Thread me = Thread.currentThread();
|
||||
try (ZipFile zf = new ZipFile(zip.name)) {
|
||||
doTest0(zip, zf);
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
|
||||
static void doTest0(Zip zip, ZipFile zf) throws Throwable {
|
||||
List<ZipEntry> list = new ArrayList(zip.entries.keySet());
|
||||
// (1) check entry list, in expected order
|
||||
if (!check(Arrays.equals(
|
||||
list.stream().map( e -> e.getName()).toArray(String[]::new),
|
||||
zf.stream().map( e -> e.getName()).toArray(String[]::new)))) {
|
||||
return;
|
||||
}
|
||||
// (2) shuffle, and check each entry and its bytes
|
||||
Collections.shuffle(list);
|
||||
for (ZipEntry ze : list) {
|
||||
byte[] data = zip.entries.get(ze);
|
||||
ZipEntry e = zf.getEntry(ze.getName());
|
||||
checkEqual(e, ze);
|
||||
if (!e.isDirectory()) {
|
||||
// check with readAllBytes
|
||||
try (InputStream is = zf.getInputStream(e)) {
|
||||
check(Arrays.equals(data, is.readAllBytes()));
|
||||
}
|
||||
// check with smaller sized buf
|
||||
try (InputStream is = zf.getInputStream(e)) {
|
||||
byte[] buf = new byte[(int)e.getSize()];
|
||||
int sz = r.nextInt((int)e.getSize()/4 + 1) + 1;
|
||||
int off = 0;
|
||||
int n;
|
||||
while ((n = is.read(buf, off, buf.length - off)) > 0) {
|
||||
off += n;
|
||||
}
|
||||
check(is.read() == -1);
|
||||
check(Arrays.equals(data, buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
// (3) check getMetaInfEntryNames
|
||||
String[] metas = list.stream()
|
||||
.map( e -> e.getName())
|
||||
.filter( s -> s.startsWith("META-INF/"))
|
||||
.sorted()
|
||||
.toArray(String[]::new);
|
||||
if (metas.length > 0) {
|
||||
// meta-inf entries
|
||||
Method getMetas = ZipFile.class.getDeclaredMethod("getMetaInfEntryNames");
|
||||
getMetas.setAccessible(true);
|
||||
String[] names = (String[])getMetas.invoke(zf);
|
||||
if (names == null) {
|
||||
fail("Failed to get metanames from " + zf);
|
||||
} else {
|
||||
Arrays.sort(names);
|
||||
check(Arrays.equals(names, metas));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class Zip {
|
||||
String name;
|
||||
Map<ZipEntry, byte[]> entries;
|
||||
BasicFileAttributes attrs;
|
||||
long lastModified;
|
||||
|
||||
Zip(String name, int num, int szMax, boolean prefix, boolean clean) {
|
||||
this.name = name;
|
||||
entries = new LinkedHashMap<>(num);
|
||||
try {
|
||||
Path p = Paths.get(name);
|
||||
if (clean) {
|
||||
Files.deleteIfExists(p);
|
||||
}
|
||||
paths.add(p);
|
||||
} catch (Exception x) {
|
||||
throw (RuntimeException)x;
|
||||
}
|
||||
|
||||
try (FileOutputStream fos = new FileOutputStream(name);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(fos);
|
||||
ZipOutputStream zos = new ZipOutputStream(bos))
|
||||
{
|
||||
if (prefix) {
|
||||
byte[] bytes = new byte[r.nextInt(1000)];
|
||||
r.nextBytes(bytes);
|
||||
bos.write(bytes);
|
||||
}
|
||||
CRC32 crc = new CRC32();
|
||||
for (int i = 0; i < num; i++) {
|
||||
String ename = "entry-" + i + "-name-" + r.nextLong();
|
||||
ZipEntry ze = new ZipEntry(ename);
|
||||
int method = r.nextBoolean() ? ZipEntry.STORED : ZipEntry.DEFLATED;
|
||||
writeEntry(zos, crc, ze, ZipEntry.STORED, szMax);
|
||||
}
|
||||
// add some manifest entries
|
||||
for (int i = 0; i < r.nextInt(20); i++) {
|
||||
String meta = "META-INF/" + "entry-" + i + "-metainf-" + r.nextLong();
|
||||
ZipEntry ze = new ZipEntry(meta);
|
||||
writeEntry(zos, crc, ze, ZipEntry.STORED, szMax);
|
||||
}
|
||||
} catch (Exception x) {
|
||||
throw (RuntimeException)x;
|
||||
}
|
||||
try {
|
||||
this.attrs = Files.readAttributes(Paths.get(name), BasicFileAttributes.class);
|
||||
this.lastModified = new File(name).lastModified();
|
||||
} catch (Exception x) {
|
||||
throw (RuntimeException)x;
|
||||
}
|
||||
}
|
||||
|
||||
private void writeEntry(ZipOutputStream zos, CRC32 crc,
|
||||
ZipEntry ze, int method, int szMax)
|
||||
throws IOException
|
||||
{
|
||||
ze.setMethod(method);
|
||||
byte[] data = new byte[r.nextInt(szMax + 1)];
|
||||
r.nextBytes(data);
|
||||
if (method == ZipEntry.STORED) { // must set size/csize/crc
|
||||
ze.setSize(data.length);
|
||||
ze.setCompressedSize(data.length);
|
||||
crc.reset();
|
||||
crc.update(data);
|
||||
ze.setCrc(crc.getValue());
|
||||
}
|
||||
ze.setTime(System.currentTimeMillis());
|
||||
ze.setComment(ze.getName());
|
||||
zos.putNextEntry(ze);
|
||||
zos.write(data);
|
||||
zos.closeEntry();
|
||||
entries.put(ze, data);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------- Infrastructure ---------------------------
|
||||
static volatile int passed = 0, failed = 0;
|
||||
static void pass() {passed++;}
|
||||
static void pass(String msg) {System.out.println(msg); passed++;}
|
||||
static void fail() {failed++; Thread.dumpStack();}
|
||||
static void fail(String msg) {System.out.println(msg); fail();}
|
||||
static void unexpected(Throwable t) {failed++; t.printStackTrace();}
|
||||
static void unexpected(Throwable t, String msg) {
|
||||
System.out.println(msg); failed++; t.printStackTrace();}
|
||||
static boolean check(boolean cond) {if (cond) pass(); else fail(); return cond;}
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
try {realMain(args);} catch (Throwable t) {unexpected(t);}
|
||||
System.out.println("\nPassed = " + passed + " failed = " + failed);
|
||||
if (failed > 0) throw new AssertionError("Some tests failed");}
|
||||
}
|
@ -28,6 +28,7 @@
|
||||
* @test
|
||||
* @bug 8043758
|
||||
* @summary Datagram Transport Layer Security (DTLS)
|
||||
* @modules java.base/sun.security.util
|
||||
* @run main/othervm DTLSOverDatagram
|
||||
*/
|
||||
|
||||
@ -40,7 +41,7 @@ import java.security.cert.*;
|
||||
import javax.net.ssl.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
/**
|
||||
* An example to show the way to use SSLEngine in datagram connections.
|
||||
|
@ -29,8 +29,6 @@ import java.io.IOException;
|
||||
import javax.net.ssl.*;
|
||||
import java.util.*;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
|
||||
/**
|
||||
* Instances of this class acts as an explorer of the network data of an
|
||||
* SSL/TLS connection.
|
||||
|
@ -107,14 +107,14 @@ public class PrintSEUmlauts implements Printable {
|
||||
System.err.println("printing content");
|
||||
System.err.println(content);
|
||||
}
|
||||
throw new RuntimeException("Expected <e4> to represent 'ä' but not found!");
|
||||
throw new RuntimeException("Expected <e4> to represent '\u00e4' but not found!");
|
||||
}
|
||||
System.err.println("SUCCESS");
|
||||
}
|
||||
|
||||
public int print(Graphics g, PageFormat pf, int pg) {
|
||||
if (pg > 0) return NO_SUCH_PAGE;
|
||||
g.drawString("ä", 100, 100);
|
||||
g.drawString("\u00e4", 100, 100);
|
||||
return PAGE_EXISTS;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@
|
||||
*/
|
||||
package jjjjj.security.auth;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import javax.management.remote.JMXPrincipal;
|
||||
import javax.security.auth.kerberos.KerberosPrincipal;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
@ -107,7 +106,6 @@ public class Subject implements java.io.Serializable {
|
||||
|
||||
public static byte[] enc(Object obj) {
|
||||
try {
|
||||
HexDumpEncoder hex = new HexDumpEncoder();
|
||||
ByteArrayOutputStream bout;
|
||||
bout = new ByteArrayOutputStream();
|
||||
new ObjectOutputStream(bout).writeObject(obj);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2015, 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
|
||||
@ -33,8 +33,6 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
import java.security.KeyPair;
|
||||
import java.security.KeyPairGenerator;
|
||||
import java.security.Policy;
|
||||
import java.security.URIParameter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
@ -115,10 +113,8 @@ public class XMLDSigWithSecMgr implements Runnable {
|
||||
|
||||
// the policy only grants this test SocketPermission to accept, resolve
|
||||
// and connect to localhost so that it can dereference 2nd reference
|
||||
URI policyURI =
|
||||
new File(System.getProperty("test.src", "."), "policy").toURI();
|
||||
Policy.setPolicy
|
||||
(Policy.getInstance("JavaPolicy", new URIParameter(policyURI)));
|
||||
System.setProperty("java.security.policy",
|
||||
System.getProperty("test.src", ".") + File.separator + "policy");
|
||||
System.setSecurityManager(new SecurityManager());
|
||||
|
||||
try {
|
||||
|
@ -30,6 +30,7 @@
|
||||
*/
|
||||
|
||||
import sun.security.jgss.GSSUtil;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
// The basic krb5 test skeleton you can copy from
|
||||
public class MSOID2 {
|
||||
@ -69,7 +70,7 @@ public class MSOID2 {
|
||||
nt[pos] = (byte)newLen;
|
||||
}
|
||||
t = nt;
|
||||
new sun.misc.HexDumpEncoder().encodeBuffer(t, System.out);
|
||||
new HexDumpEncoder().encodeBuffer(t, System.out);
|
||||
}
|
||||
if (t != null || !s.x().isEstablished()) t = s.take(t);
|
||||
if (c.x().isEstablished() && s.x().isEstablished()) break;
|
||||
|
@ -29,7 +29,7 @@ import java.security.*;
|
||||
import java.util.*;
|
||||
import javax.crypto.*;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
/*
|
||||
* Confirm interoperability of RSA public keys between SunMSCAPI and SunJCE
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
# @test
|
||||
# @bug 6888925
|
||||
# @modules java.base/sun.security.util
|
||||
# @requires os.family == "windows"
|
||||
# @run shell PublicKeyInterop.sh
|
||||
# @summary SunMSCAPI's Cipher can't use RSA public keys obtained from other
|
||||
|
@ -40,7 +40,7 @@ import java.security.Signature;
|
||||
import java.security.SignatureException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Date;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.pkcs.ContentInfo;
|
||||
import sun.security.pkcs.PKCS7;
|
||||
import sun.security.pkcs.SignerInfo;
|
||||
|
@ -43,7 +43,7 @@ import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.util.Arrays;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.pkcs.PKCS8Key;
|
||||
import sun.security.provider.DSAPrivateKey;
|
||||
import sun.security.util.DerOutputStream;
|
||||
|
@ -33,7 +33,7 @@
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.pkcs.PKCS9Attribute;
|
||||
import sun.security.util.DerValue;
|
||||
import sun.security.util.ObjectIdentifier;
|
||||
|
@ -32,7 +32,7 @@
|
||||
import java.util.Arrays;
|
||||
import sun.security.util.DerOutputStream;
|
||||
import sun.security.x509.*;
|
||||
import sun.misc.HexDumpEncoder;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
public class NullX500Name {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user