< prev index next >

src/java.base/share/classes/java/security/Provider.java

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 1996, 2024, 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

@@ -25,11 +25,13 @@
  
  package java.security;
  
  import jdk.internal.event.SecurityProviderServiceEvent;
  
+ import javax.security.auth.login.Configuration;
  import java.io.*;
+ import java.security.cert.CertStoreParameters;
  import java.util.*;
  import static java.util.Locale.ENGLISH;
  import java.lang.ref.*;
  import java.lang.reflect.*;
  import java.util.function.BiConsumer;

@@ -1554,24 +1556,24 @@
  
      // describe relevant properties of a type of engine
      private static class EngineDescription {
          final String name;
          final boolean supportsParameter;
-         final String constructorParameterClassName;
+         final Class<?> constructorParameterClass;
  
-         EngineDescription(String name, boolean sp, String paramName) {
+         EngineDescription(String name, boolean sp, Class<?> constructorParameterClass) {
              this.name = name;
              this.supportsParameter = sp;
-             this.constructorParameterClassName = paramName;
+             this.constructorParameterClass = constructorParameterClass;
          }
      }
  
      // built in knowledge of the engine types shipped as part of the JDK
      private static final Map<String,EngineDescription> knownEngines;
  
-     private static void addEngine(String name, boolean sp, String paramName) {
-         EngineDescription ed = new EngineDescription(name, sp, paramName);
+     private static void addEngine(String name, boolean sp, Class<?> constructorParameterClass) {
+         EngineDescription ed = new EngineDescription(name, sp, constructorParameterClass);
          // also index by canonical name to avoid toLowerCase() for some lookups
          knownEngines.put(name.toLowerCase(ENGLISH), ed);
          knownEngines.put(name, ed);
      }
  

@@ -1583,17 +1585,17 @@
          addEngine("KeyFactory",                         false, null);
          addEngine("KeyPairGenerator",                   false, null);
          addEngine("KeyStore",                           false, null);
          addEngine("MessageDigest",                      false, null);
          addEngine("SecureRandom",                       false,
-                 "java.security.SecureRandomParameters");
+                 SecureRandomParameters.class);
          addEngine("Signature",                          true,  null);
          addEngine("CertificateFactory",                 false, null);
          addEngine("CertPathBuilder",                    false, null);
          addEngine("CertPathValidator",                  false, null);
          addEngine("CertStore",                          false,
-                             "java.security.cert.CertStoreParameters");
+                 CertStoreParameters.class);
          // JCE
          addEngine("Cipher",                             true,  null);
          addEngine("ExemptionMechanism",                 false, null);
          addEngine("Mac",                                true,  null);
          addEngine("KeyAgreement",                       true,  null);

@@ -1608,22 +1610,24 @@
          addEngine("GssApiMechanism",                    false, null);
          // SASL
          addEngine("SaslClientFactory",                  false, null);
          addEngine("SaslServerFactory",                  false, null);
          // POLICY
+         @SuppressWarnings("removal")
+         Class<Policy.Parameters> policyParams = Policy.Parameters.class;
          addEngine("Policy",                             false,
-                             "java.security.Policy$Parameters");
+                 policyParams);
          // CONFIGURATION
          addEngine("Configuration",                      false,
-                             "javax.security.auth.login.Configuration$Parameters");
+                 Configuration.Parameters.class);
          // XML DSig
          addEngine("XMLSignatureFactory",                false, null);
          addEngine("KeyInfoFactory",                     false, null);
          addEngine("TransformService",                   false, null);
          // Smart Card I/O
          addEngine("TerminalFactory",                    false,
-                             "java.lang.Object");
+                             Object.class);
      }
  
      // get the "standard" (mixed-case) engine name for arbitrary case engine name
      // if there is no known engine by that name, return s
      private static String getEngineName(String s) {

@@ -1893,23 +1897,22 @@
                      // this is the code path future for non-core
                      // optional packages
                      ctrParamClz = constructorParameter == null?
                          null : constructorParameter.getClass();
                  } else {
-                     ctrParamClz = cap.constructorParameterClassName == null?
-                         null : Class.forName(cap.constructorParameterClassName);
+                     ctrParamClz = cap.constructorParameterClass;
                      if (constructorParameter != null) {
                          if (ctrParamClz == null) {
                              throw new InvalidParameterException
                                  ("constructorParameter not used with " + type
                                  + " engines");
                          } else {
                              Class<?> argClass = constructorParameter.getClass();
                              if (!ctrParamClz.isAssignableFrom(argClass)) {
                                  throw new InvalidParameterException
                                      ("constructorParameter must be instanceof "
-                                     + cap.constructorParameterClassName.replace('$', '.')
+                                     + cap.constructorParameterClass.getName().replace('$', '.')
                                      + " for engine type " + type);
                              }
                          }
                      }
                  }
< prev index next >