Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-10223

Elytron discovery of providers from BC module does not work without class-names

    Details

      Description

      If I register provider loader to load providers from org.bouncycastle module, no provider is loaded.

      [standalone@localhost:9990 /] /subsystem=elytron/provider-loader=bc:add(module=org.bouncycastle)
      {"outcome" => "success"}
      [standalone@localhost:9990 /] /subsystem=elytron/provider-loader=bc:read-attribute(name=loaded-providers)
      {
          "outcome" => "success",
          "result" => undefined
      }
      

      But if I specify class-names attribute, provider is loaded as expected.

      [standalone@localhost:9990 /] /subsystem=elytron/provider-loader=bc2:add(class-names=[org.bouncycastle.jce.provider.BouncyCastleProvider], module=org.bouncycastle)
      {"outcome" => "success"}
      [standalone@localhost:9990 /] /subsystem=elytron/provider-loader=bc2:read-attribute(name=loaded-providers)
      {
          "outcome" => "success",
          "result" => [{
              "name" => "BC",
              "info" => "BouncyCastle Security Provider v1.56",
              "version" => 1.56,
              "services" => [
                  {
                      "type" => "MessageDigest",
                      "algorithm" => "GOST3411",
                      "class-name" => "org.bouncycastle.jcajce.provider.digest.GOST3411$Digest"
                  },
                  {
                      "type" => "Mac",
                      "algorithm" => "HMACGOST3411",
                      "class-name" => "org.bouncycastle.jcajce.provider.digest.GOST3411$HashMac"
                  },
                  {
                      "type" => "KeyGenerator",
                      "algorithm" => "HMACGOST3411",
                      "class-name" => "org.bouncycastle.jcajce.provider.digest.GOST3411$KeyGenerator"
                  },
                  {
                      "type" => "MessageDigest",
                      "algorithm" => "GOST3411-2012-256",
                      "class-name" => "org.bouncycastle.jcajce.provider.digest.GOST3411$Digest2012_256"
                  },
      	...
      

      Check provider discovery feature.

      ProviderDefinitions

                  ClassLoader classLoader = doPrivileged((PrivilegedExceptionAction<ClassLoader>) () -> resolveClassLoader(module));
                  final List<Provider> loadedProviders;
      	    if (classNames != null) {
      		loadedProviders = new ArrayList<>(classNames.length);
      		for (String className : classNames) {
      		    Class<? extends Provider> providerClazz = classLoader.loadClass(className).asSubclass(Provider.class);
      		    loadedProviders.add(providerClazz.newInstance());
      		}
      	    } else {
      		loadedProviders = new ArrayList<>();
      		ServiceLoader<Provider> loader = ServiceLoader.load(Provider.class, classLoader);
      		loader.forEach(loadedProviders::add);
      	    }
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  honza889 Jan Kalina
                  Reporter:
                  honza889 Jan Kalina
                  Tester:
                  Martin Choma
                  Need Info from:
                  Darran Lofthouse
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: