jdk/src/java.base/share/classes/java/security/Provider.java
changeset 30033 b9c86c17164a
parent 28059 e576535359cc
child 31270 e6470b24700d
equal deleted inserted replaced
30019:e7dbbef69d12 30033:b9c86c17164a
   709             return false;
   709             return false;
   710         }
   710         }
   711 
   711 
   712         legacyChanged = true;
   712         legacyChanged = true;
   713         if (legacyStrings == null) {
   713         if (legacyStrings == null) {
   714             legacyStrings = new LinkedHashMap<String,String>();
   714             legacyStrings = new LinkedHashMap<>();
   715         }
   715         }
   716         return true;
   716         return true;
   717     }
   717     }
   718 
   718 
   719     /**
   719     /**
   771 
   771 
   772     @SuppressWarnings("unchecked") // Function must actually operate over strings
   772     @SuppressWarnings("unchecked") // Function must actually operate over strings
   773     private void implReplaceAll(BiFunction<? super Object, ? super Object, ? extends Object> function) {
   773     private void implReplaceAll(BiFunction<? super Object, ? super Object, ? extends Object> function) {
   774         legacyChanged = true;
   774         legacyChanged = true;
   775         if (legacyStrings == null) {
   775         if (legacyStrings == null) {
   776             legacyStrings = new LinkedHashMap<String,String>();
   776             legacyStrings = new LinkedHashMap<>();
   777         } else {
   777         } else {
   778             legacyStrings.replaceAll((BiFunction<? super String, ? super String, ? extends String>) function);
   778             legacyStrings.replaceAll((BiFunction<? super String, ? super String, ? extends String>) function);
   779         }
   779         }
   780         super.replaceAll(function);
   780         super.replaceAll(function);
   781     }
   781     }
   903         if ((legacyChanged == false) || (legacyStrings == null)) {
   903         if ((legacyChanged == false) || (legacyStrings == null)) {
   904             return;
   904             return;
   905         }
   905         }
   906         serviceSet = null;
   906         serviceSet = null;
   907         if (legacyMap == null) {
   907         if (legacyMap == null) {
   908             legacyMap = new LinkedHashMap<ServiceKey,Service>();
   908             legacyMap = new LinkedHashMap<>();
   909         } else {
   909         } else {
   910             legacyMap.clear();
   910             legacyMap.clear();
   911         }
   911         }
   912         for (Map.Entry<String,String> entry : legacyStrings.entrySet()) {
   912         for (Map.Entry<String,String> entry : legacyStrings.entrySet()) {
   913             parseLegacyPut(entry.getKey(), entry.getValue());
   913             parseLegacyPut(entry.getKey(), entry.getValue());
  1131         if (s.getProvider() != this) {
  1131         if (s.getProvider() != this) {
  1132             throw new IllegalArgumentException
  1132             throw new IllegalArgumentException
  1133                     ("service.getProvider() must match this Provider object");
  1133                     ("service.getProvider() must match this Provider object");
  1134         }
  1134         }
  1135         if (serviceMap == null) {
  1135         if (serviceMap == null) {
  1136             serviceMap = new LinkedHashMap<ServiceKey,Service>();
  1136             serviceMap = new LinkedHashMap<>();
  1137         }
  1137         }
  1138         servicesChanged = true;
  1138         servicesChanged = true;
  1139         String type = s.getType();
  1139         String type = s.getType();
  1140         String algorithm = s.getAlgorithm();
  1140         String algorithm = s.getAlgorithm();
  1141         ServiceKey key = new ServiceKey(type, algorithm, true);
  1141         ServiceKey key = new ServiceKey(type, algorithm, true);
  1303         knownEngines.put(name.toLowerCase(ENGLISH), ed);
  1303         knownEngines.put(name.toLowerCase(ENGLISH), ed);
  1304         knownEngines.put(name, ed);
  1304         knownEngines.put(name, ed);
  1305     }
  1305     }
  1306 
  1306 
  1307     static {
  1307     static {
  1308         knownEngines = new HashMap<String,EngineDescription>();
  1308         knownEngines = new HashMap<>();
  1309         // JCA
  1309         // JCA
  1310         addEngine("AlgorithmParameterGenerator",        false, null);
  1310         addEngine("AlgorithmParameterGenerator",        false, null);
  1311         addEngine("AlgorithmParameters",                false, null);
  1311         addEngine("AlgorithmParameters",                false, null);
  1312         addEngine("KeyFactory",                         false, null);
  1312         addEngine("KeyFactory",                         false, null);
  1313         addEngine("KeyPairGenerator",                   false, null);
  1313         addEngine("KeyPairGenerator",                   false, null);
  1429             return (type != null) && (algorithm != null) && (className != null);
  1429             return (type != null) && (algorithm != null) && (className != null);
  1430         }
  1430         }
  1431 
  1431 
  1432         private void addAlias(String alias) {
  1432         private void addAlias(String alias) {
  1433             if (aliases.isEmpty()) {
  1433             if (aliases.isEmpty()) {
  1434                 aliases = new ArrayList<String>(2);
  1434                 aliases = new ArrayList<>(2);
  1435             }
  1435             }
  1436             aliases.add(alias);
  1436             aliases.add(alias);
  1437         }
  1437         }
  1438 
  1438 
  1439         void addAttribute(String type, String value) {
  1439         void addAttribute(String type, String value) {
  1440             if (attributes.isEmpty()) {
  1440             if (attributes.isEmpty()) {
  1441                 attributes = new HashMap<UString,String>(8);
  1441                 attributes = new HashMap<>(8);
  1442             }
  1442             }
  1443             attributes.put(new UString(type), value);
  1443             attributes.put(new UString(type), value);
  1444         }
  1444         }
  1445 
  1445 
  1446         /**
  1446         /**
  1469             this.algorithm = algorithm;
  1469             this.algorithm = algorithm;
  1470             this.className = className;
  1470             this.className = className;
  1471             if (aliases == null) {
  1471             if (aliases == null) {
  1472                 this.aliases = Collections.<String>emptyList();
  1472                 this.aliases = Collections.<String>emptyList();
  1473             } else {
  1473             } else {
  1474                 this.aliases = new ArrayList<String>(aliases);
  1474                 this.aliases = new ArrayList<>(aliases);
  1475             }
  1475             }
  1476             if (attributes == null) {
  1476             if (attributes == null) {
  1477                 this.attributes = Collections.<UString,String>emptyMap();
  1477                 this.attributes = Collections.<UString,String>emptyMap();
  1478             } else {
  1478             } else {
  1479                 this.attributes = new HashMap<UString,String>();
  1479                 this.attributes = new HashMap<>();
  1480                 for (Map.Entry<String,String> entry : attributes.entrySet()) {
  1480                 for (Map.Entry<String,String> entry : attributes.entrySet()) {
  1481                     this.attributes.put(new UString(entry.getKey()), entry.getValue());
  1481                     this.attributes.put(new UString(entry.getKey()), entry.getValue());
  1482                 }
  1482                 }
  1483             }
  1483             }
  1484         }
  1484         }
  1642                     if (!Modifier.isPublic(clazz.getModifiers())) {
  1642                     if (!Modifier.isPublic(clazz.getModifiers())) {
  1643                         throw new NoSuchAlgorithmException
  1643                         throw new NoSuchAlgorithmException
  1644                             ("class configured for " + type + " (provider: " +
  1644                             ("class configured for " + type + " (provider: " +
  1645                             provider.getName() + ") is not public.");
  1645                             provider.getName() + ") is not public.");
  1646                     }
  1646                     }
  1647                     classRef = new WeakReference<Class<?>>(clazz);
  1647                     classRef = new WeakReference<>(clazz);
  1648                 }
  1648                 }
  1649                 return clazz;
  1649                 return clazz;
  1650             } catch (ClassNotFoundException e) {
  1650             } catch (ClassNotFoundException e) {
  1651                 throw new NoSuchAlgorithmException
  1651                 throw new NoSuchAlgorithmException
  1652                     ("class configured for " + type + " (provider: " +
  1652                     ("class configured for " + type + " (provider: " +