8048199: Replace anonymous inner classes with lambdas, where applicable, in JNDI
Reviewed-by: rriggs, dfuchs, aefimov, chegar
This commit is contained in:
parent
6293299dd3
commit
4e90d74000
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -59,12 +59,8 @@ final class LdapBindingEnumeration
|
|||||||
if (attrs.get(Obj.JAVA_ATTRIBUTES[Obj.CLASSNAME]) != null) {
|
if (attrs.get(Obj.JAVA_ATTRIBUTES[Obj.CLASSNAME]) != null) {
|
||||||
// serialized object or object reference
|
// serialized object or object reference
|
||||||
try {
|
try {
|
||||||
obj = AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
|
PrivilegedExceptionAction<Object> pa = () -> Obj.decodeObject(attrs);
|
||||||
@Override
|
obj = AccessController.doPrivileged(pa, acc);
|
||||||
public Object run() throws NamingException {
|
|
||||||
return Obj.decodeObject(attrs);
|
|
||||||
}
|
|
||||||
}, acc);
|
|
||||||
} catch (PrivilegedActionException e) {
|
} catch (PrivilegedActionException e) {
|
||||||
throw (NamingException)e.getException();
|
throw (NamingException)e.getException();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -395,47 +395,18 @@ public final class LdapPoolManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String getProperty(final String propName,
|
private static final String getProperty(final String propName, final String defVal) {
|
||||||
final String defVal) {
|
PrivilegedAction<String> pa = () -> System.getProperty(propName, defVal);
|
||||||
return AccessController.doPrivileged(
|
return AccessController.doPrivileged(pa);
|
||||||
new PrivilegedAction<String>() {
|
|
||||||
public String run() {
|
|
||||||
try {
|
|
||||||
return System.getProperty(propName, defVal);
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
return defVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int getInteger(final String propName,
|
private static final int getInteger(final String propName, final int defVal) {
|
||||||
final int defVal) {
|
PrivilegedAction<Integer> pa = () -> Integer.getInteger(propName, defVal);
|
||||||
Integer val = AccessController.doPrivileged(
|
return AccessController.doPrivileged(pa);
|
||||||
new PrivilegedAction<Integer>() {
|
|
||||||
public Integer run() {
|
|
||||||
try {
|
|
||||||
return Integer.getInteger(propName, defVal);
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
return defVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return val.intValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long getLong(final String propName,
|
private static final long getLong(final String propName, final long defVal) {
|
||||||
final long defVal) {
|
PrivilegedAction<Long> pa = () -> Long.getLong(propName, defVal);
|
||||||
Long val = AccessController.doPrivileged(
|
return AccessController.doPrivileged(pa);
|
||||||
new PrivilegedAction<Long>() {
|
|
||||||
public Long run() {
|
|
||||||
try {
|
|
||||||
return Long.getLong(propName, defVal);
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
return defVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return val.longValue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -119,12 +119,8 @@ final class LdapSearchEnumeration
|
|||||||
// Entry contains Java-object attributes (ser/ref object)
|
// Entry contains Java-object attributes (ser/ref object)
|
||||||
// serialized object or object reference
|
// serialized object or object reference
|
||||||
try {
|
try {
|
||||||
obj = AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
|
PrivilegedExceptionAction<Object> pea = () -> Obj.decodeObject(attrs);
|
||||||
@Override
|
obj = AccessController.doPrivileged(pea, acc);
|
||||||
public Object run() throws NamingException {
|
|
||||||
return Obj.decodeObject(attrs);
|
|
||||||
}
|
|
||||||
}, acc);
|
|
||||||
} catch (PrivilegedActionException e) {
|
} catch (PrivilegedActionException e) {
|
||||||
throw (NamingException)e.getException();
|
throw (NamingException)e.getException();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -220,23 +220,13 @@ public class StartTlsRequest implements ExtendedRequest {
|
|||||||
* Acquire the class loader associated with this thread.
|
* Acquire the class loader associated with this thread.
|
||||||
*/
|
*/
|
||||||
private final ClassLoader getContextClassLoader() {
|
private final ClassLoader getContextClassLoader() {
|
||||||
return AccessController.doPrivileged(
|
PrivilegedAction<ClassLoader> pa = Thread.currentThread()::getContextClassLoader;
|
||||||
new PrivilegedAction<ClassLoader>() {
|
return AccessController.doPrivileged(pa);
|
||||||
public ClassLoader run() {
|
|
||||||
return Thread.currentThread().getContextClassLoader();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final boolean privilegedHasNext(final Iterator<StartTlsResponse> iter) {
|
private static final boolean privilegedHasNext(final Iterator<StartTlsResponse> iter) {
|
||||||
Boolean answer = AccessController.doPrivileged(
|
PrivilegedAction<Boolean> pa = iter::hasNext;
|
||||||
new PrivilegedAction<Boolean>() {
|
return AccessController.doPrivileged(pa);
|
||||||
public Boolean run() {
|
|
||||||
return Boolean.valueOf(iter.hasNext());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return answer.booleanValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = 4441679576360753397L;
|
private static final long serialVersionUID = 4441679576360753397L;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -73,21 +73,20 @@ public final class JdkLDAP extends Provider {
|
|||||||
super("JdkLDAP", PROVIDER_VER, "JdkLDAP Provider (implements LDAP CertStore)");
|
super("JdkLDAP", PROVIDER_VER, "JdkLDAP Provider (implements LDAP CertStore)");
|
||||||
|
|
||||||
final Provider p = this;
|
final Provider p = this;
|
||||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
PrivilegedAction<Void> pa = () -> {
|
||||||
public Void run() {
|
HashMap<String, String> attrs = new HashMap<>(2);
|
||||||
HashMap<String, String> attrs = new HashMap<>(2);
|
attrs.put("LDAPSchema", "RFC2587");
|
||||||
attrs.put("LDAPSchema", "RFC2587");
|
attrs.put("ImplementedIn", "Software");
|
||||||
attrs.put("ImplementedIn", "Software");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CertStore
|
* CertStore
|
||||||
* attrs: LDAPSchema, ImplementedIn
|
* attrs: LDAPSchema, ImplementedIn
|
||||||
*/
|
*/
|
||||||
putService(new ProviderService(p, "CertStore",
|
putService(new ProviderService(p, "CertStore",
|
||||||
"LDAP", "sun.security.provider.certpath.ldap.LDAPCertStore",
|
"LDAP", "sun.security.provider.certpath.ldap.LDAPCertStore",
|
||||||
null, attrs));
|
null, attrs));
|
||||||
return null;
|
return null;
|
||||||
}
|
};
|
||||||
});
|
AccessController.doPrivileged(pa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user