Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8039853

Provider.Service.newInstance() does not work with current JDK JGSS Mechanisms.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • None
    • security-libs
    • None

      The general contract with Provider.Service.newInstance() is that the Provider.Service implementation must provide a public no-arg constructor. In some cases, like CertStore/Policy/Configuration/TerminalFactory, there needs to be a public one-arg constructor. This is controlled by the Provider.EngineDescription class.

      The following Services:

          GssApiMechanism.1.2.840.113554.1.2.2
          GssApiMechanism.1.3.6.1.5.5.2

      don't work because the EngineDescription that controls the GssApiMechanisms don't allow parameters:

      Provider.java:

      1331: addEngine("GssApiMechanism", false, null);

      and thus there must be a public no-arg constructor. Looking at the jgss/SunProvider.java:

                     put("GssApiMechanism.1.2.840.113554.1.2.2",
                         "sun.security.jgss.krb5.Krb5MechFactory");
                     put("GssApiMechanism.1.3.6.1.5.5.2",
                         "sun.security.jgss.spnego.SpNegoMechFactory");

      I see:

        public final class Krb5MechFactory implements MechanismFactory {
          public Krb5MechFactory(GSSCaller caller) {
          }

        public final class SpNegoMechFactory implements MechanismFactory {
          public SpNegoMechFactory(GSSCaller caller) {
          }

      I realize that the GSSManager.getInstance() is probably what you would use to get these, but this does not follow the expected behavior of Provider.Service class.


      public class NewInstance {

          public static void main(String[] args) throws Exception {

              Set<Provider.Service> p =
                  Security.getProvider("SunJGSS").getServices();

              for (Provider.Service s : p) {
                  try {
                      s.newInstance(null);
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          }
      }

      java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: 1.2.840.113554.1.2.2, provider: SunJGSS, class: sun.security.jgss.krb5.Krb5MechFactory)
      at java.security.Provider$Service.newInstance(Provider.java:1621)
      at NewInstance.main(NewInstance.java:100)
      Caused by: java.lang.NoSuchMethodException: sun.security.jgss.krb5.Krb5MechFactory.<init>()
      at java.lang.Class.getConstructor0(Class.java:2967)
      at java.lang.Class.getConstructor(Class.java:1811)
      at java.security.Provider$Service.newInstance(Provider.java:1594)
      ... 1 more
      java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: 1.3.6.1.5.5.2, provider: SunJGSS, class: sun.security.jgss.spnego.SpNegoMechFactory)
      at java.security.Provider$Service.newInstance(Provider.java:1621)
      at NewInstance.main(NewInstance.java:100)
      Caused by: java.lang.NoSuchMethodException: sun.security.jgss.spnego.SpNegoMechFactory.<init>()
      at java.lang.Class.getConstructor0(Class.java:2967)
      at java.lang.Class.getConstructor(Class.java:1811)
      at java.security.Provider$Service.newInstance(Provider.java:1594)
      ... 1 more

            weijun Weijun Wang
            wetmore Bradford Wetmore
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: