use of com.auth0.jwt.interfaces.ECDSAKeyProvider in project java-jwt by auth0.
the class ECDSABouncyCastleProviderTests method shouldDoECDSA512SigningWithProvidedPrivateKey.
@Test
public void shouldDoECDSA512SigningWithProvidedPrivateKey() throws Exception {
ECDSAKeyProvider provider = mock(ECDSAKeyProvider.class);
PrivateKey privateKey = readPrivateKeyFromFile(PRIVATE_KEY_FILE_512, "EC");
PublicKey publicKey = readPublicKeyFromFile(PUBLIC_KEY_FILE_512, "EC");
when(provider.getPrivateKey()).thenReturn((ECPrivateKey) privateKey);
when(provider.getPublicKeyById(null)).thenReturn((ECPublicKey) publicKey);
Algorithm algorithm = Algorithm.ECDSA512(provider);
String jwt = asJWT(algorithm, ES512Header, auth0IssPayload);
assertSignaturePresent(jwt);
algorithm.verify(JWT.decode(jwt));
}
use of com.auth0.jwt.interfaces.ECDSAKeyProvider in project java-jwt by auth0.
the class ECDSABouncyCastleProviderTests method shouldReturnNullSigningKeyIdIfCreatedWithDefaultProvider.
@Test
public void shouldReturnNullSigningKeyIdIfCreatedWithDefaultProvider() {
ECPublicKey publicKey = mock(ECPublicKey.class);
ECPrivateKey privateKey = mock(ECPrivateKey.class);
ECDSAKeyProvider provider = ECDSAAlgorithm.providerForKeys(publicKey, privateKey);
Algorithm algorithm = new ECDSAAlgorithm("some-alg", "some-algorithm", 32, provider);
assertThat(algorithm.getSigningKeyId(), is(nullValue()));
}
use of com.auth0.jwt.interfaces.ECDSAKeyProvider in project java-jwt by auth0.
the class ECDSABouncyCastleProviderTests method shouldDoECDSA384SigningWithProvidedPrivateKey.
@Test
public void shouldDoECDSA384SigningWithProvidedPrivateKey() throws Exception {
ECDSAKeyProvider provider = mock(ECDSAKeyProvider.class);
PrivateKey privateKey = readPrivateKeyFromFile(PRIVATE_KEY_FILE_384, "EC");
PublicKey publicKey = readPublicKeyFromFile(PUBLIC_KEY_FILE_384, "EC");
when(provider.getPrivateKey()).thenReturn((ECPrivateKey) privateKey);
when(provider.getPublicKeyById(null)).thenReturn((ECPublicKey) publicKey);
Algorithm algorithm = Algorithm.ECDSA384(provider);
String jwt = asJWT(algorithm, ES384Header, auth0IssPayload);
assertSignaturePresent(jwt);
algorithm.verify(JWT.decode(jwt));
}
use of com.auth0.jwt.interfaces.ECDSAKeyProvider in project java-jwt by auth0.
the class AlgorithmTest method shouldThrowECDSA384InstanceWithNullKeyProvider.
@Test
public void shouldThrowECDSA384InstanceWithNullKeyProvider() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("The Key Provider cannot be null.");
ECDSAKeyProvider provider = null;
Algorithm.ECDSA384(provider);
}
use of com.auth0.jwt.interfaces.ECDSAKeyProvider in project java-jwt by auth0.
the class AlgorithmTest method shouldCreateECDSA384AlgorithmWithProvider.
@Test
public void shouldCreateECDSA384AlgorithmWithProvider() {
ECDSAKeyProvider provider = mock(ECDSAKeyProvider.class);
Algorithm algorithm = Algorithm.ECDSA384(provider);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA384withECDSA"));
assertThat(algorithm.getName(), is("ES384"));
}
Aggregations