Skip to content

Instantly share code, notes, and snippets.

@drissamri
Last active March 31, 2018 12:52
Show Gist options
  • Save drissamri/82dc691dacf0bcc0beda996acb02decf to your computer and use it in GitHub Desktop.
Save drissamri/82dc691dacf0bcc0beda996acb02decf to your computer and use it in GitHub Desktop.
@Bean
public JwtParser jwtParser()
{
Security.addProvider(new BouncyCastleProvider());
final X509EncodedKeySpec spec = new X509EncodedKeySpec(Base64.getUrlDecoder().decode(PUBLIC_KEY));
final KeyFactory factory;
try {
factory = KeyFactory.getInstance("ECDSA", "BC");
final PublicKey publicKey = factory.generatePublic(spec);
return Jwts.parser().setSigningKey(publicKey);
}
catch (NoSuchAlgorithmException | NoSuchProviderException | InvalidKeySpecException e) {
throw new RuntimeException(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment