Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-8823

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

XMLWordPrintable

      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);
      	    }
      

              jkalina@redhat.com Jan Kalina (Inactive)
              mchoma@redhat.com Martin Choma
              Martin Choma Martin Choma
              Martin Choma Martin Choma
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: