mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
Merge
This commit is contained in:
commit
cc3a5f23de
152 changed files with 1312 additions and 2096 deletions
|
@ -12,4 +12,5 @@ jdk.crypto.ucrypto
|
|||
jdk.localedata
|
||||
jdk.naming.dns
|
||||
jdk.scripting.nashorn
|
||||
jdk.xml.dom
|
||||
jdk.zipfs
|
||||
|
|
|
@ -105,7 +105,7 @@ final class EPollPort
|
|||
|
||||
// create the queue and offer the special event to ensure that the first
|
||||
// threads polls
|
||||
this.queue = new ArrayBlockingQueue<Event>(MAX_EPOLL_EVENTS);
|
||||
this.queue = new ArrayBlockingQueue<>(MAX_EPOLL_EVENTS);
|
||||
this.queue.offer(NEED_TO_POLL);
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ class LinuxNativeDispatcher extends UnixNativeDispatcher {
|
|||
private static native void init();
|
||||
|
||||
static {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("nio");
|
||||
return null;
|
||||
|
|
|
@ -190,7 +190,7 @@ class LinuxWatchService
|
|||
this.watcher = watcher;
|
||||
this.ifd = ifd;
|
||||
this.socketpair = sp;
|
||||
this.wdToKey = new HashMap<Integer,LinuxWatchKey>();
|
||||
this.wdToKey = new HashMap<>();
|
||||
this.address = unsafe.allocateMemory(BUFFER_SIZE);
|
||||
}
|
||||
|
||||
|
@ -457,7 +457,7 @@ class LinuxWatchService
|
|||
private static native int poll(int fd1, int fd2) throws UnixException;
|
||||
|
||||
static {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("nio");
|
||||
return null;
|
||||
|
|
|
@ -68,7 +68,7 @@ class MagicFileTypeDetector extends AbstractFileTypeDetector {
|
|||
private static native byte[] probe0(long pathAddress);
|
||||
|
||||
static {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
public Void run() {
|
||||
System.loadLibrary("nio");
|
||||
|
|
|
@ -87,7 +87,7 @@ class NativeUnpack {
|
|||
// If loading from stand alone build uncomment this.
|
||||
// System.loadLibrary("unpack");
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("unpack");
|
||||
return null;
|
||||
|
|
|
@ -1210,7 +1210,7 @@ class Package {
|
|||
// This keeps files of similar format near each other.
|
||||
// Put class files at the end, keeping their fixed order.
|
||||
// Be sure the JAR file's required manifest stays at the front. (4893051)
|
||||
Collections.sort(files, new Comparator<File>() {
|
||||
Collections.sort(files, new Comparator<>() {
|
||||
public int compare(File r0, File r1) {
|
||||
// Get the file name.
|
||||
String f0 = r0.nameString;
|
||||
|
|
|
@ -1151,7 +1151,7 @@ class PackageReader extends BandStructure {
|
|||
return -1;
|
||||
}
|
||||
|
||||
Comparator<Entry> entryOutputOrder = new Comparator<Entry>() {
|
||||
Comparator<Entry> entryOutputOrder = new Comparator<>() {
|
||||
public int compare(Entry e0, Entry e1) {
|
||||
int k0 = getOutputIndex(e0);
|
||||
int k1 = getOutputIndex(e1);
|
||||
|
|
|
@ -829,7 +829,7 @@ class PackageWriter extends BandStructure {
|
|||
maxFlags = new int[ATTR_CONTEXT_LIMIT];
|
||||
allLayouts = new FixedList<>(ATTR_CONTEXT_LIMIT);
|
||||
for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
|
||||
allLayouts.set(i, new HashMap<Attribute.Layout, int[]>());
|
||||
allLayouts.set(i, new HashMap<>());
|
||||
}
|
||||
// Collect maxFlags and allLayouts.
|
||||
for (Class cls : pkg.classes) {
|
||||
|
@ -892,7 +892,7 @@ class PackageWriter extends BandStructure {
|
|||
// Sort by count, most frequent first.
|
||||
// Predefs. participate in this sort, though it does not matter.
|
||||
Arrays.sort(layoutsAndCounts,
|
||||
new Comparator<Map.Entry<Attribute.Layout, int[]>>() {
|
||||
new Comparator<>() {
|
||||
public int compare(Map.Entry<Attribute.Layout, int[]> e0,
|
||||
Map.Entry<Attribute.Layout, int[]> e1) {
|
||||
// Primary sort key is count, reversed.
|
||||
|
@ -1010,7 +1010,7 @@ class PackageWriter extends BandStructure {
|
|||
int numAttrDefs = defList.size();
|
||||
Object[][] defs = new Object[numAttrDefs][];
|
||||
defList.toArray(defs);
|
||||
Arrays.sort(defs, new Comparator<Object[]>() {
|
||||
Arrays.sort(defs, new Comparator<>() {
|
||||
public int compare(Object[] a0, Object[] a1) {
|
||||
// Primary sort key is attr def header.
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -64,7 +64,7 @@ class ExpiringCache {
|
|||
@SuppressWarnings("serial")
|
||||
ExpiringCache(long millisUntilExpiration) {
|
||||
this.millisUntilExpiration = millisUntilExpiration;
|
||||
map = new LinkedHashMap<String,Entry>() {
|
||||
map = new LinkedHashMap<>() {
|
||||
protected boolean removeEldestEntry(Map.Entry<String,Entry> eldest) {
|
||||
return size() > MAX_ENTRIES;
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ public final class FilePermission extends Permission implements Serializable {
|
|||
}
|
||||
|
||||
// store only the canonical cpath if possible
|
||||
cpath = AccessController.doPrivileged(new PrivilegedAction<String>() {
|
||||
cpath = AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public String run() {
|
||||
try {
|
||||
String path = cpath;
|
||||
|
|
|
@ -1263,7 +1263,7 @@ public class ObjectInputStream
|
|||
*/
|
||||
private static boolean auditSubclass(final Class<?> subcl) {
|
||||
Boolean result = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Boolean>() {
|
||||
new PrivilegedAction<>() {
|
||||
public Boolean run() {
|
||||
for (Class<?> cl = subcl;
|
||||
cl != ObjectInputStream.class;
|
||||
|
@ -2255,7 +2255,7 @@ public class ObjectInputStream
|
|||
try {
|
||||
while (list != null) {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<Void>()
|
||||
new PrivilegedExceptionAction<>()
|
||||
{
|
||||
public Void run() throws InvalidObjectException {
|
||||
list.obj.validateObject();
|
||||
|
|
|
@ -1066,7 +1066,7 @@ public class ObjectOutputStream
|
|||
*/
|
||||
private static boolean auditSubclass(final Class<?> subcl) {
|
||||
Boolean result = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Boolean>() {
|
||||
new PrivilegedAction<>() {
|
||||
public Boolean run() {
|
||||
for (Class<?> cl = subcl;
|
||||
cl != ObjectOutputStream.class;
|
||||
|
|
|
@ -367,7 +367,7 @@ public class ObjectStreamClass implements Serializable {
|
|||
entry = th;
|
||||
}
|
||||
if (future.set(entry)) {
|
||||
Caches.localDescs.put(key, new SoftReference<Object>(entry));
|
||||
Caches.localDescs.put(key, new SoftReference<>(entry));
|
||||
} else {
|
||||
// nested lookup call already set future
|
||||
entry = future.get();
|
||||
|
@ -430,7 +430,7 @@ public class ObjectStreamClass implements Serializable {
|
|||
}
|
||||
if (interrupted) {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction<Void>() {
|
||||
new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
Thread.currentThread().interrupt();
|
||||
return null;
|
||||
|
@ -465,7 +465,7 @@ public class ObjectStreamClass implements Serializable {
|
|||
localDesc = this;
|
||||
|
||||
if (serializable) {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
if (isEnum) {
|
||||
suid = Long.valueOf(0);
|
||||
|
@ -1733,7 +1733,7 @@ public class ObjectStreamClass implements Serializable {
|
|||
for (int i = 0; i < fields.length; i++) {
|
||||
fieldSigs[i] = new MemberSignature(fields[i]);
|
||||
}
|
||||
Arrays.sort(fieldSigs, new Comparator<MemberSignature>() {
|
||||
Arrays.sort(fieldSigs, new Comparator<>() {
|
||||
public int compare(MemberSignature ms1, MemberSignature ms2) {
|
||||
return ms1.name.compareTo(ms2.name);
|
||||
}
|
||||
|
@ -1764,7 +1764,7 @@ public class ObjectStreamClass implements Serializable {
|
|||
for (int i = 0; i < cons.length; i++) {
|
||||
consSigs[i] = new MemberSignature(cons[i]);
|
||||
}
|
||||
Arrays.sort(consSigs, new Comparator<MemberSignature>() {
|
||||
Arrays.sort(consSigs, new Comparator<>() {
|
||||
public int compare(MemberSignature ms1, MemberSignature ms2) {
|
||||
return ms1.signature.compareTo(ms2.signature);
|
||||
}
|
||||
|
@ -1787,7 +1787,7 @@ public class ObjectStreamClass implements Serializable {
|
|||
for (int i = 0; i < methods.length; i++) {
|
||||
methSigs[i] = new MemberSignature(methods[i]);
|
||||
}
|
||||
Arrays.sort(methSigs, new Comparator<MemberSignature>() {
|
||||
Arrays.sort(methSigs, new Comparator<>() {
|
||||
public int compare(MemberSignature ms1, MemberSignature ms2) {
|
||||
int comp = ms1.name.compareTo(ms2.name);
|
||||
if (comp == 0) {
|
||||
|
@ -2164,7 +2164,7 @@ public class ObjectStreamClass implements Serializable {
|
|||
entry = th;
|
||||
}
|
||||
future.set(entry);
|
||||
Caches.reflectors.put(key, new SoftReference<Object>(entry));
|
||||
Caches.reflectors.put(key, new SoftReference<>(entry));
|
||||
}
|
||||
|
||||
if (entry instanceof FieldReflector) {
|
||||
|
|
|
@ -45,7 +45,7 @@ class CharacterName {
|
|||
DataInputStream dis = null;
|
||||
try {
|
||||
dis = new DataInputStream(new InflaterInputStream(
|
||||
AccessController.doPrivileged(new PrivilegedAction<InputStream>()
|
||||
AccessController.doPrivileged(new PrivilegedAction<>()
|
||||
{
|
||||
public InputStream run() {
|
||||
return getClass().getResourceAsStream("uniName.dat");
|
||||
|
|
|
@ -437,7 +437,7 @@ public final class Class<T> implements java.io.Serializable,
|
|||
// (the stack depth is wrong for the Constructor's
|
||||
// security check to work)
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
c.setAccessible(true);
|
||||
return null;
|
||||
|
@ -1068,7 +1068,7 @@ public final class Class<T> implements java.io.Serializable,
|
|||
Reflection.getCallerClass(), true);
|
||||
// Client is ok to access declared methods but j.l.Class might not be.
|
||||
Method[] candidates = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Method[]>() {
|
||||
new PrivilegedAction<>() {
|
||||
@Override
|
||||
public Method[] run() {
|
||||
return enclosingCandidate.getDeclaredMethods();
|
||||
|
@ -1228,7 +1228,7 @@ public final class Class<T> implements java.io.Serializable,
|
|||
Reflection.getCallerClass(), true);
|
||||
// Client is ok to access declared methods but j.l.Class might not be.
|
||||
Constructor<?>[] candidates = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Constructor<?>[]>() {
|
||||
new PrivilegedAction<>() {
|
||||
@Override
|
||||
public Constructor<?>[] run() {
|
||||
return enclosingCandidate.getDeclaredConstructors();
|
||||
|
@ -1542,7 +1542,7 @@ public final class Class<T> implements java.io.Serializable,
|
|||
// has already been ok'd by the SecurityManager.
|
||||
|
||||
return java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Class<?>[]>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public Class<?>[] run() {
|
||||
List<Class<?>> list = new ArrayList<>();
|
||||
Class<?> currentClass = Class.this;
|
||||
|
@ -3293,7 +3293,7 @@ public final class Class<T> implements java.io.Serializable,
|
|||
private static boolean initted = false;
|
||||
private static void checkInitted() {
|
||||
if (initted) return;
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
// Tests to ensure the system properties table is fully
|
||||
// initialized. This is needed because reflection code is
|
||||
|
@ -3349,7 +3349,7 @@ public final class Class<T> implements java.io.Serializable,
|
|||
try {
|
||||
final Method values = getMethod("values");
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
values.setAccessible(true);
|
||||
return null;
|
||||
|
|
|
@ -496,7 +496,7 @@ public abstract class ClassLoader {
|
|||
final String name = cls.getName();
|
||||
final int i = name.lastIndexOf('.');
|
||||
if (i != -1) {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
sm.checkPackageAccess(name.substring(0, i));
|
||||
return null;
|
||||
|
@ -1265,7 +1265,7 @@ public abstract class ClassLoader {
|
|||
{
|
||||
final Enumeration<Resource> e =
|
||||
getBootstrapClassPath().getResources(name);
|
||||
return new Enumeration<URL> () {
|
||||
return new Enumeration<> () {
|
||||
public URL nextElement() {
|
||||
return e.nextElement().getURL();
|
||||
}
|
||||
|
@ -1867,7 +1867,7 @@ public abstract class ClassLoader {
|
|||
boolean isBuiltin = (name != null);
|
||||
if (!isBuiltin) {
|
||||
name = AccessController.doPrivileged(
|
||||
new PrivilegedAction<String>() {
|
||||
new PrivilegedAction<>() {
|
||||
public String run() {
|
||||
try {
|
||||
return file.exists() ? file.getCanonicalPath() : null;
|
||||
|
|
|
@ -595,7 +595,7 @@ public class Package implements java.lang.reflect.AnnotatedElement {
|
|||
|
||||
CachedManifest(final String fileName) {
|
||||
this.fileName = fileName;
|
||||
this.url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
|
||||
this.url = AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public URL run() {
|
||||
final File file = new File(fileName);
|
||||
if (file.isFile()) {
|
||||
|
@ -626,7 +626,7 @@ public class Package implements java.lang.reflect.AnnotatedElement {
|
|||
if (m != null) {
|
||||
return m;
|
||||
}
|
||||
m = AccessController.doPrivileged(new PrivilegedAction<Manifest>() {
|
||||
m = AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Manifest run() {
|
||||
try (FileInputStream fis = new FileInputStream(fileName);
|
||||
JarInputStream jis = new JarInputStream(fis, false)) {
|
||||
|
|
|
@ -1455,7 +1455,7 @@ class SecurityManager {
|
|||
if (!packageAccessValid) {
|
||||
String tmpPropertyStr =
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction<String>() {
|
||||
new PrivilegedAction<>() {
|
||||
public String run() {
|
||||
return java.security.Security.getProperty(
|
||||
"package.access");
|
||||
|
@ -1524,7 +1524,7 @@ class SecurityManager {
|
|||
if (!packageDefinitionValid) {
|
||||
String tmpPropertyStr =
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction<String>() {
|
||||
new PrivilegedAction<>() {
|
||||
public String run() {
|
||||
return java.security.Security.getProperty(
|
||||
"package.definition");
|
||||
|
|
|
@ -206,6 +206,7 @@ import java.util.Arrays;
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws IndexOutOfBoundsException {@inheritDoc}
|
||||
* @since 1.5
|
||||
*/
|
||||
@Override
|
||||
|
@ -214,6 +215,7 @@ import java.util.Arrays;
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws IndexOutOfBoundsException {@inheritDoc}
|
||||
* @since 1.5
|
||||
*/
|
||||
@Override
|
||||
|
@ -222,6 +224,7 @@ import java.util.Arrays;
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws IndexOutOfBoundsException {@inheritDoc}
|
||||
* @since 1.5
|
||||
*/
|
||||
@Override
|
||||
|
@ -230,6 +233,7 @@ import java.util.Arrays;
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws IndexOutOfBoundsException {@inheritDoc}
|
||||
* @since 1.5
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -309,7 +309,7 @@ public final class System {
|
|||
// calls the installed security manager's checkPermission method
|
||||
// which will loop infinitely if there is a non-system class
|
||||
// (in this case: the new security manager class) on the stack).
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Object run() {
|
||||
s.getClass().getProtectionDomain().implies
|
||||
(SecurityConstants.ALL_PERMISSION);
|
||||
|
|
|
@ -1661,7 +1661,7 @@ class Thread implements Runnable {
|
|||
*/
|
||||
private static boolean auditSubclass(final Class<?> subcl) {
|
||||
Boolean result = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Boolean>() {
|
||||
new PrivilegedAction<>() {
|
||||
public Boolean run() {
|
||||
for (Class<?> cl = subcl;
|
||||
cl != Thread.class;
|
||||
|
|
|
@ -87,7 +87,7 @@ class InfoFromMemberName implements MethodHandleInfo {
|
|||
// For more information see comments on {@link MethodHandleNatives#linkMethod}.
|
||||
throw new IllegalArgumentException("cannot reflect signature polymorphic method");
|
||||
}
|
||||
Member mem = AccessController.doPrivileged(new PrivilegedAction<Member>() {
|
||||
Member mem = AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Member run() {
|
||||
try {
|
||||
return reflectUnchecked();
|
||||
|
|
|
@ -194,7 +194,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
|||
final Class<?> innerClass = spinInnerClass();
|
||||
if (invokedType.parameterCount() == 0) {
|
||||
final Constructor<?>[] ctrs = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Constructor<?>[]>() {
|
||||
new PrivilegedAction<>() {
|
||||
@Override
|
||||
public Constructor<?>[] run() {
|
||||
Constructor<?>[] ctrs = innerClass.getDeclaredConstructors();
|
||||
|
@ -311,7 +311,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
|||
|
||||
// If requested, dump out to a file for debugging purposes
|
||||
if (dumper != null) {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
public Void run() {
|
||||
dumper.dumpClass(lambdaClassName, classBytes);
|
||||
|
|
|
@ -167,7 +167,7 @@ class InvokerBytecodeGenerator {
|
|||
static void maybeDump(final String className, final byte[] classFile) {
|
||||
if (DUMP_CLASS_FILES) {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
try {
|
||||
String dumpName = className;
|
||||
|
|
|
@ -51,7 +51,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
|
|||
private static final int MAX_ARITY;
|
||||
static {
|
||||
final Object[] values = { 255 };
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
public Void run() {
|
||||
values[0] = Integer.getInteger(MethodHandleImpl.class.getName()+".MAX_ARITY", 255);
|
||||
|
@ -1234,7 +1234,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
|
|||
private static final byte[] T_BYTES;
|
||||
static {
|
||||
final Object[] values = {null};
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
try {
|
||||
Class<T> tClass = T.class;
|
||||
|
|
|
@ -199,7 +199,7 @@ public class MethodHandleProxies {
|
|||
// sun.invoke.WrapperInstance is a restricted interface not accessible
|
||||
// by any non-null class loader.
|
||||
final ClassLoader loader = proxyLoader;
|
||||
proxy = AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
proxy = AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Object run() {
|
||||
return Proxy.newProxyInstance(
|
||||
loader,
|
||||
|
|
|
@ -53,7 +53,7 @@ import sun.misc.Unsafe;
|
|||
|
||||
static {
|
||||
final Object[] values = new Object[9];
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
values[0] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DEBUG_NAMES");
|
||||
values[1] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DUMP_CLASS_FILES");
|
||||
|
|
|
@ -64,7 +64,7 @@ final class ProxyClassesDumper {
|
|||
try {
|
||||
path = path.trim();
|
||||
final Path dir = Paths.get(path.length() == 0 ? "." : path);
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
public Void run() {
|
||||
validateDumpDir(dir);
|
||||
|
|
|
@ -218,7 +218,7 @@ public final class SerializedLambda implements Serializable {
|
|||
|
||||
private Object readResolve() throws ReflectiveOperationException {
|
||||
try {
|
||||
Method deserialize = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
|
||||
Method deserialize = AccessController.doPrivileged(new PrivilegedExceptionAction<>() {
|
||||
@Override
|
||||
public Method run() throws Exception {
|
||||
Method m = capturingClass.getDeclaredMethod("$deserializeLambda$", SerializedLambda.class);
|
||||
|
|
|
@ -121,7 +121,7 @@ final class Finalizer extends FinalReference<Object> { /* Package-private; must
|
|||
*/
|
||||
private static void forkSecondaryFinalizer(final Runnable proc) {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction<Void>() {
|
||||
new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
ThreadGroup tg = Thread.currentThread().getThreadGroup();
|
||||
for (ThreadGroup tgn = tg;
|
||||
|
|
|
@ -728,7 +728,7 @@ public class Proxy implements java.io.Serializable {
|
|||
|
||||
final Constructor<?> cons = cl.getConstructor(constructorParams);
|
||||
if (!Modifier.isPublic(cl.getModifiers())) {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
cons.setAccessible(true);
|
||||
return null;
|
||||
|
|
|
@ -62,7 +62,7 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
*/
|
||||
static {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("net");
|
||||
return null;
|
||||
|
|
|
@ -79,7 +79,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
|
|||
*/
|
||||
static {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("net");
|
||||
return null;
|
||||
|
|
|
@ -201,14 +201,13 @@ public class CookieManager extends CookieHandler
|
|||
throw new IllegalArgumentException("Argument is null");
|
||||
}
|
||||
|
||||
Map<String, List<String>> cookieMap =
|
||||
new java.util.HashMap<String, List<String>>();
|
||||
Map<String, List<String>> cookieMap = new java.util.HashMap<>();
|
||||
// if there's no default CookieStore, no way for us to get any cookie
|
||||
if (cookieJar == null)
|
||||
return Collections.unmodifiableMap(cookieMap);
|
||||
|
||||
boolean secureLink = "https".equalsIgnoreCase(uri.getScheme());
|
||||
List<HttpCookie> cookies = new java.util.ArrayList<HttpCookie>();
|
||||
List<HttpCookie> cookies = new java.util.ArrayList<>();
|
||||
String path = uri.getPath();
|
||||
if (path == null || path.isEmpty()) {
|
||||
path = "/";
|
||||
|
@ -411,7 +410,7 @@ public class CookieManager extends CookieHandler
|
|||
private List<String> sortByPath(List<HttpCookie> cookies) {
|
||||
Collections.sort(cookies, new CookiePathComparator());
|
||||
|
||||
List<String> cookieHeader = new java.util.ArrayList<String>();
|
||||
List<String> cookieHeader = new java.util.ArrayList<>();
|
||||
for (HttpCookie cookie : cookies) {
|
||||
// Netscape cookie spec and RFC 2965 have different format of Cookie
|
||||
// header; RFC 2965 requires a leading $Version="1" string while Netscape
|
||||
|
|
|
@ -47,7 +47,7 @@ class DatagramPacket {
|
|||
*/
|
||||
static {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("net");
|
||||
return null;
|
||||
|
|
|
@ -308,7 +308,7 @@ class DatagramSocket implements java.io.Closeable {
|
|||
// getDeclaredMethod, therefore we need permission to access the member
|
||||
try {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<Void>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public Void run() throws NoSuchMethodException {
|
||||
Class<?>[] cl = new Class<?>[1];
|
||||
cl[0] = DatagramPacket.class;
|
||||
|
|
|
@ -64,7 +64,7 @@ import java.util.Set;
|
|||
serverSocketField = netClientClazz.getDeclaredField("serverSocket");
|
||||
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
httpField.setAccessible(true);
|
||||
serverSocketField.setAccessible(true);
|
||||
|
@ -146,7 +146,7 @@ import java.util.Set;
|
|||
{
|
||||
try {
|
||||
return java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<Socket>() {
|
||||
new java.security.PrivilegedExceptionAction<>() {
|
||||
public Socket run() throws IOException {
|
||||
return doTunnel(urlString, timeout);
|
||||
}
|
||||
|
|
|
@ -1125,7 +1125,7 @@ public final class HttpCookie implements Cloneable {
|
|||
* @return list of strings; never null
|
||||
*/
|
||||
private static List<String> splitMultiCookies(String header) {
|
||||
List<String> cookies = new java.util.ArrayList<String>();
|
||||
List<String> cookies = new java.util.ArrayList<>();
|
||||
int quoteCount = 0;
|
||||
int p, q;
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ public final class IDN {
|
|||
try {
|
||||
final String IDN_PROFILE = "uidna.spp";
|
||||
if (System.getSecurityManager() != null) {
|
||||
stream = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
|
||||
stream = AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public InputStream run() {
|
||||
return StringPrep.class.getResourceAsStream(IDN_PROFILE);
|
||||
}
|
||||
|
|
|
@ -62,9 +62,9 @@ class InMemoryCookieStore implements CookieStore {
|
|||
* The default ctor
|
||||
*/
|
||||
public InMemoryCookieStore() {
|
||||
cookieJar = new ArrayList<HttpCookie>();
|
||||
domainIndex = new HashMap<String, List<HttpCookie>>();
|
||||
uriIndex = new HashMap<URI, List<HttpCookie>>();
|
||||
cookieJar = new ArrayList<>();
|
||||
domainIndex = new HashMap<>();
|
||||
uriIndex = new HashMap<>();
|
||||
|
||||
lock = new ReentrantLock(false);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ class InMemoryCookieStore implements CookieStore {
|
|||
throw new NullPointerException("uri is null");
|
||||
}
|
||||
|
||||
List<HttpCookie> cookies = new ArrayList<HttpCookie>();
|
||||
List<HttpCookie> cookies = new ArrayList<>();
|
||||
boolean secureLink = "https".equalsIgnoreCase(uri.getScheme());
|
||||
lock.lock();
|
||||
try {
|
||||
|
@ -157,7 +157,7 @@ class InMemoryCookieStore implements CookieStore {
|
|||
* of this cookie store.
|
||||
*/
|
||||
public List<URI> getURIs() {
|
||||
List<URI> uris = new ArrayList<URI>();
|
||||
List<URI> uris = new ArrayList<>();
|
||||
|
||||
lock.lock();
|
||||
try {
|
||||
|
@ -281,7 +281,7 @@ class InMemoryCookieStore implements CookieStore {
|
|||
String host, boolean secureLink) {
|
||||
// Use a separate list to handle cookies that need to be removed so
|
||||
// that there is no conflict with iterators.
|
||||
ArrayList<HttpCookie> toRemove = new ArrayList<HttpCookie>();
|
||||
ArrayList<HttpCookie> toRemove = new ArrayList<>();
|
||||
for (Map.Entry<String, List<HttpCookie>> entry : cookieIndex.entrySet()) {
|
||||
String domain = entry.getKey();
|
||||
List<HttpCookie> lst = entry.getValue();
|
||||
|
@ -368,7 +368,7 @@ class InMemoryCookieStore implements CookieStore {
|
|||
|
||||
cookies.add(cookie);
|
||||
} else {
|
||||
cookies = new ArrayList<HttpCookie>();
|
||||
cookies = new ArrayList<>();
|
||||
cookies.add(cookie);
|
||||
indexStore.put(index, cookies);
|
||||
}
|
||||
|
|
|
@ -270,7 +270,7 @@ class InetAddress implements java.io.Serializable {
|
|||
preferIPv6Address = java.security.AccessController.doPrivileged(
|
||||
new GetBooleanAction("java.net.preferIPv6Addresses")).booleanValue();
|
||||
AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("net");
|
||||
return null;
|
||||
|
@ -852,7 +852,7 @@ class InetAddress implements java.io.Serializable {
|
|||
final String providerName = provider;
|
||||
try {
|
||||
nameService = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<NameService>() {
|
||||
new java.security.PrivilegedExceptionAction<>() {
|
||||
public NameService run() {
|
||||
Iterator<NameServiceDescriptor> itr =
|
||||
ServiceLoader.load(NameServiceDescriptor.class)
|
||||
|
@ -892,7 +892,7 @@ class InetAddress implements java.io.Serializable {
|
|||
String provider = null;;
|
||||
String propPrefix = "sun.net.spi.nameservice.provider.";
|
||||
int n = 1;
|
||||
nameServices = new ArrayList<NameService>();
|
||||
nameServices = new ArrayList<>();
|
||||
provider = AccessController.doPrivileged(
|
||||
new GetPropertyAction(propPrefix + n));
|
||||
while (provider != null) {
|
||||
|
|
|
@ -54,7 +54,7 @@ public final class NetworkInterface {
|
|||
|
||||
static {
|
||||
AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("net");
|
||||
return null;
|
||||
|
@ -167,7 +167,7 @@ public final class NetworkInterface {
|
|||
* @since 1.6
|
||||
*/
|
||||
public java.util.List<InterfaceAddress> getInterfaceAddresses() {
|
||||
java.util.List<InterfaceAddress> lst = new java.util.ArrayList<InterfaceAddress>(1);
|
||||
java.util.List<InterfaceAddress> lst = new java.util.ArrayList<>(1);
|
||||
SecurityManager sec = System.getSecurityManager();
|
||||
for (int j=0; j<bindings.length; j++) {
|
||||
try {
|
||||
|
@ -346,7 +346,7 @@ public final class NetworkInterface {
|
|||
if (netifs == null)
|
||||
return null;
|
||||
|
||||
return new Enumeration<NetworkInterface>() {
|
||||
return new Enumeration<>() {
|
||||
private int i = 0;
|
||||
public NetworkInterface nextElement() {
|
||||
if (netifs != null && i < netifs.length) {
|
||||
|
|
|
@ -470,7 +470,7 @@ class Socket implements java.io.Closeable {
|
|||
// getDeclaredMethod, therefore we need permission to access the member
|
||||
|
||||
oldImpl = AccessController.doPrivileged
|
||||
(new PrivilegedAction<Boolean>() {
|
||||
(new PrivilegedAction<>() {
|
||||
public Boolean run() {
|
||||
Class<?> clazz = impl.getClass();
|
||||
while (true) {
|
||||
|
@ -911,7 +911,7 @@ class Socket implements java.io.Closeable {
|
|||
InputStream is = null;
|
||||
try {
|
||||
is = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<InputStream>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public InputStream run() throws IOException {
|
||||
return impl.getInputStream();
|
||||
}
|
||||
|
@ -951,7 +951,7 @@ class Socket implements java.io.Closeable {
|
|||
OutputStream os = null;
|
||||
try {
|
||||
os = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<OutputStream>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public OutputStream run() throws IOException {
|
||||
return impl.getOutputStream();
|
||||
}
|
||||
|
|
|
@ -1194,7 +1194,7 @@ public final class SocketPermission extends Permission
|
|||
*/
|
||||
private static int initEphemeralPorts(String suffix, int defval) {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<Integer>(){
|
||||
new PrivilegedAction<>(){
|
||||
public Integer run() {
|
||||
int val = Integer.getInteger(
|
||||
"jdk.net.ephemeralPortRange."+suffix, -1
|
||||
|
@ -1328,7 +1328,7 @@ final class SocketPermissionCollection extends PermissionCollection
|
|||
*/
|
||||
|
||||
public SocketPermissionCollection() {
|
||||
perms = new ArrayList<SocketPermission>();
|
||||
perms = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1466,7 +1466,7 @@ final class SocketPermissionCollection extends PermissionCollection
|
|||
// Get the one we want
|
||||
@SuppressWarnings("unchecked")
|
||||
Vector<SocketPermission> permissions = (Vector<SocketPermission>)gfields.get("permissions", null);
|
||||
perms = new ArrayList<SocketPermission>(permissions.size());
|
||||
perms = new ArrayList<>(permissions.size());
|
||||
perms.addAll(permissions);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
|||
{
|
||||
try {
|
||||
AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<Void>() {
|
||||
new java.security.PrivilegedExceptionAction<>() {
|
||||
public Void run() throws IOException {
|
||||
superConnectServer(host, port, timeout);
|
||||
cmdIn = getInputStream();
|
||||
|
@ -157,7 +157,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
|||
final InetAddress addr = InetAddress.getByName(server);
|
||||
PasswordAuthentication pw =
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<PasswordAuthentication>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public PasswordAuthentication run() {
|
||||
return Authenticator.requestPasswordAuthentication(
|
||||
server, addr, serverPort, "SOCKS5", "SOCKS authentication", null);
|
||||
|
@ -351,7 +351,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
|||
// server is not null only when the socket was created with a
|
||||
// specified proxy in which case it does bypass the ProxySelector
|
||||
ProxySelector sel = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<ProxySelector>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public ProxySelector run() {
|
||||
return ProxySelector.getDefault();
|
||||
}
|
||||
|
@ -595,7 +595,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
|||
InetAddress naddr = baddr;
|
||||
if (naddr.isAnyLocalAddress()) {
|
||||
naddr = AccessController.doPrivileged(
|
||||
new PrivilegedAction<InetAddress>() {
|
||||
new PrivilegedAction<>() {
|
||||
public InetAddress run() {
|
||||
return cmdsock.getLocalAddress();
|
||||
|
||||
|
@ -671,7 +671,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
|||
// server is not null only when the socket was created with a
|
||||
// specified proxy in which case it does bypass the ProxySelector
|
||||
ProxySelector sel = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<ProxySelector>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public ProxySelector run() {
|
||||
return ProxySelector.getDefault();
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
|||
// Connects to the SOCKS server
|
||||
try {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<Void>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public Void run() throws Exception {
|
||||
cmdsock = new Socket(new PlainSocketImpl());
|
||||
cmdsock.connect(new InetSocketAddress(server, serverPort));
|
||||
|
@ -755,7 +755,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
|||
} else {
|
||||
try {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<Void>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public Void run() throws Exception {
|
||||
cmdsock = new Socket(new PlainSocketImpl());
|
||||
cmdsock.connect(new InetSocketAddress(server, serverPort));
|
||||
|
|
|
@ -268,6 +268,23 @@ public final class URL implements java.io.Serializable {
|
|||
* createURLStreamHandler} method of each provider, if instantiated, is
|
||||
* invoked, with the protocol string, until a provider returns non-null,
|
||||
* or all providers have been exhausted.
|
||||
* <li>If the previous step fails to find a protocol handler, the
|
||||
* constructor reads the value of the system property:
|
||||
* <blockquote>{@code
|
||||
* java.protocol.handler.pkgs
|
||||
* }</blockquote>
|
||||
* If the value of that system property is not {@code null},
|
||||
* it is interpreted as a list of packages separated by a vertical
|
||||
* slash character '{@code |}'. The constructor tries to load
|
||||
* the class named:
|
||||
* <blockquote>{@code
|
||||
* <package>.<protocol>.Handler
|
||||
* }</blockquote>
|
||||
* where {@code <package>} is replaced by the name of the package
|
||||
* and {@code <protocol>} is replaced by the name of the protocol.
|
||||
* If this class does not exist, or if the class exists but it is not
|
||||
* a subclass of {@code URLStreamHandler}, then the next package
|
||||
* in the list is tried.
|
||||
* <li>If the previous step fails to find a protocol handler, then the
|
||||
* constructor tries to load a built-in protocol handler.
|
||||
* If this class does not exist, or if the class exists but it is not a
|
||||
|
@ -1139,8 +1156,41 @@ public final class URL implements java.io.Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
private static URLStreamHandler lookupViaProperty(String protocol) {
|
||||
String packagePrefixList = java.security.AccessController.doPrivileged(
|
||||
new PrivilegedAction<>() {
|
||||
public String run() {
|
||||
return System.getProperty(protocolPathProp, "");
|
||||
}
|
||||
});
|
||||
String[] packagePrefixes = packagePrefixList.split("\\|");
|
||||
|
||||
URLStreamHandler handler = null;
|
||||
for (int i=0; handler == null && i<packagePrefixes.length; i++) {
|
||||
String packagePrefix = packagePrefixes[i].trim();
|
||||
try {
|
||||
String clsName = packagePrefix + "." + protocol + ".Handler";
|
||||
Class<?> cls = null;
|
||||
try {
|
||||
cls = Class.forName(clsName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||
if (cl != null) {
|
||||
cls = cl.loadClass(clsName);
|
||||
}
|
||||
}
|
||||
if (cls != null) {
|
||||
handler = (URLStreamHandler)cls.newInstance();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// any number of exceptions can get thrown here
|
||||
}
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
private static Iterator<URLStreamHandlerProvider> providers() {
|
||||
return new Iterator<URLStreamHandlerProvider>() {
|
||||
return new Iterator<>() {
|
||||
|
||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||
ServiceLoader<URLStreamHandlerProvider> sl =
|
||||
|
@ -1193,7 +1243,7 @@ public final class URL implements java.io.Serializable {
|
|||
gate.set(gate);
|
||||
try {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<URLStreamHandler>() {
|
||||
new PrivilegedAction<>() {
|
||||
public URLStreamHandler run() {
|
||||
Iterator<URLStreamHandlerProvider> itr = providers();
|
||||
while (itr.hasNext()) {
|
||||
|
@ -1251,6 +1301,10 @@ public final class URL implements java.io.Serializable {
|
|||
if (handler == null && !protocol.equalsIgnoreCase("jar")) {
|
||||
handler = lookupViaProviders(protocol);
|
||||
}
|
||||
|
||||
if (handler == null) {
|
||||
handler = lookupViaProperty(protocol);
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (streamHandlerLock) {
|
||||
|
|
|
@ -359,7 +359,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
final Class<?> result;
|
||||
try {
|
||||
result = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<Class<?>>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public Class<?> run() throws ClassNotFoundException {
|
||||
String path = name.replace('.', '/').concat(".class");
|
||||
Resource res = ucp.getResource(path, false);
|
||||
|
@ -564,7 +564,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
* The same restriction to finding classes applies to resources
|
||||
*/
|
||||
URL url = AccessController.doPrivileged(
|
||||
new PrivilegedAction<URL>() {
|
||||
new PrivilegedAction<>() {
|
||||
public URL run() {
|
||||
return ucp.findResource(name, true);
|
||||
}
|
||||
|
@ -587,7 +587,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
{
|
||||
final Enumeration<URL> e = ucp.findResources(name, true);
|
||||
|
||||
return new Enumeration<URL>() {
|
||||
return new Enumeration<>() {
|
||||
private URL url = null;
|
||||
|
||||
private boolean next() {
|
||||
|
@ -596,7 +596,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
}
|
||||
do {
|
||||
URL u = AccessController.doPrivileged(
|
||||
new PrivilegedAction<URL>() {
|
||||
new PrivilegedAction<>() {
|
||||
public URL run() {
|
||||
if (!e.hasMoreElements())
|
||||
return null;
|
||||
|
@ -704,7 +704,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
final SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
final Permission fp = p;
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() throws SecurityException {
|
||||
sm.checkPermission(fp);
|
||||
return null;
|
||||
|
@ -735,7 +735,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
final AccessControlContext acc = AccessController.getContext();
|
||||
// Need a privileged block to create the class loader
|
||||
URLClassLoader ucl = AccessController.doPrivileged(
|
||||
new PrivilegedAction<URLClassLoader>() {
|
||||
new PrivilegedAction<>() {
|
||||
public URLClassLoader run() {
|
||||
return new FactoryURLClassLoader(urls, parent, acc);
|
||||
}
|
||||
|
@ -760,7 +760,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
final AccessControlContext acc = AccessController.getContext();
|
||||
// Need a privileged block to create the class loader
|
||||
URLClassLoader ucl = AccessController.doPrivileged(
|
||||
new PrivilegedAction<URLClassLoader>() {
|
||||
new PrivilegedAction<>() {
|
||||
public URLClassLoader run() {
|
||||
return new FactoryURLClassLoader(urls, acc);
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ public abstract class AsynchronousFileChannel
|
|||
public static AsynchronousFileChannel open(Path file, OpenOption... options)
|
||||
throws IOException
|
||||
{
|
||||
Set<OpenOption> set = new HashSet<OpenOption>(options.length);
|
||||
Set<OpenOption> set = new HashSet<>(options.length);
|
||||
Collections.addAll(set, options);
|
||||
return open(file, set, null, NO_ATTRIBUTES);
|
||||
}
|
||||
|
|
|
@ -330,7 +330,7 @@ public abstract class FileChannel
|
|||
public static FileChannel open(Path path, OpenOption... options)
|
||||
throws IOException
|
||||
{
|
||||
Set<OpenOption> set = new HashSet<OpenOption>(options.length);
|
||||
Set<OpenOption> set = new HashSet<>(options.length);
|
||||
Collections.addAll(set, options);
|
||||
return open(path, set, NO_ATTRIBUTES);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public abstract class AsynchronousChannelProvider {
|
|||
|
||||
private static AsynchronousChannelProvider load() {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<AsynchronousChannelProvider>() {
|
||||
.doPrivileged(new PrivilegedAction<>() {
|
||||
public AsynchronousChannelProvider run() {
|
||||
AsynchronousChannelProvider p;
|
||||
p = loadProviderFromProperty();
|
||||
|
|
|
@ -172,7 +172,7 @@ public abstract class SelectorProvider {
|
|||
if (provider != null)
|
||||
return provider;
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<SelectorProvider>() {
|
||||
new PrivilegedAction<>() {
|
||||
public SelectorProvider run() {
|
||||
if (loadProviderFromProperty())
|
||||
return provider;
|
||||
|
|
|
@ -335,7 +335,7 @@ public abstract class Charset
|
|||
// thrown. Should be invoked with full privileges.
|
||||
//
|
||||
private static Iterator<CharsetProvider> providers() {
|
||||
return new Iterator<CharsetProvider>() {
|
||||
return new Iterator<>() {
|
||||
|
||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||
ServiceLoader<CharsetProvider> sl =
|
||||
|
@ -404,7 +404,7 @@ public abstract class Charset
|
|||
gate.set(gate);
|
||||
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<Charset>() {
|
||||
new PrivilegedAction<>() {
|
||||
public Charset run() {
|
||||
for (Iterator<CharsetProvider> i = providers();
|
||||
i.hasNext();) {
|
||||
|
@ -428,7 +428,7 @@ public abstract class Charset
|
|||
// returns ExtendedProvider, if installed
|
||||
private static CharsetProvider extendedProvider() {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<CharsetProvider>() {
|
||||
new PrivilegedAction<>() {
|
||||
public CharsetProvider run() {
|
||||
try {
|
||||
Class<?> epc
|
||||
|
@ -570,10 +570,10 @@ public abstract class Charset
|
|||
*/
|
||||
public static SortedMap<String,Charset> availableCharsets() {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<SortedMap<String,Charset>>() {
|
||||
new PrivilegedAction<>() {
|
||||
public SortedMap<String,Charset> run() {
|
||||
TreeMap<String,Charset> m =
|
||||
new TreeMap<String,Charset>(
|
||||
new TreeMap<>(
|
||||
ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
|
||||
put(standardProvider.charsets(), m);
|
||||
CharsetProvider ecp = ExtendedProviderHolder.extendedProvider;
|
||||
|
@ -663,7 +663,7 @@ public abstract class Charset
|
|||
if (aliasSet != null)
|
||||
return aliasSet;
|
||||
int n = aliases.length;
|
||||
HashSet<String> hs = new HashSet<String>(n);
|
||||
HashSet<String> hs = new HashSet<>(n);
|
||||
for (int i = 0; i < n; i++)
|
||||
hs.add(aliases[i]);
|
||||
aliasSet = Collections.unmodifiableSet(hs);
|
||||
|
|
|
@ -204,13 +204,13 @@ public class CoderResult {
|
|||
WeakReference<CoderResult> w;
|
||||
CoderResult e = null;
|
||||
if (cache == null) {
|
||||
cache = new HashMap<Integer,WeakReference<CoderResult>>();
|
||||
cache = new HashMap<>();
|
||||
} else if ((w = cache.get(k)) != null) {
|
||||
e = w.get();
|
||||
}
|
||||
if (e == null) {
|
||||
e = create(len);
|
||||
cache.put(k, new WeakReference<CoderResult>(e));
|
||||
cache.put(k, new WeakReference<>(e));
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public final class FileSystems {
|
|||
private static FileSystem defaultFileSystem() {
|
||||
// load default provider
|
||||
FileSystemProvider provider = AccessController
|
||||
.doPrivileged(new PrivilegedAction<FileSystemProvider>() {
|
||||
.doPrivileged(new PrivilegedAction<>() {
|
||||
public FileSystemProvider run() {
|
||||
return getDefaultProvider();
|
||||
}
|
||||
|
|
|
@ -402,7 +402,7 @@ public final class Files {
|
|||
public static SeekableByteChannel newByteChannel(Path path, OpenOption... options)
|
||||
throws IOException
|
||||
{
|
||||
Set<OpenOption> set = new HashSet<OpenOption>(options.length);
|
||||
Set<OpenOption> set = new HashSet<>(options.length);
|
||||
Collections.addAll(set, options);
|
||||
return newByteChannel(path, set);
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ public final class Files {
|
|||
// create a matcher and return a filter that uses it.
|
||||
FileSystem fs = dir.getFileSystem();
|
||||
final PathMatcher matcher = fs.getPathMatcher("glob:" + glob);
|
||||
DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
|
||||
DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<>() {
|
||||
@Override
|
||||
public boolean accept(Path entry) {
|
||||
return matcher.matches(entry.getFileName());
|
||||
|
@ -1541,7 +1541,7 @@ public final class Files {
|
|||
// creates the default file type detector
|
||||
private static FileTypeDetector createDefaultFileTypeDetector() {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<FileTypeDetector>() {
|
||||
.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override public FileTypeDetector run() {
|
||||
return sun.nio.fs.DefaultFileTypeDetector.create();
|
||||
}});
|
||||
|
@ -1550,7 +1550,7 @@ public final class Files {
|
|||
// loads all installed file type detectors
|
||||
private static List<FileTypeDetector> loadInstalledDetectors() {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<List<FileTypeDetector>>() {
|
||||
.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override public List<FileTypeDetector> run() {
|
||||
List<FileTypeDetector> list = new ArrayList<>();
|
||||
ServiceLoader<FileTypeDetector> loader = ServiceLoader
|
||||
|
@ -3468,7 +3468,7 @@ public final class Files {
|
|||
final Iterator<Path> delegate = ds.iterator();
|
||||
|
||||
// Re-wrap DirectoryIteratorException to UncheckedIOException
|
||||
Iterator<Path> iterator = new Iterator<Path>() {
|
||||
Iterator<Path> iterator = new Iterator<>() {
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
try {
|
||||
|
|
|
@ -801,7 +801,7 @@ public interface Path
|
|||
*/
|
||||
@Override
|
||||
default Iterator<Path> iterator() {
|
||||
return new Iterator<Path>() {
|
||||
return new Iterator<>() {
|
||||
private int i = 0;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -306,7 +306,7 @@ public final class AclEntry {
|
|||
* @return the permissions component
|
||||
*/
|
||||
public Set<AclEntryPermission> permissions() {
|
||||
return new HashSet<AclEntryPermission>(perms);
|
||||
return new HashSet<>(perms);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -317,7 +317,7 @@ public final class AclEntry {
|
|||
* @return the flags component
|
||||
*/
|
||||
public Set<AclEntryFlag> flags() {
|
||||
return new HashSet<AclEntryFlag>(flags);
|
||||
return new HashSet<>(flags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -160,13 +160,13 @@ public final class PosixFilePermissions {
|
|||
{
|
||||
// copy set and check for nulls (CCE will be thrown if an element is not
|
||||
// a PosixFilePermission)
|
||||
perms = new HashSet<PosixFilePermission>(perms);
|
||||
perms = new HashSet<>(perms);
|
||||
for (PosixFilePermission p: perms) {
|
||||
if (p == null)
|
||||
throw new NullPointerException();
|
||||
}
|
||||
final Set<PosixFilePermission> value = perms;
|
||||
return new FileAttribute<Set<PosixFilePermission>>() {
|
||||
return new FileAttribute<>() {
|
||||
@Override
|
||||
public String name() {
|
||||
return "posix:permissions";
|
||||
|
|
|
@ -110,7 +110,7 @@ public abstract class FileSystemProvider {
|
|||
|
||||
// loads all installed providers
|
||||
private static List<FileSystemProvider> loadInstalledProviders() {
|
||||
List<FileSystemProvider> list = new ArrayList<FileSystemProvider>();
|
||||
List<FileSystemProvider> list = new ArrayList<>();
|
||||
|
||||
ServiceLoader<FileSystemProvider> sl = ServiceLoader
|
||||
.load(FileSystemProvider.class, ClassLoader.getSystemClassLoader());
|
||||
|
@ -163,7 +163,7 @@ public abstract class FileSystemProvider {
|
|||
loadingProviders = true;
|
||||
|
||||
List<FileSystemProvider> list = AccessController
|
||||
.doPrivileged(new PrivilegedAction<List<FileSystemProvider>>() {
|
||||
.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
public List<FileSystemProvider> run() {
|
||||
return loadInstalledProviders();
|
||||
|
@ -419,7 +419,7 @@ public abstract class FileSystemProvider {
|
|||
throws IOException
|
||||
{
|
||||
int len = options.length;
|
||||
Set<OpenOption> opts = new HashSet<OpenOption>(len + 3);
|
||||
Set<OpenOption> opts = new HashSet<>(len + 3);
|
||||
if (len == 0) {
|
||||
opts.add(StandardOpenOption.CREATE);
|
||||
opts.add(StandardOpenOption.TRUNCATE_EXISTING);
|
||||
|
|
|
@ -399,7 +399,7 @@ final class DateTimeParseContext {
|
|||
*/
|
||||
void addChronoChangedListener(Consumer<Chronology> listener) {
|
||||
if (chronoListeners == null) {
|
||||
chronoListeners = new ArrayList<Consumer<Chronology>>();
|
||||
chronoListeners = new ArrayList<>();
|
||||
}
|
||||
chronoListeners.add(listener);
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ public abstract class ZoneRulesProvider {
|
|||
// if the property java.time.zone.DefaultZoneRulesProvider is
|
||||
// set then its value is the class name of the default provider
|
||||
final List<ZoneRulesProvider> loaded = new ArrayList<>();
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Object run() {
|
||||
String prop = System.getProperty("java.time.zone.DefaultZoneRulesProvider");
|
||||
if (prop != null) {
|
||||
|
|
|
@ -3579,7 +3579,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
|
|||
ZoneInfo zi = null;
|
||||
try {
|
||||
zi = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<ZoneInfo>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
@Override
|
||||
public ZoneInfo run() throws Exception {
|
||||
return (ZoneInfo) input.readObject();
|
||||
|
|
|
@ -212,7 +212,7 @@ public final class Currency implements Serializable {
|
|||
private static final int VALID_FORMAT_VERSION = 2;
|
||||
|
||||
static {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
public Void run() {
|
||||
try {
|
||||
|
|
|
@ -2655,7 +2655,7 @@ public abstract class ResourceBundle {
|
|||
InputStream stream = null;
|
||||
try {
|
||||
stream = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<InputStream>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public InputStream run() throws IOException {
|
||||
InputStream is = null;
|
||||
if (reloadFlag) {
|
||||
|
|
|
@ -678,7 +678,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
|
|||
assert tz != null;
|
||||
|
||||
final String id = zoneID;
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
public Void run() {
|
||||
System.setProperty("user.timezone", id);
|
||||
|
|
|
@ -593,7 +593,7 @@ class JarFile extends ZipFile {
|
|||
if (includeUnsigned) {
|
||||
return unsignedEntryNames();
|
||||
} else {
|
||||
return new Enumeration<String>() {
|
||||
return new Enumeration<>() {
|
||||
|
||||
public boolean hasMoreElements() {
|
||||
return false;
|
||||
|
@ -619,7 +619,7 @@ class JarFile extends ZipFile {
|
|||
|
||||
// screen out entries which are never signed
|
||||
final Enumeration<? extends ZipEntry> enum_ = super.entries();
|
||||
return new Enumeration<JarEntry>() {
|
||||
return new Enumeration<>() {
|
||||
|
||||
ZipEntry entry;
|
||||
|
||||
|
@ -669,7 +669,7 @@ class JarFile extends ZipFile {
|
|||
|
||||
private Enumeration<String> unsignedEntryNames() {
|
||||
final Enumeration<JarEntry> entries = entries();
|
||||
return new Enumeration<String>() {
|
||||
return new Enumeration<>() {
|
||||
|
||||
String name;
|
||||
|
||||
|
|
|
@ -684,7 +684,7 @@ class JarVerifier {
|
|||
final List<CodeSigner[]> signersReq = req;
|
||||
final Enumeration<String> enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration;
|
||||
|
||||
return new Enumeration<String>() {
|
||||
return new Enumeration<>() {
|
||||
|
||||
String name;
|
||||
|
||||
|
@ -726,7 +726,7 @@ class JarVerifier {
|
|||
final Map<String, CodeSigner[]> map = new HashMap<>();
|
||||
map.putAll(signerMap());
|
||||
final Enumeration<? extends ZipEntry> enum_ = e;
|
||||
return new Enumeration<JarEntry>() {
|
||||
return new Enumeration<>() {
|
||||
|
||||
Enumeration<String> signers = null;
|
||||
JarEntry entry;
|
||||
|
@ -786,7 +786,7 @@ class JarVerifier {
|
|||
private Enumeration<String> unsignedEntryNames(JarFile jar) {
|
||||
final Map<String, CodeSigner[]> map = signerMap();
|
||||
final Enumeration<JarEntry> entries = jar.entries();
|
||||
return new Enumeration<String>() {
|
||||
return new Enumeration<>() {
|
||||
|
||||
String name;
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ public class Cleaner
|
|||
try {
|
||||
thunk.run();
|
||||
} catch (final Throwable x) {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
if (System.err != null)
|
||||
new Error("Cleaner terminated abnormally", x)
|
||||
|
|
|
@ -97,16 +97,16 @@ public class URLClassPath {
|
|||
}
|
||||
|
||||
/* The original search path of URLs. */
|
||||
private ArrayList<URL> path = new ArrayList<URL>();
|
||||
private ArrayList<URL> path = new ArrayList<>();
|
||||
|
||||
/* The stack of unopened URLs */
|
||||
Stack<URL> urls = new Stack<URL>();
|
||||
Stack<URL> urls = new Stack<>();
|
||||
|
||||
/* The resulting search path of Loaders */
|
||||
ArrayList<Loader> loaders = new ArrayList<Loader>();
|
||||
ArrayList<Loader> loaders = new ArrayList<>();
|
||||
|
||||
/* Map of each URL opened to its corresponding Loader */
|
||||
HashMap<String, Loader> lmap = new HashMap<String, Loader>();
|
||||
HashMap<String, Loader> lmap = new HashMap<>();
|
||||
|
||||
/* The jar protocol handler to use when creating new URLs */
|
||||
private URLStreamHandler jarHandler;
|
||||
|
@ -142,7 +142,7 @@ public class URLClassPath {
|
|||
if (closed) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<IOException> result = new LinkedList<IOException>();
|
||||
List<IOException> result = new LinkedList<>();
|
||||
for (Loader loader : loaders) {
|
||||
try {
|
||||
loader.close();
|
||||
|
@ -234,7 +234,7 @@ public class URLClassPath {
|
|||
*/
|
||||
public Enumeration<URL> findResources(final String name,
|
||||
final boolean check) {
|
||||
return new Enumeration<URL>() {
|
||||
return new Enumeration<>() {
|
||||
private int index = 0;
|
||||
private URL url = null;
|
||||
|
||||
|
@ -281,7 +281,7 @@ public class URLClassPath {
|
|||
*/
|
||||
public Enumeration<Resource> getResources(final String name,
|
||||
final boolean check) {
|
||||
return new Enumeration<Resource>() {
|
||||
return new Enumeration<>() {
|
||||
private int index = 0;
|
||||
private Resource res = null;
|
||||
|
||||
|
@ -374,7 +374,7 @@ public class URLClassPath {
|
|||
private Loader getLoader(final URL url) throws IOException {
|
||||
try {
|
||||
return java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<Loader>() {
|
||||
new java.security.PrivilegedExceptionAction<>() {
|
||||
public Loader run() throws IOException {
|
||||
String file = url.getFile();
|
||||
if (file != null && file.endsWith("/")) {
|
||||
|
@ -689,7 +689,7 @@ public class URLClassPath {
|
|||
if (jar == null) {
|
||||
try {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<Void>() {
|
||||
new java.security.PrivilegedExceptionAction<>() {
|
||||
public Void run() throws IOException {
|
||||
if (DEBUG) {
|
||||
System.err.println("Opening " + csu);
|
||||
|
@ -870,7 +870,7 @@ public class URLClassPath {
|
|||
if (index == null)
|
||||
return null;
|
||||
|
||||
HashSet<String> visited = new HashSet<String>();
|
||||
HashSet<String> visited = new HashSet<>();
|
||||
return getResource(name, check, visited);
|
||||
}
|
||||
|
||||
|
@ -912,7 +912,7 @@ public class URLClassPath {
|
|||
* before
|
||||
*/
|
||||
newLoader = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<JarLoader>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public JarLoader run() throws IOException {
|
||||
return new JarLoader(url, handler,
|
||||
lmap);
|
||||
|
|
|
@ -69,7 +69,7 @@ public class NetworkClient {
|
|||
final String encs[] = { null };
|
||||
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction<Void>() {
|
||||
new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
vals[0] = Integer.getInteger("sun.net.client.defaultReadTimeout", 0).intValue();
|
||||
vals[1] = Integer.getInteger("sun.net.client.defaultConnectTimeout", 0).intValue();
|
||||
|
@ -154,7 +154,7 @@ public class NetworkClient {
|
|||
if (proxy != null) {
|
||||
if (proxy.type() == Proxy.Type.SOCKS) {
|
||||
s = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Socket>() {
|
||||
new PrivilegedAction<>() {
|
||||
public Socket run() {
|
||||
return new Socket(proxy);
|
||||
}});
|
||||
|
@ -201,7 +201,7 @@ public class NetworkClient {
|
|||
if (serverSocket == null)
|
||||
throw new IOException("not connected");
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<InetAddress>() {
|
||||
new PrivilegedAction<>() {
|
||||
public InetAddress run() {
|
||||
return serverSocket.getLocalAddress();
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public class ProgressMonitor
|
|||
* Return a snapshot of the ProgressSource list
|
||||
*/
|
||||
public ArrayList<ProgressSource> getProgressSources() {
|
||||
ArrayList<ProgressSource> snapshot = new ArrayList<ProgressSource>();
|
||||
ArrayList<ProgressSource> snapshot = new ArrayList<>();
|
||||
|
||||
try {
|
||||
synchronized(progressSourceList) {
|
||||
|
@ -114,7 +114,7 @@ public class ProgressMonitor
|
|||
if (progressListenerList.size() > 0)
|
||||
{
|
||||
// Notify progress listener if there is progress change
|
||||
ArrayList<ProgressListener> listeners = new ArrayList<ProgressListener>();
|
||||
ArrayList<ProgressListener> listeners = new ArrayList<>();
|
||||
|
||||
// Copy progress listeners to another list to avoid holding locks
|
||||
synchronized(progressListenerList) {
|
||||
|
@ -151,7 +151,7 @@ public class ProgressMonitor
|
|||
if (progressListenerList.size() > 0)
|
||||
{
|
||||
// Notify progress listener if there is progress change
|
||||
ArrayList<ProgressListener> listeners = new ArrayList<ProgressListener>();
|
||||
ArrayList<ProgressListener> listeners = new ArrayList<>();
|
||||
|
||||
// Copy progress listeners to another list to avoid holding locks
|
||||
synchronized(progressListenerList) {
|
||||
|
@ -183,7 +183,7 @@ public class ProgressMonitor
|
|||
if (progressListenerList.size() > 0)
|
||||
{
|
||||
// Notify progress listener if there is progress change
|
||||
ArrayList<ProgressListener> listeners = new ArrayList<ProgressListener>();
|
||||
ArrayList<ProgressListener> listeners = new ArrayList<>();
|
||||
|
||||
// Copy progress listeners to another list to avoid holding locks
|
||||
synchronized(progressListenerList) {
|
||||
|
|
|
@ -244,7 +244,7 @@ class MessageHeader {
|
|||
public synchronized Map<String, List<String>> filterAndAddHeaders(
|
||||
String[] excludeList, Map<String, List<String>> include) {
|
||||
boolean skipIt = false;
|
||||
Map<String, List<String>> m = new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> m = new HashMap<>();
|
||||
for (int i = nkeys; --i >= 0;) {
|
||||
if (excludeList != null) {
|
||||
// check if the key is in the excludeList.
|
||||
|
@ -260,7 +260,7 @@ class MessageHeader {
|
|||
if (!skipIt) {
|
||||
List<String> l = m.get(keys[i]);
|
||||
if (l == null) {
|
||||
l = new ArrayList<String>();
|
||||
l = new ArrayList<>();
|
||||
m.put(keys[i], l);
|
||||
}
|
||||
l.add(values[i]);
|
||||
|
@ -274,7 +274,7 @@ class MessageHeader {
|
|||
for (Map.Entry<String,List<String>> entry: include.entrySet()) {
|
||||
List<String> l = m.get(entry.getKey());
|
||||
if (l == null) {
|
||||
l = new ArrayList<String>();
|
||||
l = new ArrayList<>();
|
||||
m.put(entry.getKey(), l);
|
||||
}
|
||||
l.addAll(entry.getValue());
|
||||
|
|
|
@ -64,7 +64,7 @@ public class HttpCapture {
|
|||
private static synchronized void init() {
|
||||
initialized = true;
|
||||
String rulesFile = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<String>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public String run() {
|
||||
return NetProperties.get("sun.net.http.captureRules");
|
||||
}
|
||||
|
@ -85,8 +85,8 @@ public class HttpCapture {
|
|||
String[] s = line.split(",");
|
||||
if (s.length == 2) {
|
||||
if (patterns == null) {
|
||||
patterns = new ArrayList<Pattern>();
|
||||
capFiles = new ArrayList<String>();
|
||||
patterns = new ArrayList<>();
|
||||
capFiles = new ArrayList<>();
|
||||
}
|
||||
patterns.add(Pattern.compile(s[0].trim()));
|
||||
capFiles.add(s[1].trim());
|
||||
|
|
|
@ -479,7 +479,7 @@ public class HttpClient extends NetworkClient {
|
|||
{
|
||||
try {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<Void>() {
|
||||
new java.security.PrivilegedExceptionAction<>() {
|
||||
public Void run() throws IOException {
|
||||
openServer(server.getHostString(), server.getPort());
|
||||
return null;
|
||||
|
|
|
@ -94,7 +94,7 @@ public class KeepAliveCache
|
|||
*/
|
||||
final KeepAliveCache cache = this;
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
keepAliveTimer = new InnocuousThread(cache, "Keep-Alive-Timer");
|
||||
keepAliveTimer.setDaemon(true);
|
||||
|
@ -178,7 +178,7 @@ public class KeepAliveCache
|
|||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
ArrayList<KeepAliveKey> keysToRemove
|
||||
= new ArrayList<KeepAliveKey>();
|
||||
= new ArrayList<>();
|
||||
|
||||
for (KeepAliveKey key : keySet()) {
|
||||
ClientVector v = get(key);
|
||||
|
|
|
@ -122,7 +122,7 @@ public class AuthenticationHeader {
|
|||
this.dontUseNegotiate = dontUseNegotiate;
|
||||
rsp = response;
|
||||
this.hdrname = hdrname;
|
||||
schemes = new HashMap<String,SchemeMapValue>();
|
||||
schemes = new HashMap<>();
|
||||
parse();
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class DigestAuthentication extends AuthenticationInfo {
|
|||
|
||||
static {
|
||||
Boolean b = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Boolean>() {
|
||||
new PrivilegedAction<>() {
|
||||
public Boolean run() {
|
||||
return NetProperties.getBoolean(compatPropName);
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||
new sun.security.action.GetBooleanAction(
|
||||
"sun.net.http.allowRestrictedHeaders")).booleanValue();
|
||||
if (!allowRestrictedHeaders) {
|
||||
restrictedHeaderSet = new HashSet<String>(restrictedHeaders.length);
|
||||
restrictedHeaderSet = new HashSet<>(restrictedHeaders.length);
|
||||
for (int i=0; i < restrictedHeaders.length; i++) {
|
||||
restrictedHeaderSet.add(restrictedHeaders[i].toLowerCase());
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||
final URL url,
|
||||
final RequestorType authType) {
|
||||
return java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<PasswordAuthentication>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public PasswordAuthentication run() {
|
||||
if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
|
||||
logger.finest("Requesting Authentication: host =" + host + " url = " + url);
|
||||
|
@ -817,14 +817,14 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||
} catch (SecurityException se) { /* swallow exception */ }
|
||||
} else {
|
||||
cookieHandler = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<CookieHandler>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public CookieHandler run() {
|
||||
return CookieHandler.getDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
cacheHandler = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<ResponseCache>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public ResponseCache run() {
|
||||
return ResponseCache.getDefault();
|
||||
}
|
||||
|
@ -909,7 +909,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||
final boolean result[] = {false};
|
||||
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
try {
|
||||
InetAddress a1 = InetAddress.getByName(h1);
|
||||
|
@ -954,7 +954,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||
try {
|
||||
// lookup hostname and use IP address if available
|
||||
host = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<String>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public String run() throws IOException {
|
||||
InetAddress addr = InetAddress.getByName(hostarg);
|
||||
return addr.getHostAddress();
|
||||
|
@ -984,7 +984,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||
if (p != null) {
|
||||
try {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<Void>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public Void run() throws IOException {
|
||||
plainConnect0();
|
||||
return null;
|
||||
|
@ -1086,7 +1086,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||
*/
|
||||
ProxySelector sel =
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<ProxySelector>() {
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public ProxySelector run() {
|
||||
return ProxySelector.getDefault();
|
||||
}
|
||||
|
@ -1245,7 +1245,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||
if (p != null) {
|
||||
try {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<OutputStream>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public OutputStream run() throws IOException {
|
||||
return getOutputStream0();
|
||||
}
|
||||
|
@ -1423,7 +1423,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||
if (p != null) {
|
||||
try {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<InputStream>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public InputStream run() throws IOException {
|
||||
return getInputStream0();
|
||||
}
|
||||
|
@ -1877,7 +1877,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||
final Object[] args = { rememberedException.getMessage() };
|
||||
IOException chainedException =
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<IOException>() {
|
||||
new java.security.PrivilegedExceptionAction<>() {
|
||||
public IOException run() throws Exception {
|
||||
return (IOException)
|
||||
rememberedException.getClass()
|
||||
|
@ -2204,7 +2204,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||
try {
|
||||
final String finalHost = host;
|
||||
addr = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<InetAddress>() {
|
||||
new java.security.PrivilegedExceptionAction<>() {
|
||||
public InetAddress run()
|
||||
throws java.net.UnknownHostException {
|
||||
return InetAddress.getByName(finalHost);
|
||||
|
@ -2566,7 +2566,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||
if (p != null) {
|
||||
try {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<Boolean>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public Boolean run() throws IOException {
|
||||
return followRedirect0(loc, stat, locUrl0);
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ public class URLJarFile extends JarFile {
|
|||
/* get the stream before asserting privileges */
|
||||
try (final InputStream in = url.openConnection().getInputStream()) {
|
||||
result = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<JarFile>() {
|
||||
new PrivilegedExceptionAction<>() {
|
||||
public JarFile run() throws IOException {
|
||||
Path tmpFile = Files.createTempFile("jar_cache", null);
|
||||
try {
|
||||
|
|
|
@ -76,7 +76,7 @@ abstract class AsynchronousChannelGroupImpl
|
|||
this.pool = pool;
|
||||
|
||||
if (pool.isFixedThreadPool()) {
|
||||
taskQueue = new ConcurrentLinkedQueue<Runnable>();
|
||||
taskQueue = new ConcurrentLinkedQueue<>();
|
||||
} else {
|
||||
taskQueue = null; // not used
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ abstract class AsynchronousChannelGroupImpl
|
|||
}
|
||||
|
||||
private void startInternalThread(final Runnable task) {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
public Void run() {
|
||||
// internal threads should not be visible to application so
|
||||
|
@ -246,7 +246,7 @@ abstract class AsynchronousChannelGroupImpl
|
|||
abstract void shutdownHandlerTasks();
|
||||
|
||||
private void shutdownExecutors() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
pool.executor().shutdown();
|
||||
timeoutExecutor.shutdown();
|
||||
|
@ -323,7 +323,7 @@ abstract class AsynchronousChannelGroupImpl
|
|||
task = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
public Void run() {
|
||||
delegate.run();
|
||||
|
|
|
@ -228,7 +228,7 @@ abstract class AsynchronousServerSocketChannelImpl
|
|||
static final Set<SocketOption<?>> defaultOptions = defaultOptions();
|
||||
|
||||
private static Set<SocketOption<?>> defaultOptions() {
|
||||
HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(2);
|
||||
HashSet<SocketOption<?>> set = new HashSet<>(2);
|
||||
set.add(StandardSocketOptions.SO_RCVBUF);
|
||||
set.add(StandardSocketOptions.SO_REUSEADDR);
|
||||
return Collections.unmodifiableSet(set);
|
||||
|
|
|
@ -503,7 +503,7 @@ abstract class AsynchronousSocketChannelImpl
|
|||
static final Set<SocketOption<?>> defaultOptions = defaultOptions();
|
||||
|
||||
private static Set<SocketOption<?>> defaultOptions() {
|
||||
HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(5);
|
||||
HashSet<SocketOption<?>> set = new HashSet<>(5);
|
||||
set.add(StandardSocketOptions.SO_SNDBUF);
|
||||
set.add(StandardSocketOptions.SO_RCVBUF);
|
||||
set.add(StandardSocketOptions.SO_KEEPALIVE);
|
||||
|
|
|
@ -294,7 +294,7 @@ class DatagramChannelImpl
|
|||
static final Set<SocketOption<?>> defaultOptions = defaultOptions();
|
||||
|
||||
private static Set<SocketOption<?>> defaultOptions() {
|
||||
HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
|
||||
HashSet<SocketOption<?>> set = new HashSet<>(8);
|
||||
set.add(StandardSocketOptions.SO_SNDBUF);
|
||||
set.add(StandardSocketOptions.SO_RCVBUF);
|
||||
set.add(StandardSocketOptions.SO_REUSEADDR);
|
||||
|
|
|
@ -184,7 +184,7 @@ class MembershipKeyImpl
|
|||
|
||||
// created blocked set if required and add source address
|
||||
if (blockedSet == null)
|
||||
blockedSet = new HashSet<InetAddress>();
|
||||
blockedSet = new HashSet<>();
|
||||
blockedSet.add(toBlock);
|
||||
}
|
||||
return this;
|
||||
|
|
|
@ -84,13 +84,13 @@ class MembershipRegistry {
|
|||
InetAddress group = key.group();
|
||||
List<MembershipKeyImpl> keys;
|
||||
if (groups == null) {
|
||||
groups = new HashMap<InetAddress,List<MembershipKeyImpl>>();
|
||||
groups = new HashMap<>();
|
||||
keys = null;
|
||||
} else {
|
||||
keys = groups.get(group);
|
||||
}
|
||||
if (keys == null) {
|
||||
keys = new LinkedList<MembershipKeyImpl>();
|
||||
keys = new LinkedList<>();
|
||||
groups.put(group, keys);
|
||||
}
|
||||
keys.add(key);
|
||||
|
|
|
@ -52,8 +52,8 @@ public abstract class SelectorImpl
|
|||
|
||||
protected SelectorImpl(SelectorProvider sp) {
|
||||
super(sp);
|
||||
keys = new HashSet<SelectionKey>();
|
||||
selectedKeys = new HashSet<SelectionKey>();
|
||||
keys = new HashSet<>();
|
||||
selectedKeys = new HashSet<>();
|
||||
if (Util.atBugLevel("1.4")) {
|
||||
publicKeys = keys;
|
||||
publicSelectedKeys = selectedKeys;
|
||||
|
|
|
@ -182,7 +182,7 @@ class ServerSocketChannelImpl
|
|||
static final Set<SocketOption<?>> defaultOptions = defaultOptions();
|
||||
|
||||
private static Set<SocketOption<?>> defaultOptions() {
|
||||
HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(2);
|
||||
HashSet<SocketOption<?>> set = new HashSet<>(2);
|
||||
set.add(StandardSocketOptions.SO_RCVBUF);
|
||||
set.add(StandardSocketOptions.SO_REUSEADDR);
|
||||
set.add(StandardSocketOptions.IP_TOS);
|
||||
|
|
|
@ -229,7 +229,7 @@ class SocketChannelImpl
|
|||
static final Set<SocketOption<?>> defaultOptions = defaultOptions();
|
||||
|
||||
private static Set<SocketOption<?>> defaultOptions() {
|
||||
HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
|
||||
HashSet<SocketOption<?>> set = new HashSet<>(8);
|
||||
set.add(StandardSocketOptions.SO_SNDBUF);
|
||||
set.add(StandardSocketOptions.SO_RCVBUF);
|
||||
set.add(StandardSocketOptions.SO_KEEPALIVE);
|
||||
|
|
|
@ -135,7 +135,7 @@ public class CharsetMapping {
|
|||
|
||||
// init the CharsetMapping object from the .dat binary file
|
||||
public static CharsetMapping get(final InputStream is) {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<CharsetMapping>() {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public CharsetMapping run() {
|
||||
return new CharsetMapping().load(is);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ abstract class AbstractPoller implements Runnable {
|
|||
private boolean shutdown;
|
||||
|
||||
protected AbstractPoller() {
|
||||
this.requestList = new LinkedList<Request>();
|
||||
this.requestList = new LinkedList<>();
|
||||
this.shutdown = false;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ abstract class AbstractPoller implements Runnable {
|
|||
*/
|
||||
public void start() {
|
||||
final Runnable thisRunnable = this;
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
public Object run() {
|
||||
Thread thr = new ManagedLocalsThread(thisRunnable);
|
||||
|
|
|
@ -70,8 +70,8 @@ abstract class AbstractWatchKey implements WatchKey {
|
|||
this.watcher = watcher;
|
||||
this.dir = dir;
|
||||
this.state = State.READY;
|
||||
this.events = new ArrayList<WatchEvent<?>>();
|
||||
this.lastModifyEvents = new HashMap<Object,WatchEvent<?>>();
|
||||
this.events = new ArrayList<>();
|
||||
this.lastModifyEvents = new HashMap<>();
|
||||
}
|
||||
|
||||
final AbstractWatchService watcher() {
|
||||
|
@ -146,7 +146,7 @@ abstract class AbstractWatchKey implements WatchKey {
|
|||
|
||||
// non-repeated event
|
||||
Event<Object> ev =
|
||||
new Event<Object>((WatchEvent.Kind<Object>)kind, context);
|
||||
new Event<>((WatchEvent.Kind<Object>)kind, context);
|
||||
if (isModify) {
|
||||
lastModifyEvents.put(context, ev);
|
||||
} else if (kind == StandardWatchEventKinds.OVERFLOW) {
|
||||
|
@ -163,7 +163,7 @@ abstract class AbstractWatchKey implements WatchKey {
|
|||
public final List<WatchEvent<?>> pollEvents() {
|
||||
synchronized (this) {
|
||||
List<WatchEvent<?>> result = events;
|
||||
events = new ArrayList<WatchEvent<?>>();
|
||||
events = new ArrayList<>();
|
||||
lastModifyEvents.clear();
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -375,7 +375,7 @@ public class ReflectionFactory {
|
|||
private static void checkInitted() {
|
||||
if (initted) return;
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction<Void>() {
|
||||
new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
// Tests to ensure the system properties table is fully
|
||||
// initialized. This is needed because reflection code is
|
||||
|
|
|
@ -106,16 +106,16 @@ public class AnnotationType {
|
|||
throw new IllegalArgumentException("Not an annotation type");
|
||||
|
||||
Method[] methods =
|
||||
AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Method[] run() {
|
||||
// Initialize memberTypes and defaultValues
|
||||
return annotationClass.getDeclaredMethods();
|
||||
}
|
||||
});
|
||||
|
||||
memberTypes = new HashMap<String,Class<?>>(methods.length+1, 1.0f);
|
||||
memberDefaults = new HashMap<String, Object>(0);
|
||||
members = new HashMap<String, Method>(methods.length+1, 1.0f);
|
||||
memberTypes = new HashMap<>(methods.length+1, 1.0f);
|
||||
memberDefaults = new HashMap<>(0);
|
||||
members = new HashMap<>(methods.length+1, 1.0f);
|
||||
|
||||
for (Method method : methods) {
|
||||
if (method.getParameterTypes().length != 0)
|
||||
|
|
|
@ -102,8 +102,8 @@ public abstract class Builder {
|
|||
|
||||
/**
|
||||
* Verifies whether the input certificate completes the path.
|
||||
* When building forward, a trust anchor will complete the path.
|
||||
* When building reverse, the target certificate will complete the path.
|
||||
* When building in the forward direction, a trust anchor will
|
||||
* complete the path.
|
||||
*
|
||||
* @param cert the certificate to test
|
||||
* @return a boolean value indicating whether the cert completes the path.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 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
|
||||
|
@ -25,7 +25,6 @@
|
|||
package sun.security.provider.certpath;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.PublicKey;
|
||||
import java.security.cert.*;
|
||||
import java.security.interfaces.DSAPublicKey;
|
||||
|
@ -194,7 +193,6 @@ class PKIX {
|
|||
|
||||
static class BuilderParams extends ValidatorParams {
|
||||
private PKIXBuilderParameters params;
|
||||
private boolean buildForward = true;
|
||||
private List<CertStore> stores;
|
||||
private X500Principal targetSubject;
|
||||
|
||||
|
@ -213,10 +211,6 @@ class PKIX {
|
|||
+ "targetCertConstraints parameter must be an "
|
||||
+ "X509CertSelector");
|
||||
}
|
||||
if (params instanceof SunCertPathBuilderParameters) {
|
||||
buildForward =
|
||||
((SunCertPathBuilderParameters)params).getBuildForward();
|
||||
}
|
||||
this.params = params;
|
||||
this.targetSubject = getTargetSubject(
|
||||
certStores(), (X509CertSelector)targetCertConstraints());
|
||||
|
@ -230,7 +224,6 @@ class PKIX {
|
|||
return stores;
|
||||
}
|
||||
int maxPathLength() { return params.getMaxPathLength(); }
|
||||
boolean buildForward() { return buildForward; }
|
||||
PKIXBuilderParameters params() { return params; }
|
||||
X500Principal targetSubject() { return targetSubject; }
|
||||
|
||||
|
|
|
@ -1,551 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2013, 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.provider.certpath;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.Principal;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertPathValidatorException;
|
||||
import java.security.cert.CertStore;
|
||||
import java.security.cert.CertStoreException;
|
||||
import java.security.cert.PKIXBuilderParameters;
|
||||
import java.security.cert.PKIXCertPathChecker;
|
||||
import java.security.cert.PKIXParameters;
|
||||
import java.security.cert.PKIXReason;
|
||||
import java.security.cert.TrustAnchor;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.security.cert.X509CertSelector;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
import sun.security.provider.certpath.PKIX.BuilderParams;
|
||||
import sun.security.util.Debug;
|
||||
import sun.security.x509.Extension;
|
||||
import static sun.security.x509.PKIXExtensions.*;
|
||||
import sun.security.x509.X500Name;
|
||||
import sun.security.x509.X509CertImpl;
|
||||
import sun.security.x509.PolicyMappingsExtension;
|
||||
|
||||
/**
|
||||
* This class represents a reverse builder, which is able to retrieve
|
||||
* matching certificates from CertStores and verify a particular certificate
|
||||
* against a ReverseState.
|
||||
*
|
||||
* @since 1.4
|
||||
* @author Sean Mullan
|
||||
* @author Yassir Elley
|
||||
*/
|
||||
|
||||
class ReverseBuilder extends Builder {
|
||||
|
||||
private Debug debug = Debug.getInstance("certpath");
|
||||
|
||||
private final Set<String> initPolicies;
|
||||
|
||||
/**
|
||||
* Initialize the builder with the input parameters.
|
||||
*
|
||||
* @param params the parameter set used to build a certification path
|
||||
*/
|
||||
ReverseBuilder(BuilderParams buildParams) {
|
||||
super(buildParams);
|
||||
|
||||
Set<String> initialPolicies = buildParams.initialPolicies();
|
||||
initPolicies = new HashSet<String>();
|
||||
if (initialPolicies.isEmpty()) {
|
||||
// if no initialPolicies are specified by user, set
|
||||
// initPolicies to be anyPolicy by default
|
||||
initPolicies.add(PolicyChecker.ANY_POLICY);
|
||||
} else {
|
||||
initPolicies.addAll(initialPolicies);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all certs from the specified CertStores that satisfy the
|
||||
* requirements specified in the parameters and the current
|
||||
* PKIX state (name constraints, policy constraints, etc).
|
||||
*
|
||||
* @param currentState the current state.
|
||||
* Must be an instance of <code>ReverseState</code>
|
||||
* @param certStores list of CertStores
|
||||
*/
|
||||
@Override
|
||||
Collection<X509Certificate> getMatchingCerts
|
||||
(State currState, List<CertStore> certStores)
|
||||
throws CertStoreException, CertificateException, IOException
|
||||
{
|
||||
ReverseState currentState = (ReverseState) currState;
|
||||
|
||||
if (debug != null)
|
||||
debug.println("In ReverseBuilder.getMatchingCerts.");
|
||||
|
||||
/*
|
||||
* The last certificate could be an EE or a CA certificate
|
||||
* (we may be building a partial certification path or
|
||||
* establishing trust in a CA).
|
||||
*
|
||||
* Try the EE certs before the CA certs. It will be more
|
||||
* common to build a path to an end entity.
|
||||
*/
|
||||
Collection<X509Certificate> certs =
|
||||
getMatchingEECerts(currentState, certStores);
|
||||
certs.addAll(getMatchingCACerts(currentState, certStores));
|
||||
|
||||
return certs;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieves all end-entity certificates which satisfy constraints
|
||||
* and requirements specified in the parameters and PKIX state.
|
||||
*/
|
||||
private Collection<X509Certificate> getMatchingEECerts
|
||||
(ReverseState currentState, List<CertStore> certStores)
|
||||
throws CertStoreException, CertificateException, IOException {
|
||||
|
||||
/*
|
||||
* Compose a CertSelector to filter out
|
||||
* certs which do not satisfy requirements.
|
||||
*
|
||||
* First, retrieve clone of current target cert constraints, and
|
||||
* then add more selection criteria based on current validation state.
|
||||
*/
|
||||
X509CertSelector sel = (X509CertSelector) targetCertConstraints.clone();
|
||||
|
||||
/*
|
||||
* Match on issuer (subject of previous cert)
|
||||
*/
|
||||
sel.setIssuer(currentState.subjectDN);
|
||||
|
||||
/*
|
||||
* Match on certificate validity date.
|
||||
*/
|
||||
sel.setCertificateValid(buildParams.date());
|
||||
|
||||
/*
|
||||
* Policy processing optimizations
|
||||
*/
|
||||
if (currentState.explicitPolicy == 0)
|
||||
sel.setPolicy(getMatchingPolicies());
|
||||
|
||||
/*
|
||||
* If previous cert has a subject key identifier extension,
|
||||
* use it to match on authority key identifier extension.
|
||||
*/
|
||||
/*if (currentState.subjKeyId != null) {
|
||||
AuthorityKeyIdentifierExtension authKeyId = new AuthorityKeyIdentifierExtension(
|
||||
(KeyIdentifier) currentState.subjKeyId.get(SubjectKeyIdentifierExtension.KEY_ID),
|
||||
null, null);
|
||||
sel.setAuthorityKeyIdentifier(authKeyId.getExtensionValue());
|
||||
}*/
|
||||
|
||||
/*
|
||||
* Require EE certs
|
||||
*/
|
||||
sel.setBasicConstraints(-2);
|
||||
|
||||
/* Retrieve matching certs from CertStores */
|
||||
HashSet<X509Certificate> eeCerts = new HashSet<>();
|
||||
addMatchingCerts(sel, certStores, eeCerts, true);
|
||||
|
||||
if (debug != null) {
|
||||
debug.println("ReverseBuilder.getMatchingEECerts got "
|
||||
+ eeCerts.size() + " certs.");
|
||||
}
|
||||
return eeCerts;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieves all CA certificates which satisfy constraints
|
||||
* and requirements specified in the parameters and PKIX state.
|
||||
*/
|
||||
private Collection<X509Certificate> getMatchingCACerts
|
||||
(ReverseState currentState, List<CertStore> certStores)
|
||||
throws CertificateException, CertStoreException, IOException {
|
||||
|
||||
/*
|
||||
* Compose a CertSelector to filter out
|
||||
* certs which do not satisfy requirements.
|
||||
*/
|
||||
X509CertSelector sel = new X509CertSelector();
|
||||
|
||||
/*
|
||||
* Match on issuer (subject of previous cert)
|
||||
*/
|
||||
sel.setIssuer(currentState.subjectDN);
|
||||
|
||||
/*
|
||||
* Match on certificate validity date.
|
||||
*/
|
||||
sel.setCertificateValid(buildParams.date());
|
||||
|
||||
/*
|
||||
* Match on target subject name (checks that current cert's
|
||||
* name constraints permit it to certify target).
|
||||
* (4 is the integer type for DIRECTORY name).
|
||||
*/
|
||||
byte[] subject = targetCertConstraints.getSubjectAsBytes();
|
||||
if (subject != null) {
|
||||
sel.addPathToName(4, subject);
|
||||
} else {
|
||||
X509Certificate cert = targetCertConstraints.getCertificate();
|
||||
if (cert != null) {
|
||||
sel.addPathToName(4,
|
||||
cert.getSubjectX500Principal().getEncoded());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Policy processing optimizations
|
||||
*/
|
||||
if (currentState.explicitPolicy == 0)
|
||||
sel.setPolicy(getMatchingPolicies());
|
||||
|
||||
/*
|
||||
* If previous cert has a subject key identifier extension,
|
||||
* use it to match on authority key identifier extension.
|
||||
*/
|
||||
/*if (currentState.subjKeyId != null) {
|
||||
AuthorityKeyIdentifierExtension authKeyId = new AuthorityKeyIdentifierExtension(
|
||||
(KeyIdentifier) currentState.subjKeyId.get(SubjectKeyIdentifierExtension.KEY_ID),
|
||||
null, null);
|
||||
sel.setAuthorityKeyIdentifier(authKeyId.getExtensionValue());
|
||||
}*/
|
||||
|
||||
/*
|
||||
* Require CA certs
|
||||
*/
|
||||
sel.setBasicConstraints(0);
|
||||
|
||||
/* Retrieve matching certs from CertStores */
|
||||
ArrayList<X509Certificate> reverseCerts = new ArrayList<>();
|
||||
addMatchingCerts(sel, certStores, reverseCerts, true);
|
||||
|
||||
/* Sort remaining certs using name constraints */
|
||||
Collections.sort(reverseCerts, new PKIXCertComparator());
|
||||
|
||||
if (debug != null)
|
||||
debug.println("ReverseBuilder.getMatchingCACerts got " +
|
||||
reverseCerts.size() + " certs.");
|
||||
return reverseCerts;
|
||||
}
|
||||
|
||||
/*
|
||||
* This inner class compares 2 PKIX certificates according to which
|
||||
* should be tried first when building a path to the target. For
|
||||
* now, the algorithm is to look at name constraints in each cert and those
|
||||
* which constrain the path closer to the target should be
|
||||
* ranked higher. Later, we may want to consider other components,
|
||||
* such as key identifiers.
|
||||
*/
|
||||
class PKIXCertComparator implements Comparator<X509Certificate> {
|
||||
|
||||
private Debug debug = Debug.getInstance("certpath");
|
||||
|
||||
@Override
|
||||
public int compare(X509Certificate cert1, X509Certificate cert2) {
|
||||
|
||||
/*
|
||||
* if either cert certifies the target, always
|
||||
* put at head of list.
|
||||
*/
|
||||
X500Principal targetSubject = buildParams.targetSubject();
|
||||
if (cert1.getSubjectX500Principal().equals(targetSubject)) {
|
||||
return -1;
|
||||
}
|
||||
if (cert2.getSubjectX500Principal().equals(targetSubject)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int targetDist1;
|
||||
int targetDist2;
|
||||
try {
|
||||
X500Name targetSubjectName = X500Name.asX500Name(targetSubject);
|
||||
targetDist1 = Builder.targetDistance(
|
||||
null, cert1, targetSubjectName);
|
||||
targetDist2 = Builder.targetDistance(
|
||||
null, cert2, targetSubjectName);
|
||||
} catch (IOException e) {
|
||||
if (debug != null) {
|
||||
debug.println("IOException in call to Builder.targetDistance");
|
||||
e.printStackTrace();
|
||||
}
|
||||
throw new ClassCastException
|
||||
("Invalid target subject distinguished name");
|
||||
}
|
||||
|
||||
if (targetDist1 == targetDist2)
|
||||
return 0;
|
||||
|
||||
if (targetDist1 == -1)
|
||||
return 1;
|
||||
|
||||
if (targetDist1 < targetDist2)
|
||||
return -1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies a matching certificate.
|
||||
*
|
||||
* This method executes any of the validation steps in the PKIX path validation
|
||||
* algorithm which were not satisfied via filtering out non-compliant
|
||||
* certificates with certificate matching rules.
|
||||
*
|
||||
* If the last certificate is being verified (the one whose subject
|
||||
* matches the target subject, then the steps in Section 6.1.4 of the
|
||||
* Certification Path Validation algorithm are NOT executed,
|
||||
* regardless of whether or not the last cert is an end-entity
|
||||
* cert or not. This allows callers to certify CA certs as
|
||||
* well as EE certs.
|
||||
*
|
||||
* @param cert the certificate to be verified
|
||||
* @param currentState the current state against which the cert is verified
|
||||
* @param certPathList the certPathList generated thus far
|
||||
*/
|
||||
@Override
|
||||
void verifyCert(X509Certificate cert, State currState,
|
||||
List<X509Certificate> certPathList)
|
||||
throws GeneralSecurityException
|
||||
{
|
||||
if (debug != null) {
|
||||
debug.println("ReverseBuilder.verifyCert(SN: "
|
||||
+ Debug.toHexString(cert.getSerialNumber())
|
||||
+ "\n Subject: " + cert.getSubjectX500Principal() + ")");
|
||||
}
|
||||
|
||||
ReverseState currentState = (ReverseState) currState;
|
||||
|
||||
/* we don't perform any validation of the trusted cert */
|
||||
if (currentState.isInitial()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't bother to verify untrusted certificate more.
|
||||
currentState.untrustedChecker.check(cert,
|
||||
Collections.<String>emptySet());
|
||||
|
||||
/*
|
||||
* check for looping - abort a loop if
|
||||
* ((we encounter the same certificate twice) AND
|
||||
* ((policyMappingInhibited = true) OR (no policy mapping
|
||||
* extensions can be found between the occurrences of the same
|
||||
* certificate)))
|
||||
* in order to facilitate the check to see if there are
|
||||
* any policy mapping extensions found between the occurrences
|
||||
* of the same certificate, we reverse the certpathlist first
|
||||
*/
|
||||
if ((certPathList != null) && (!certPathList.isEmpty())) {
|
||||
List<X509Certificate> reverseCertList = new ArrayList<>();
|
||||
for (X509Certificate c : certPathList) {
|
||||
reverseCertList.add(0, c);
|
||||
}
|
||||
|
||||
boolean policyMappingFound = false;
|
||||
for (X509Certificate cpListCert : reverseCertList) {
|
||||
X509CertImpl cpListCertImpl = X509CertImpl.toImpl(cpListCert);
|
||||
PolicyMappingsExtension policyMappingsExt =
|
||||
cpListCertImpl.getPolicyMappingsExtension();
|
||||
if (policyMappingsExt != null) {
|
||||
policyMappingFound = true;
|
||||
}
|
||||
if (debug != null)
|
||||
debug.println("policyMappingFound = " + policyMappingFound);
|
||||
if (cert.equals(cpListCert)) {
|
||||
if ((buildParams.policyMappingInhibited()) ||
|
||||
(!policyMappingFound)){
|
||||
if (debug != null)
|
||||
debug.println("loop detected!!");
|
||||
throw new CertPathValidatorException("loop detected");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* check if target cert */
|
||||
boolean finalCert = cert.getSubjectX500Principal().equals(buildParams.targetSubject());
|
||||
|
||||
/* check if CA cert */
|
||||
boolean caCert = (cert.getBasicConstraints() != -1 ? true : false);
|
||||
|
||||
/* if there are more certs to follow, verify certain constraints */
|
||||
if (!finalCert) {
|
||||
|
||||
/* check if CA cert */
|
||||
if (!caCert)
|
||||
throw new CertPathValidatorException("cert is NOT a CA cert");
|
||||
|
||||
/* If the certificate was not self-issued, verify that
|
||||
* remainingCerts is greater than zero
|
||||
*/
|
||||
if ((currentState.remainingCACerts <= 0) && !X509CertImpl.isSelfIssued(cert)) {
|
||||
throw new CertPathValidatorException
|
||||
("pathLenConstraint violated, path too long", null,
|
||||
null, -1, PKIXReason.PATH_TOO_LONG);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check keyUsage extension (only if CA cert and not final cert)
|
||||
*/
|
||||
KeyChecker.verifyCAKeyUsage(cert);
|
||||
|
||||
} else {
|
||||
|
||||
/*
|
||||
* If final cert, check that it satisfies specified target
|
||||
* constraints
|
||||
*/
|
||||
if (targetCertConstraints.match(cert) == false) {
|
||||
throw new CertPathValidatorException("target certificate " +
|
||||
"constraints check failed");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check revocation.
|
||||
*/
|
||||
if (buildParams.revocationEnabled() && currentState.revChecker != null) {
|
||||
currentState.revChecker.check(cert, Collections.<String>emptySet());
|
||||
}
|
||||
|
||||
/* Check name constraints if this is not a self-issued cert */
|
||||
if (finalCert || !X509CertImpl.isSelfIssued(cert)){
|
||||
if (currentState.nc != null) {
|
||||
try {
|
||||
if (!currentState.nc.verify(cert)){
|
||||
throw new CertPathValidatorException
|
||||
("name constraints check failed", null, null, -1,
|
||||
PKIXReason.INVALID_NAME);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
throw new CertPathValidatorException(ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check policy
|
||||
*/
|
||||
X509CertImpl certImpl = X509CertImpl.toImpl(cert);
|
||||
currentState.rootNode = PolicyChecker.processPolicies
|
||||
(currentState.certIndex, initPolicies,
|
||||
currentState.explicitPolicy, currentState.policyMapping,
|
||||
currentState.inhibitAnyPolicy,
|
||||
buildParams.policyQualifiersRejected(), currentState.rootNode,
|
||||
certImpl, finalCert);
|
||||
|
||||
/*
|
||||
* Check CRITICAL private extensions
|
||||
*/
|
||||
Set<String> unresolvedCritExts = cert.getCriticalExtensionOIDs();
|
||||
if (unresolvedCritExts == null) {
|
||||
unresolvedCritExts = Collections.<String>emptySet();
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that the signature algorithm is not disabled.
|
||||
*/
|
||||
currentState.algorithmChecker.check(cert, unresolvedCritExts);
|
||||
|
||||
for (PKIXCertPathChecker checker : currentState.userCheckers) {
|
||||
checker.check(cert, unresolvedCritExts);
|
||||
}
|
||||
|
||||
/*
|
||||
* Look at the remaining extensions and remove any ones we have
|
||||
* already checked. If there are any left, throw an exception!
|
||||
*/
|
||||
if (!unresolvedCritExts.isEmpty()) {
|
||||
unresolvedCritExts.remove(BasicConstraints_Id.toString());
|
||||
unresolvedCritExts.remove(NameConstraints_Id.toString());
|
||||
unresolvedCritExts.remove(CertificatePolicies_Id.toString());
|
||||
unresolvedCritExts.remove(PolicyMappings_Id.toString());
|
||||
unresolvedCritExts.remove(PolicyConstraints_Id.toString());
|
||||
unresolvedCritExts.remove(InhibitAnyPolicy_Id.toString());
|
||||
unresolvedCritExts.remove(SubjectAlternativeName_Id.toString());
|
||||
unresolvedCritExts.remove(KeyUsage_Id.toString());
|
||||
unresolvedCritExts.remove(ExtendedKeyUsage_Id.toString());
|
||||
|
||||
if (!unresolvedCritExts.isEmpty())
|
||||
throw new CertPathValidatorException
|
||||
("Unrecognized critical extension(s)", null, null, -1,
|
||||
PKIXReason.UNRECOGNIZED_CRIT_EXT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check signature.
|
||||
*/
|
||||
if (buildParams.sigProvider() != null) {
|
||||
cert.verify(currentState.pubKey, buildParams.sigProvider());
|
||||
} else {
|
||||
cert.verify(currentState.pubKey);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies whether the input certificate completes the path.
|
||||
* This checks whether the cert is the target certificate.
|
||||
*
|
||||
* @param cert the certificate to test
|
||||
* @return a boolean value indicating whether the cert completes the path.
|
||||
*/
|
||||
@Override
|
||||
boolean isPathCompleted(X509Certificate cert) {
|
||||
return cert.getSubjectX500Principal().equals(buildParams.targetSubject());
|
||||
}
|
||||
|
||||
/** Adds the certificate to the certPathList
|
||||
*
|
||||
* @param cert the certificate to be added
|
||||
* @param certPathList the certification path list
|
||||
*/
|
||||
@Override
|
||||
void addCertToPath(X509Certificate cert,
|
||||
LinkedList<X509Certificate> certPathList) {
|
||||
certPathList.addLast(cert);
|
||||
}
|
||||
|
||||
/** Removes final certificate from the certPathList
|
||||
*
|
||||
* @param certPathList the certification path list
|
||||
*/
|
||||
@Override
|
||||
void removeFinalCertFromPath(LinkedList<X509Certificate> certPathList) {
|
||||
certPathList.removeLast();
|
||||
}
|
||||
}
|
|
@ -1,406 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2013, 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.provider.certpath;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.PublicKey;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertPathValidatorException;
|
||||
import java.security.cert.PKIXCertPathChecker;
|
||||
import java.security.cert.PKIXRevocationChecker;
|
||||
import java.security.cert.TrustAnchor;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Set;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
import sun.security.provider.certpath.PKIX.BuilderParams;
|
||||
import sun.security.util.Debug;
|
||||
import sun.security.x509.NameConstraintsExtension;
|
||||
import sun.security.x509.SubjectKeyIdentifierExtension;
|
||||
import sun.security.x509.X509CertImpl;
|
||||
|
||||
/**
|
||||
* A specification of a reverse PKIX validation state
|
||||
* which is initialized by each build and updated each time a
|
||||
* certificate is added to the current path.
|
||||
* @since 1.4
|
||||
* @author Sean Mullan
|
||||
* @author Yassir Elley
|
||||
*/
|
||||
|
||||
class ReverseState implements State {
|
||||
|
||||
private static final Debug debug = Debug.getInstance("certpath");
|
||||
|
||||
/* The subject DN of the last cert in the path */
|
||||
X500Principal subjectDN;
|
||||
|
||||
/* The subject public key of the last cert */
|
||||
PublicKey pubKey;
|
||||
|
||||
/* The subject key identifier extension (if any) of the last cert */
|
||||
SubjectKeyIdentifierExtension subjKeyId;
|
||||
|
||||
/* The PKIX constrained/excluded subtrees state variable */
|
||||
NameConstraintsExtension nc;
|
||||
|
||||
/* The PKIX explicit policy, policy mapping, and inhibit_any-policy
|
||||
state variables */
|
||||
int explicitPolicy;
|
||||
int policyMapping;
|
||||
int inhibitAnyPolicy;
|
||||
int certIndex;
|
||||
PolicyNodeImpl rootNode;
|
||||
|
||||
/* The number of remaining CA certs which may follow in the path.
|
||||
* -1: previous cert was an EE cert
|
||||
* 0: only EE certs may follow.
|
||||
* >0 and <Integer.MAX_VALUE:no more than this number of CA certs may follow
|
||||
* Integer.MAX_VALUE: unlimited
|
||||
*/
|
||||
int remainingCACerts;
|
||||
|
||||
/* The list of user-defined checkers retrieved from the PKIXParameters
|
||||
* instance */
|
||||
ArrayList<PKIXCertPathChecker> userCheckers;
|
||||
|
||||
/* Flag indicating if state is initial (path is just starting) */
|
||||
private boolean init = true;
|
||||
|
||||
/* the checker used for revocation status */
|
||||
RevocationChecker revChecker;
|
||||
|
||||
/* the algorithm checker */
|
||||
AlgorithmChecker algorithmChecker;
|
||||
|
||||
/* the untrusted certificates checker */
|
||||
UntrustedChecker untrustedChecker;
|
||||
|
||||
/* the trust anchor used to validate the path */
|
||||
TrustAnchor trustAnchor;
|
||||
|
||||
/* Flag indicating if current cert can vouch for the CRL for
|
||||
* the next cert
|
||||
*/
|
||||
boolean crlSign = true;
|
||||
|
||||
/**
|
||||
* Returns a boolean flag indicating if the state is initial
|
||||
* (just starting)
|
||||
*
|
||||
* @return boolean flag indicating if the state is initial (just starting)
|
||||
*/
|
||||
@Override
|
||||
public boolean isInitial() {
|
||||
return init;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display state for debugging purposes
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("State [");
|
||||
sb.append("\n subjectDN of last cert: ").append(subjectDN);
|
||||
sb.append("\n subjectKeyIdentifier: ").append
|
||||
(String.valueOf(subjKeyId));
|
||||
sb.append("\n nameConstraints: ").append(String.valueOf(nc));
|
||||
sb.append("\n certIndex: ").append(certIndex);
|
||||
sb.append("\n explicitPolicy: ").append(explicitPolicy);
|
||||
sb.append("\n policyMapping: ").append(policyMapping);
|
||||
sb.append("\n inhibitAnyPolicy: ").append(inhibitAnyPolicy);
|
||||
sb.append("\n rootNode: ").append(rootNode);
|
||||
sb.append("\n remainingCACerts: ").append(remainingCACerts);
|
||||
sb.append("\n crlSign: ").append(crlSign);
|
||||
sb.append("\n init: ").append(init);
|
||||
sb.append("\n]\n");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the state.
|
||||
*
|
||||
* @param buildParams builder parameters
|
||||
*/
|
||||
public void initState(BuilderParams buildParams)
|
||||
throws CertPathValidatorException
|
||||
{
|
||||
/*
|
||||
* Initialize number of remainingCACerts.
|
||||
* Note that -1 maxPathLen implies unlimited.
|
||||
* 0 implies only an EE cert is acceptable.
|
||||
*/
|
||||
int maxPathLen = buildParams.maxPathLength();
|
||||
remainingCACerts = (maxPathLen == -1) ? Integer.MAX_VALUE
|
||||
: maxPathLen;
|
||||
|
||||
/* Initialize explicit policy state variable */
|
||||
if (buildParams.explicitPolicyRequired()) {
|
||||
explicitPolicy = 0;
|
||||
} else {
|
||||
// unconstrained if maxPathLen is -1,
|
||||
// otherwise, we want to initialize this to the value of the
|
||||
// longest possible path + 1 (i.e. maxpathlen + finalcert + 1)
|
||||
explicitPolicy = (maxPathLen == -1) ? maxPathLen : maxPathLen + 2;
|
||||
}
|
||||
|
||||
/* Initialize policy mapping state variable */
|
||||
if (buildParams.policyMappingInhibited()) {
|
||||
policyMapping = 0;
|
||||
} else {
|
||||
policyMapping = (maxPathLen == -1) ? maxPathLen : maxPathLen + 2;
|
||||
}
|
||||
|
||||
/* Initialize inhibit any policy state variable */
|
||||
if (buildParams.anyPolicyInhibited()) {
|
||||
inhibitAnyPolicy = 0;
|
||||
} else {
|
||||
inhibitAnyPolicy = (maxPathLen == -1) ? maxPathLen : maxPathLen + 2;
|
||||
}
|
||||
|
||||
/* Initialize certIndex */
|
||||
certIndex = 1;
|
||||
|
||||
/* Initialize policy tree */
|
||||
Set<String> initExpPolSet = new HashSet<>(1);
|
||||
initExpPolSet.add(PolicyChecker.ANY_POLICY);
|
||||
|
||||
rootNode = new PolicyNodeImpl(null, PolicyChecker.ANY_POLICY, null,
|
||||
false, initExpPolSet, false);
|
||||
|
||||
/*
|
||||
* Initialize each user-defined checker
|
||||
* Shallow copy the checkers
|
||||
*/
|
||||
userCheckers = new ArrayList<>(buildParams.certPathCheckers());
|
||||
/* initialize each checker (just in case) */
|
||||
for (PKIXCertPathChecker checker : userCheckers) {
|
||||
checker.init(false);
|
||||
}
|
||||
|
||||
/* Start by trusting the cert to sign CRLs */
|
||||
crlSign = true;
|
||||
|
||||
init = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the state with the specified trust anchor.
|
||||
*
|
||||
* @param anchor the most-trusted CA
|
||||
* @param buildParams builder parameters
|
||||
*/
|
||||
public void updateState(TrustAnchor anchor, BuilderParams buildParams)
|
||||
throws CertificateException, IOException, CertPathValidatorException
|
||||
{
|
||||
trustAnchor = anchor;
|
||||
X509Certificate trustedCert = anchor.getTrustedCert();
|
||||
if (trustedCert != null) {
|
||||
updateState(trustedCert);
|
||||
} else {
|
||||
X500Principal caName = anchor.getCA();
|
||||
updateState(anchor.getCAPublicKey(), caName);
|
||||
}
|
||||
|
||||
// The user specified AlgorithmChecker and RevocationChecker may not be
|
||||
// able to set the trust anchor until now.
|
||||
boolean revCheckerAdded = false;
|
||||
for (PKIXCertPathChecker checker : userCheckers) {
|
||||
if (checker instanceof AlgorithmChecker) {
|
||||
((AlgorithmChecker)checker).trySetTrustAnchor(anchor);
|
||||
} else if (checker instanceof PKIXRevocationChecker) {
|
||||
if (revCheckerAdded) {
|
||||
throw new CertPathValidatorException(
|
||||
"Only one PKIXRevocationChecker can be specified");
|
||||
}
|
||||
// if it's our own, initialize it
|
||||
if (checker instanceof RevocationChecker) {
|
||||
((RevocationChecker)checker).init(anchor, buildParams);
|
||||
}
|
||||
((PKIXRevocationChecker)checker).init(false);
|
||||
revCheckerAdded = true;
|
||||
}
|
||||
}
|
||||
|
||||
// only create a RevocationChecker if revocation is enabled and
|
||||
// a PKIXRevocationChecker has not already been added
|
||||
if (buildParams.revocationEnabled() && !revCheckerAdded) {
|
||||
revChecker = new RevocationChecker(anchor, buildParams);
|
||||
revChecker.init(false);
|
||||
}
|
||||
|
||||
init = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the state. This method is used when the most-trusted CA is
|
||||
* a trusted public-key and caName, instead of a trusted cert.
|
||||
*
|
||||
* @param pubKey the public key of the trusted CA
|
||||
* @param subjectDN the subject distinguished name of the trusted CA
|
||||
*/
|
||||
private void updateState(PublicKey pubKey, X500Principal subjectDN) {
|
||||
|
||||
/* update subject DN */
|
||||
this.subjectDN = subjectDN;
|
||||
|
||||
/* update subject public key */
|
||||
this.pubKey = pubKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the state with the next certificate added to the path.
|
||||
*
|
||||
* @param cert the certificate which is used to update the state
|
||||
*/
|
||||
public void updateState(X509Certificate cert)
|
||||
throws CertificateException, IOException, CertPathValidatorException {
|
||||
|
||||
if (cert == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* update subject DN */
|
||||
subjectDN = cert.getSubjectX500Principal();
|
||||
|
||||
/* check for key needing to inherit alg parameters */
|
||||
X509CertImpl icert = X509CertImpl.toImpl(cert);
|
||||
PublicKey newKey = cert.getPublicKey();
|
||||
if (PKIX.isDSAPublicKeyWithoutParams(newKey)) {
|
||||
newKey = BasicChecker.makeInheritedParamsKey(newKey, pubKey);
|
||||
}
|
||||
|
||||
/* update subject public key */
|
||||
pubKey = newKey;
|
||||
|
||||
/*
|
||||
* if this is a trusted cert (init == true), then we
|
||||
* don't update any of the remaining fields
|
||||
*/
|
||||
if (init) {
|
||||
init = false;
|
||||
return;
|
||||
}
|
||||
|
||||
/* update subject key identifier */
|
||||
subjKeyId = icert.getSubjectKeyIdentifierExtension();
|
||||
|
||||
/* update crlSign */
|
||||
crlSign = RevocationChecker.certCanSignCrl(cert);
|
||||
|
||||
/* update current name constraints */
|
||||
if (nc != null) {
|
||||
nc.merge(icert.getNameConstraintsExtension());
|
||||
} else {
|
||||
nc = icert.getNameConstraintsExtension();
|
||||
if (nc != null) {
|
||||
// Make sure we do a clone here, because we're probably
|
||||
// going to modify this object later and we don't want to
|
||||
// be sharing it with a Certificate object!
|
||||
nc = (NameConstraintsExtension) nc.clone();
|
||||
}
|
||||
}
|
||||
|
||||
/* update policy state variables */
|
||||
explicitPolicy =
|
||||
PolicyChecker.mergeExplicitPolicy(explicitPolicy, icert, false);
|
||||
policyMapping =
|
||||
PolicyChecker.mergePolicyMapping(policyMapping, icert);
|
||||
inhibitAnyPolicy =
|
||||
PolicyChecker.mergeInhibitAnyPolicy(inhibitAnyPolicy, icert);
|
||||
certIndex++;
|
||||
|
||||
/*
|
||||
* Update remaining CA certs
|
||||
*/
|
||||
remainingCACerts =
|
||||
ConstraintsChecker.mergeBasicConstraints(cert, remainingCACerts);
|
||||
|
||||
init = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean flag indicating if a key lacking necessary key
|
||||
* algorithm parameters has been encountered.
|
||||
*
|
||||
* @return boolean flag indicating if key lacking parameters encountered.
|
||||
*/
|
||||
@Override
|
||||
public boolean keyParamsNeeded() {
|
||||
/* when building in reverse, we immediately get parameters needed
|
||||
* or else throw an exception
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clone current state. The state is cloned as each cert is
|
||||
* added to the path. This is necessary if backtracking occurs,
|
||||
* and a prior state needs to be restored.
|
||||
*
|
||||
* Note that this is a SMART clone. Not all fields are fully copied,
|
||||
* because some of them (e.g., subjKeyId) will
|
||||
* not have their contents modified by subsequent calls to updateState.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
|
||||
public Object clone() {
|
||||
try {
|
||||
ReverseState clonedState = (ReverseState) super.clone();
|
||||
|
||||
/* clone checkers, if cloneable */
|
||||
clonedState.userCheckers =
|
||||
(ArrayList<PKIXCertPathChecker>)userCheckers.clone();
|
||||
ListIterator<PKIXCertPathChecker> li =
|
||||
clonedState.userCheckers.listIterator();
|
||||
while (li.hasNext()) {
|
||||
PKIXCertPathChecker checker = li.next();
|
||||
if (checker instanceof Cloneable) {
|
||||
li.set((PKIXCertPathChecker)checker.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/* make copy of name constraints */
|
||||
if (nc != null) {
|
||||
clonedState.nc = (NameConstraintsExtension) nc.clone();
|
||||
}
|
||||
|
||||
/* make copy of policy tree */
|
||||
if (rootNode != null) {
|
||||
clonedState.rootNode = rootNode.copyTree();
|
||||
}
|
||||
|
||||
return clonedState;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,8 +35,6 @@ import java.security.cert.PKIXReason;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
@ -47,8 +45,7 @@ import static sun.security.x509.PKIXExtensions.*;
|
|||
import sun.security.util.Debug;
|
||||
|
||||
/**
|
||||
* This class is able to build certification paths in either the forward
|
||||
* or reverse directions.
|
||||
* This class builds certification paths in the forward direction.
|
||||
*
|
||||
* <p> If successful, it returns a certification path which has successfully
|
||||
* satisfied all the constraints and requirements specified in the
|
||||
|
@ -102,10 +99,8 @@ public final class SunCertPathBuilder extends CertPathBuilderSpi {
|
|||
/**
|
||||
* Attempts to build a certification path using the Sun build
|
||||
* algorithm from a trusted anchor(s) to a target subject, which must both
|
||||
* be specified in the input parameter set. By default, this method will
|
||||
* attempt to build in the forward direction. In order to build in the
|
||||
* reverse direction, the caller needs to pass in an instance of
|
||||
* SunCertPathBuilderParameters with the buildForward flag set to false.
|
||||
* be specified in the input parameter set. This method will
|
||||
* attempt to build in the forward direction: from the target to the CA.
|
||||
*
|
||||
* <p>The certification path that is constructed is validated
|
||||
* according to the PKIX specification.
|
||||
|
@ -162,11 +157,7 @@ public final class SunCertPathBuilder extends CertPathBuilderSpi {
|
|||
policyTreeResult = null;
|
||||
LinkedList<X509Certificate> certPathList = new LinkedList<>();
|
||||
try {
|
||||
if (buildParams.buildForward()) {
|
||||
buildForward(adjList, certPathList, searchAllCertStores);
|
||||
} else {
|
||||
buildReverse(adjList, certPathList);
|
||||
}
|
||||
buildForward(adjList, certPathList, searchAllCertStores);
|
||||
} catch (GeneralSecurityException | IOException e) {
|
||||
if (debug != null) {
|
||||
debug.println("SunCertPathBuilder.engineBuild() exception in "
|
||||
|
@ -209,81 +200,6 @@ public final class SunCertPathBuilder extends CertPathBuilderSpi {
|
|||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Private build reverse method.
|
||||
*/
|
||||
private void buildReverse(List<List<Vertex>> adjacencyList,
|
||||
LinkedList<X509Certificate> certPathList)
|
||||
throws GeneralSecurityException, IOException
|
||||
{
|
||||
if (debug != null) {
|
||||
debug.println("SunCertPathBuilder.buildReverse()...");
|
||||
debug.println("SunCertPathBuilder.buildReverse() InitialPolicies: "
|
||||
+ buildParams.initialPolicies());
|
||||
}
|
||||
|
||||
ReverseState currentState = new ReverseState();
|
||||
/* Initialize adjacency list */
|
||||
adjacencyList.clear();
|
||||
adjacencyList.add(new LinkedList<Vertex>());
|
||||
|
||||
/*
|
||||
* Perform a search using each trust anchor, until a valid
|
||||
* path is found
|
||||
*/
|
||||
Iterator<TrustAnchor> iter = buildParams.trustAnchors().iterator();
|
||||
while (iter.hasNext()) {
|
||||
TrustAnchor anchor = iter.next();
|
||||
|
||||
/* check if anchor satisfies target constraints */
|
||||
if (anchorIsTarget(anchor, buildParams.targetCertConstraints())) {
|
||||
this.trustAnchor = anchor;
|
||||
this.pathCompleted = true;
|
||||
this.finalPublicKey = anchor.getTrustedCert().getPublicKey();
|
||||
break;
|
||||
}
|
||||
|
||||
// skip anchor if it contains a DSA key with no DSA params
|
||||
X509Certificate trustedCert = anchor.getTrustedCert();
|
||||
PublicKey pubKey = trustedCert != null ? trustedCert.getPublicKey()
|
||||
: anchor.getCAPublicKey();
|
||||
|
||||
if (PKIX.isDSAPublicKeyWithoutParams(pubKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Initialize current state */
|
||||
currentState.initState(buildParams);
|
||||
currentState.updateState(anchor, buildParams);
|
||||
|
||||
currentState.algorithmChecker = new AlgorithmChecker(anchor);
|
||||
currentState.untrustedChecker = new UntrustedChecker();
|
||||
try {
|
||||
depthFirstSearchReverse(null, currentState,
|
||||
new ReverseBuilder(buildParams),
|
||||
adjacencyList, certPathList);
|
||||
} catch (GeneralSecurityException | IOException e) {
|
||||
// continue on error if more anchors to try
|
||||
if (iter.hasNext())
|
||||
continue;
|
||||
else
|
||||
throw e;
|
||||
}
|
||||
|
||||
// break out of loop if search is successful
|
||||
if (pathCompleted) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug != null) {
|
||||
debug.println("SunCertPathBuilder.buildReverse() returned from "
|
||||
+ "depthFirstSearchReverse()");
|
||||
debug.println("SunCertPathBuilder.buildReverse() "
|
||||
+ "certPathList.size: " + certPathList.size());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Private build forward method.
|
||||
*/
|
||||
|
@ -631,147 +547,6 @@ public final class SunCertPathBuilder extends CertPathBuilderSpi {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This method performs a depth first search for a certification
|
||||
* path while building reverse which meets the requirements set in
|
||||
* the parameters object.
|
||||
* It uses an adjacency list to store all certificates which were
|
||||
* tried (i.e. at one time added to the path - they may not end up in
|
||||
* the final path if backtracking occurs). This information can
|
||||
* be used later to debug or demo the build.
|
||||
*
|
||||
* See "Data Structure and Algorithms, by Aho, Hopcroft, and Ullman"
|
||||
* for an explanation of the DFS algorithm.
|
||||
*
|
||||
* @param dN the distinguished name being currently searched for certs
|
||||
* @param currentState the current PKIX validation state
|
||||
*/
|
||||
private void depthFirstSearchReverse(X500Principal dN,
|
||||
ReverseState currentState,
|
||||
ReverseBuilder builder,
|
||||
List<List<Vertex>> adjList,
|
||||
LinkedList<X509Certificate> cpList)
|
||||
throws GeneralSecurityException, IOException
|
||||
{
|
||||
if (debug != null)
|
||||
debug.println("SunCertPathBuilder.depthFirstSearchReverse(" + dN
|
||||
+ ", " + currentState.toString() + ")");
|
||||
|
||||
/*
|
||||
* Find all the certificates issued by dN which
|
||||
* satisfy the PKIX certification path constraints.
|
||||
*/
|
||||
Collection<X509Certificate> certs =
|
||||
builder.getMatchingCerts(currentState, buildParams.certStores());
|
||||
List<Vertex> vertices = addVertices(certs, adjList);
|
||||
if (debug != null)
|
||||
debug.println("SunCertPathBuilder.depthFirstSearchReverse(): "
|
||||
+ "certs.size=" + vertices.size());
|
||||
|
||||
/*
|
||||
* For each cert in the collection, verify anything
|
||||
* that hasn't been checked yet (signature, revocation, etc)
|
||||
* and check for loops. Call depthFirstSearchReverse()
|
||||
* recursively for each good cert.
|
||||
*/
|
||||
for (Vertex vertex : vertices) {
|
||||
/**
|
||||
* Restore state to currentState each time through the loop.
|
||||
* This is important because some of the user-defined
|
||||
* checkers modify the state, which MUST be restored if
|
||||
* the cert eventually fails to lead to the target and
|
||||
* the next matching cert is tried.
|
||||
*/
|
||||
ReverseState nextState = (ReverseState) currentState.clone();
|
||||
X509Certificate cert = vertex.getCertificate();
|
||||
try {
|
||||
builder.verifyCert(cert, nextState, cpList);
|
||||
} catch (GeneralSecurityException gse) {
|
||||
if (debug != null)
|
||||
debug.println("SunCertPathBuilder.depthFirstSearchReverse()"
|
||||
+ ": validation failed: " + gse);
|
||||
vertex.setThrowable(gse);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Certificate is good, add it to the path (if it isn't a
|
||||
* self-signed cert) and update state
|
||||
*/
|
||||
if (!currentState.isInitial())
|
||||
builder.addCertToPath(cert, cpList);
|
||||
// save trust anchor
|
||||
this.trustAnchor = currentState.trustAnchor;
|
||||
|
||||
/*
|
||||
* Check if path is completed, return ASAP if so.
|
||||
*/
|
||||
if (builder.isPathCompleted(cert)) {
|
||||
if (debug != null)
|
||||
debug.println("SunCertPathBuilder.depthFirstSearchReverse()"
|
||||
+ ": path completed!");
|
||||
pathCompleted = true;
|
||||
|
||||
PolicyNodeImpl rootNode = nextState.rootNode;
|
||||
|
||||
if (rootNode == null)
|
||||
policyTreeResult = null;
|
||||
else {
|
||||
policyTreeResult = rootNode.copyTree();
|
||||
((PolicyNodeImpl)policyTreeResult).setImmutable();
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract and save the final target public key
|
||||
*/
|
||||
finalPublicKey = cert.getPublicKey();
|
||||
if (PKIX.isDSAPublicKeyWithoutParams(finalPublicKey)) {
|
||||
finalPublicKey =
|
||||
BasicChecker.makeInheritedParamsKey
|
||||
(finalPublicKey, currentState.pubKey);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update the PKIX state */
|
||||
nextState.updateState(cert);
|
||||
|
||||
/*
|
||||
* Append an entry for cert in adjacency list and
|
||||
* set index for current vertex.
|
||||
*/
|
||||
adjList.add(new LinkedList<Vertex>());
|
||||
vertex.setIndex(adjList.size() - 1);
|
||||
|
||||
/* recursively search for matching certs at next dN */
|
||||
depthFirstSearchReverse(cert.getSubjectX500Principal(), nextState,
|
||||
builder, adjList, cpList);
|
||||
|
||||
/*
|
||||
* If path has been completed, return ASAP!
|
||||
*/
|
||||
if (pathCompleted) {
|
||||
return;
|
||||
} else {
|
||||
/*
|
||||
* If we get here, it means we have searched all possible
|
||||
* certs issued by the dN w/o finding any matching certs. This
|
||||
* means we have to backtrack to the previous cert in the path
|
||||
* and try some other paths.
|
||||
*/
|
||||
if (debug != null)
|
||||
debug.println("SunCertPathBuilder.depthFirstSearchReverse()"
|
||||
+ ": backtracking");
|
||||
if (!currentState.isInitial())
|
||||
builder.removeFinalCertFromPath(cpList);
|
||||
}
|
||||
}
|
||||
if (debug != null)
|
||||
debug.println("SunCertPathBuilder.depthFirstSearchReverse() all "
|
||||
+ "certs in this adjacency list checked");
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a collection of matching certificates to the
|
||||
* adjacency list.
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2012, 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.provider.certpath;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.cert.*;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This class specifies the set of parameters used as input for the Sun
|
||||
* certification path build algorithm. It is identical to PKIXBuilderParameters
|
||||
* with the addition of a <code>buildForward</code> parameter which allows
|
||||
* the caller to specify whether or not the path should be constructed in
|
||||
* the forward direction.
|
||||
*
|
||||
* The default for the <code>buildForward</code> parameter is
|
||||
* true, which means that the build algorithm should construct paths
|
||||
* from the target subject back to the trusted anchor.
|
||||
*
|
||||
* @since 1.4
|
||||
* @author Sean Mullan
|
||||
* @author Yassir Elley
|
||||
*/
|
||||
public class SunCertPathBuilderParameters extends PKIXBuilderParameters {
|
||||
|
||||
private boolean buildForward = true;
|
||||
|
||||
/**
|
||||
* Creates an instance of <code>SunCertPathBuilderParameters</code> with the
|
||||
* specified parameter values.
|
||||
*
|
||||
* @param trustAnchors a <code>Set</code> of <code>TrustAnchor</code>s
|
||||
* @param targetConstraints a <code>CertSelector</code> specifying the
|
||||
* constraints on the target certificate
|
||||
* @throws InvalidAlgorithmParameterException if the specified
|
||||
* <code>Set</code> is empty <code>(trustAnchors.isEmpty() == true)</code>
|
||||
* @throws NullPointerException if the specified <code>Set</code> is
|
||||
* <code>null</code>
|
||||
* @throws ClassCastException if any of the elements in the <code>Set</code>
|
||||
* are not of type <code>java.security.cert.TrustAnchor</code>
|
||||
*/
|
||||
public SunCertPathBuilderParameters(Set<TrustAnchor> trustAnchors,
|
||||
CertSelector targetConstraints) throws InvalidAlgorithmParameterException
|
||||
{
|
||||
super(trustAnchors, targetConstraints);
|
||||
setBuildForward(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of <code>SunCertPathBuilderParameters</code> that
|
||||
* uses the specified <code>KeyStore</code> to populate the set
|
||||
* of most-trusted CA certificates.
|
||||
*
|
||||
* @param keystore A keystore from which the set of most-trusted
|
||||
* CA certificates will be populated.
|
||||
* @param targetConstraints a <code>CertSelector</code> specifying the
|
||||
* constraints on the target certificate
|
||||
* @throws KeyStoreException if the keystore has not been initialized.
|
||||
* @throws InvalidAlgorithmParameterException if the keystore does
|
||||
* not contain at least one trusted certificate entry
|
||||
* @throws NullPointerException if the keystore is <code>null</code>
|
||||
*/
|
||||
public SunCertPathBuilderParameters(KeyStore keystore,
|
||||
CertSelector targetConstraints)
|
||||
throws KeyStoreException, InvalidAlgorithmParameterException
|
||||
{
|
||||
super(keystore, targetConstraints);
|
||||
setBuildForward(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the buildForward flag.
|
||||
*
|
||||
* @return the value of the buildForward flag
|
||||
*/
|
||||
public boolean getBuildForward() {
|
||||
return this.buildForward;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the buildForward flag. If true, paths
|
||||
* are built from the target subject to the trusted anchor.
|
||||
* If false, paths are built from the trusted anchor to the
|
||||
* target subject. The default value if not specified is true.
|
||||
*
|
||||
* @param buildForward the value of the buildForward flag
|
||||
*/
|
||||
public void setBuildForward(boolean buildForward) {
|
||||
this.buildForward = buildForward;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatted string describing the parameters.
|
||||
*
|
||||
* @return a formatted string describing the parameters.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("[\n");
|
||||
sb.append(super.toString());
|
||||
sb.append(" Build Forward Flag: " + String.valueOf(buildForward) + "\n");
|
||||
sb.append("]\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue