Skip to content

Commit

Permalink
Updated to work with beta jars and added better preamble to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Megan Woods committed Feb 8, 2017
1 parent 22ed0ba commit 1d50832
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 6 deletions.
42 changes: 42 additions & 0 deletions test/est/example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,48 @@

# EST client examples

## Before running

The examples below use utility scripts, these scripts will try to ensure the dependencies are met to run the examples.

To do this ahead of time run the following:

```
cd <bc-java>/test/est/example
./ensurejar.sh
```

This script will download the provider from the betas page and it will then endeavour to build, using gradle the
Bouncycastle distribution. You will need to have installed gradle and have it on the PATH for this to run.

When it is done building it will then copy the jars into the ```<bc-java>/test/est/example/jars/``` directory.

If you need to refresh these jars delete the jars directory.

## Not in a unix environment
The examples need a provider, the pkix jar, and the test jar.

If you have openjdk installed you can simply use gradle to compile bc-java and the libraries will be in
```
cd <bc-java>
gradle -x test clean jar
# Libraries will be in:
# test/build/libs
# prov/build/libs
# pkix/build/libs
#
```
NB: The above was built disabling the tests.


OpenJDK does not enforce provider signing which can be advantageous in testing. If you are using a JVM that does
enforce provider signing then you will need to download the provider from the betas page.

If you are familiar with .BAT files you will be able to examine each .sh file to see how to invoke the examples.


## The code:
The code can be found in
```
Expand Down
7 changes: 5 additions & 2 deletions test/est/example/cacerts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd $DIR/../../../
BCDIR=`pwd`
popd
CP="$BCDIR/pkix/build/libs/bcpkix-jdk15on-1.56-SNAPSHOT.jar:$BCDIR/test/build/libs/test-1.56-SNAPSHOT.jar:$BCDIR/prov/build/libs/prov-1.56-SNAPSHOT.jar:$BCDIR/core/build/libs/core-1.56-SNAPSHOT.jar"
java -cp $CP org.bouncycastle.test.est.examples.CaCertsExample $@

$DIR/ensurejar.sh

CP="$DIR/jars/bcpkix-jdk15on-1.56-SNAPSHOT.jar:$DIR/jars/bcprov-jdk15on-157b03.jar:$DIR/jars/test-1.56-SNAPSHOT.jar"
java -classpath $CP org.bouncycastle.test.est.examples.CaCertsExample $@

7 changes: 5 additions & 2 deletions test/est/example/csrattrs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd $DIR/../../../
BCDIR=`pwd`
popd
CP="$BCDIR/pkix/build/libs/bcpkix-jdk15on-1.56-SNAPSHOT.jar:$BCDIR/test/build/libs/test-1.56-SNAPSHOT.jar:$BCDIR/prov/build/libs/prov-1.56-SNAPSHOT.jar:$BCDIR/core/build/libs/core-1.56-SNAPSHOT.jar"
java -cp $CP org.bouncycastle.test.est.examples.CSRAttributesExample $@

$DIR/ensurejar.sh

CP="$DIR/jars/bcpkix-jdk15on-1.56-SNAPSHOT.jar:$DIR/jars/bcprov-jdk15on-157b03.jar:$DIR/jars/test-1.56-SNAPSHOT.jar"
java -classpath $CP org.bouncycastle.test.est.examples.CSRAttributesExample $@

6 changes: 4 additions & 2 deletions test/est/example/enroll.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd $DIR/../../../
BCDIR=`pwd`
popd
CP="$BCDIR/pkix/build/libs/bcpkix-jdk15on-1.56-SNAPSHOT.jar:$BCDIR/test/build/libs/test-1.56-SNAPSHOT.jar:$BCDIR/prov/build/libs/prov-1.56-SNAPSHOT.jar:$BCDIR/core/build/libs/core-1.56-SNAPSHOT.jar"
java -cp $CP org.bouncycastle.test.est.examples.EnrollExample $@

$DIR/ensurejar.sh

CP="$DIR/jars/bcpkix-jdk15on-1.56-SNAPSHOT.jar:$DIR/jars/bcprov-jdk15on-157b03.jar:$DIR/jars/test-1.56-SNAPSHOT.jar"
java -classpath $CP org.bouncycastle.test.est.examples.EnrollExample $@
34 changes: 34 additions & 0 deletions test/est/example/ensurejar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [ ! -d "$DIR/jars" ]; then
mkdir $DIR/jars

pushd $DIR/../../../
BCDIR=`pwd`
popd

pushd $DIR/jars

if type curl > /dev/null; then
curl -O https://downloads.bouncycastle.org/betas/bcprov-jdk15on-157b03.jar
elif type wget > /dev/null ; then
wget https://downloads.bouncycastle.org/betas/bcprov-jdk15on-157b03.jar
else
echo "No wget or curl to download provider jar"
fi

popd

cd $BCDIR

gradle -x test clean jar

cp $BCDIR/test/build/libs/* $DIR/jars
cp $BCDIR/pkix/build/libs/*.jar $DIR/jars

fi



0 comments on commit 1d50832

Please sign in to comment.