mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
Merge
This commit is contained in:
commit
c782d0e486
15 changed files with 428 additions and 339 deletions
|
@ -868,7 +868,7 @@ public abstract class Provider extends Properties {
|
|||
// For backward compatibility, the registration ordering of
|
||||
// SecureRandom (RNG) algorithms needs to be preserved for
|
||||
// "new SecureRandom()" calls when this provider is used
|
||||
private transient Set<Service> prngServices;
|
||||
private transient Set<String> prngAlgos;
|
||||
|
||||
// Map<ServiceKey,Service>
|
||||
// used for services added via legacy methods, init on demand
|
||||
|
@ -1089,7 +1089,7 @@ public abstract class Provider extends Properties {
|
|||
legacyChanged = false;
|
||||
servicesChanged = false;
|
||||
serviceSet = null;
|
||||
prngServices = null;
|
||||
prngAlgos = null;
|
||||
super.clear();
|
||||
putId();
|
||||
}
|
||||
|
@ -1221,7 +1221,7 @@ public abstract class Provider extends Properties {
|
|||
s.className = className;
|
||||
|
||||
if (type.equals("SecureRandom")) {
|
||||
updateSecureRandomEntries(true, s);
|
||||
updateSecureRandomEntries(true, s.algorithm);
|
||||
}
|
||||
} else { // attribute
|
||||
// e.g. put("MessageDigest.SHA-1 ImplementedIn", "Software");
|
||||
|
@ -1383,25 +1383,25 @@ public abstract class Provider extends Properties {
|
|||
synchronized (this) {
|
||||
putPropertyStrings(s);
|
||||
if (type.equals("SecureRandom")) {
|
||||
updateSecureRandomEntries(true, s);
|
||||
updateSecureRandomEntries(true, s.algorithm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSecureRandomEntries(boolean doAdd, Service s) {
|
||||
// keep tracks of the registered secure random algos and store them in order
|
||||
private void updateSecureRandomEntries(boolean doAdd, String s) {
|
||||
Objects.requireNonNull(s);
|
||||
if (doAdd) {
|
||||
if (prngServices == null) {
|
||||
prngServices = new LinkedHashSet<Service>();
|
||||
if (prngAlgos == null) {
|
||||
prngAlgos = new LinkedHashSet<String>();
|
||||
}
|
||||
prngServices.add(s);
|
||||
prngAlgos.add(s);
|
||||
} else {
|
||||
prngServices.remove(s);
|
||||
prngAlgos.remove(s);
|
||||
}
|
||||
|
||||
if (debug != null) {
|
||||
debug.println((doAdd? "Add":"Remove") + " SecureRandom algo " +
|
||||
s.getAlgorithm());
|
||||
debug.println((doAdd? "Add":"Remove") + " SecureRandom algo " + s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1411,12 +1411,15 @@ public abstract class Provider extends Properties {
|
|||
checkInitialized();
|
||||
|
||||
if (legacyChanged) {
|
||||
prngServices = null;
|
||||
prngAlgos = null;
|
||||
ensureLegacyParsed();
|
||||
}
|
||||
|
||||
if (prngServices != null && !prngServices.isEmpty()) {
|
||||
return prngServices.iterator().next();
|
||||
if (prngAlgos != null && !prngAlgos.isEmpty()) {
|
||||
// IMPORTANT: use the Service obj returned by getService(...) call
|
||||
// as providers may override putService(...)/getService(...) and
|
||||
// return their own Service objects
|
||||
return getService("SecureRandom", prngAlgos.iterator().next());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -1516,7 +1519,7 @@ public abstract class Provider extends Properties {
|
|||
synchronized (this) {
|
||||
removePropertyStrings(s);
|
||||
if (type.equals("SecureRandom")) {
|
||||
updateSecureRandomEntries(false, s);
|
||||
updateSecureRandomEntries(false, s.algorithm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue