Skip to content

Commit

Permalink
ensure bc provider is being used
Browse files Browse the repository at this point in the history
  • Loading branch information
lbalmaceda committed Nov 3, 2017
1 parent 96031ce commit ce486b1
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import com.auth0.jwt.interfaces.ECDSAKeyProvider;
import org.apache.commons.codec.binary.Base64;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Expand Down Expand Up @@ -46,25 +46,29 @@ public class ECDSABouncyCastleProviderTests {

@Rule
public ExpectedException exception = ExpectedException.none();
private final BouncyCastleProvider bcProvider = new BouncyCastleProvider();
private static final Provider bcProvider = new BouncyCastleProvider();

//JOSE Signatures obtained using Node 'jwa' lib: https://github.com/brianloveswords/node-jwa
//DER Signatures obtained from source JOSE signature using 'ecdsa-sig-formatter' lib: https://github.com/Brightspace/node-ecdsa-sig-formatter


//These tests add and use the BouncyCastle SecurityProvider to handle ECDSA algorithms

@Before
public void setUp() throws Exception {
@BeforeClass
public static void setUp() throws Exception {
//Set BC as the preferred bcProvider
Security.insertProviderAt(bcProvider, 1);
}

@After
public void tearDown() throws Exception {
@AfterClass
public static void tearDown() throws Exception {
Security.removeProvider(bcProvider.getName());
}

@Test
public void shouldPreferBouncyCastleProvider() throws Exception {
assertThat(Security.getProviders()[0], is(equalTo(bcProvider)));
}

// Verify

Expand Down

0 comments on commit ce486b1

Please sign in to comment.