public interface PublicKeyProvider
The following example demonstrates using the JwkProviderBuilder
from the
jwks-rsa-java library to fetch the public key.
JwkProvider provider = new JwkProviderBuilder("https://your-domain.auth0.com").build(); SignatureVerifier sigVerifier = SignatureVerifier.forRS256(new PublicKeyProvider() { @Override public RSAPublicKey getPublicKeyById(String keyId) throws PublicKeyProviderException { try { return (RSAPublicKey) provider.get(keyId).getPublicKey(); } catch (JwkException jwke) { throw new PublicKeyProviderException("Error obtaining public key", jwke); } } }
Modifier and Type | Method and Description |
---|---|
java.security.interfaces.RSAPublicKey |
getPublicKeyById(java.lang.String keyId)
Get a
RSAPublicKey given the key ID. |
java.security.interfaces.RSAPublicKey getPublicKeyById(java.lang.String keyId) throws PublicKeyProviderException
RSAPublicKey
given the key ID.keyId
- the key ID for which to retrieve the key.RSAPublicKey
for the given key ID.PublicKeyProviderException
- if the public key cannot be retrieved.