@Nonnull @Override public JwtReader getReader(@Nonnull String jwt) throws JwtParseException, JwsUnsupportedAlgorithmException, JwtUnknownIssuerException, JwtIssuerLacksSharedSecretException { return getReader(jwt, SystemClock.getInstance()); }
private JwtReader getReader(String jwt, RSAPublicKey publicKey, Clock clock) throws JwsUnsupportedAlgorithmException, JwtParseException, JwtUnknownIssuerException { SimpleUnverifiedJwt unverifiedJwt = new NimbusUnverifiedJwtReader().parse(jwt); SigningAlgorithm algorithm = validateAlgorithm(unverifiedJwt); String issuer = validateIssuer(unverifiedJwt); if (algorithm.requiresKeyPair()) { return rsVerifyingReader(issuer, publicKey, clock); } throw new JwsUnsupportedAlgorithmException(String.format("Expected an asymmetric signing algorithm such as %s, and not %s. Try an asymmetric algorithm.", SigningAlgorithm.RS256, algorithm.name())); }
private JwtReader getReader(String jwt, Clock clock) throws JwsUnsupportedAlgorithmException, JwtUnknownIssuerException, JwtParseException, JwtIssuerLacksSharedSecretException { SimpleUnverifiedJwt unverifiedJwt = new NimbusUnverifiedJwtReader().parse(jwt); SigningAlgorithm algorithm = validateAlgorithm(unverifiedJwt); String issuer = validateIssuer(unverifiedJwt); if (algorithm.requiresSharedSecret()) { return macVerifyingReader(issuer, jwtIssuerSharedSecretService.getSharedSecret(issuer), clock); } throw new JwsUnsupportedAlgorithmException(String.format("Expected a symmetric signing algorithm such as %s, and not %s. Try a symmetric algorithm.", SigningAlgorithm.HS256, algorithm.name())); }
public JwtTestVerifier(String sharedSecret, String clientId) { this.sharedSecret = sharedSecret; this.clientId = clientId; this.readerFactory = new NimbusJwtReaderFactory(new TestJwtIssuerValidator(clientId), new TestJwtIssuerSharedSecretService(sharedSecret)); }
@Nonnull @Override public JwtReader getReader(@Nonnull String jwt, RSAPublicKey publicKey) throws JwsUnsupportedAlgorithmException, JwtParseException, JwtUnknownIssuerException { return getReader(jwt, publicKey, SystemClock.getInstance()); }
@Nonnull @Override public JwtReader getReader(@Nonnull String jwt, RSAPublicKey publicKey, @Nonnull Date date) throws JwsUnsupportedAlgorithmException, JwtParseException, JwtUnknownIssuerException { return getReader(jwt, publicKey, StaticClock.at(date)); }
@Nonnull @Override public JwtReader getReader(@Nonnull String jwt, @Nonnull Date date) throws JwsUnsupportedAlgorithmException, JwtUnknownIssuerException, JwtParseException, JwtIssuerLacksSharedSecretException { return getReader(jwt, StaticClock.at(date)); }
private Jwt getVerifiedJwt(String token) throws JwtVerificationException, JwtIssuerLacksSharedSecretException, JwtUnknownIssuerException, JwtParseException { return readerFactory.getReader(token).read(token, Maps.<String, JwtClaimEqualityVerifier>newHashMap()); }