Using BouncyCastle (or other encryption providers) in DW?

1,475 views
Skip to first unread message

Lance N.

unread,
Sep 19, 2013, 3:19:20 PM9/19/13
to dropwiz...@googlegroups.com
How can one use the BouncyCastle encryption library (or another external JCE provider) in a DW app? Is there an example somewhere? This is frustrating because we have another non-DW app that works fine with BouncyCastle, and we don't do any jar signing or anything else. 

Thanks,

Lance



Coda Hale

unread,
Sep 19, 2013, 3:27:19 PM9/19/13
to dropwiz...@googlegroups.com
You'll need to add it to your JAR's class path and exclude it from being shaded in with the rest of your dependencies.

Or, install it as a JCE provider on the machine.


--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Coda Hale
http://codahale.com

Justin Cummins

unread,
Sep 19, 2013, 3:50:33 PM9/19/13
to dropwiz...@googlegroups.com
I've got some content in my pom.xml for this. The maven-shade-plugin will add a manifest entry to expect the bouncycastle provider jar at `lib-signed/bcprov-jdk15on.jar` and you'll have to put it there when you deploy.

Installing the JCE provider on the machine is easier. However, it's a pain when you want to update the bouncycastle version as part of a deploy with rollback. Also, that bouncycastle version would apply to all java programs on that jre.
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <version>2.1</version>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
        <goal>shade</goal>
      </goals>
      <configuration>
        <shadedArtifactAttached>true</shadedArtifactAttached>
        <shadedClassifierName>shaded</shadedClassifierName>
        <transformers>
          <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
          <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
            <manifestEntries>
              <Class-Path>lib-signed/bcprov-jdk15on.jar</Class-Path>
              <Main-Class>${project.mainclass}</Main-Class>
            </manifestEntries>
          </transformer>
        </transformers>

        <!-- signatures from foreign jars are bad news -->
        <filters>
          <filter>
            <artifact>*:*</artifact>
            <excludes>
              <exclude>META-INF/*.SF</exclude>
              <exclude>META-INF/*.DSA</exclude>
              <exclude>META-INF/*.RSA</exclude>
            </excludes>
          </filter>
        </filters>

        <artifactSet>
          <excludes>
            <exclude>org.bouncycastle:bcprov-jdk15on</exclude>
          </excludes>
        </artifactSet>
      </configuration>
    </execution>
  </executions>
</plugin>

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>2.8</version>
  <executions>
    <execution>
      <id>copy</id>
      <phase>package</phase>
      <goals>
        <goal>copy-dependencies</goal>
      </goals>
      <configuration>
        <outputDirectory>${project.build.directory}/lib-signed</outputDirectory>
        <includeArtifactIds>bcprov-jdk15on</includeArtifactIds>
        <stripVersion>true</stripVersion>
      </configuration>
    </execution>
  </executions>
</plugin>

Lance N.

unread,
Sep 19, 2013, 4:34:53 PM9/19/13
to dropwiz...@googlegroups.com
Thanks very much! I've since discovered that our programs work this way also. 

Lance Norskog

unread,
Sep 19, 2013, 9:36:21 PM9/19/13
to dropwiz...@googlegroups.com
In this Maven technique, how can you also make your DW application class be the main class? 

Lance


--
You received this message because you are subscribed to a topic in the Google Groups "dropwizard-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dropwizard-user/Grp5atjNSTU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dropwizard-us...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Lance Norskog
lance....@gmail.com
Redwood City, CA
Reply all
Reply to author
Forward
0 new messages