title: Adding Bouncycastle security provider to maven jar
body: <p>Hello Stackoverflow Community,</p>
  
  <p>When trying to compile my maven project that uses the bouncycastle security provider, I get this error: <code>java.lang.SecurityException: JCE cannot authenticate the provider BC</code>
  I am aware that the jar must be signed, so I have added this to the pom.xml to prevent an error with compilation: </p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.3&lt;/version&gt;
          &lt;configuration&gt;
              &lt;filters&gt;
                  &lt;filter&gt;
                      &lt;artifact&gt;*:*&lt;/artifact&gt;
                      &lt;excludes&gt;
                          &lt;exclude&gt;META-INF/*.SF&lt;/exclude&gt;
                          &lt;exclude&gt;META-INF/*.DSA&lt;/exclude&gt;
                          &lt;exclude&gt;META-INF/*.RSA&lt;/exclude&gt;
                      &lt;/excludes&gt;
                  &lt;/filter&gt;
              &lt;/filters&gt;
          &lt;/configuration&gt;
          &lt;executions&gt;
              &lt;execution&gt;
                  &lt;phase&gt;
                      package
                  &lt;/phase&gt;
                  &lt;goals&gt;
                      &lt;goal&gt;shade&lt;/goal&gt;
                  &lt;/goals&gt;
              &lt;/execution&gt;
          &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>Based on this (<a href="https://stackoverflow.com/questions/6908696/bouncycastle-provider-cant-find-classes-needed-for-algorithm">bouncycastle provider can&#39;t find classes needed for algorithm</a>) I have added this: <code>Security.setProperty("java.policy", "unlimited");</code> and I have added the provider with this: <code>Security.addProvider(new BouncyCastleProvider());</code>
  in my public static void main.</p>
  
  <p>Unfortunately, this didn't work. Do you have any suggestions of how to implement the thing shown in the post linked above without having to implement it for every JRE separately? Thanks in advance for any help.</p>