use of com.auth0.jwt.JWT in project data-transfer-project by google.
the class JWTTokenManager method getJobIdFromToken.
@Override
public UUID getJobIdFromToken(String token) {
try {
DecodedJWT jwt = verifier.verify(token);
// Token is verified, get claim
Claim claim = jwt.getClaim(JWTTokenManager.ID_CLAIM_KEY);
if (claim.isNull()) {
return null;
}
return claim.isNull() ? null : UUID.fromString(claim.asString());
} catch (JWTVerificationException exception) {
throw new RuntimeException("Error verifying token: " + token);
}
}
use of com.auth0.jwt.JWT in project data-transfer-project by google.
the class JWTTokenManager method getJobIdFromToken.
@Override
public UUID getJobIdFromToken(String token) {
try {
DecodedJWT jwt = verifier.verify(token);
// Token is verified, get claim
Claim claim = jwt.getClaim(JWTTokenManager.ID_CLAIM_KEY);
if (claim.isNull()) {
return null;
}
return claim.isNull() ? null : UUID.fromString(claim.asString());
} catch (JWTVerificationException exception) {
logger.debug("Error verifying token: {}", exception);
throw new RuntimeException("Error verifying token: " + token);
}
}
use of com.auth0.jwt.JWT in project wikidata-query-rdf by wikimedia.
the class TimeLimitedAccessTokenFactory method decide.
<T> T decide(String token, Supplier<T> good, Supplier<T> bad) {
if (token == null) {
return bad.get();
}
DecodedJWT decoded;
try {
decoded = verifier.verify(token);
} catch (JWTVerificationException e) {
return bad.get();
}
Claim claim = decoded.getClaim(USERNAME);
if (claim.isNull()) {
throw new IllegalStateException(("All valid jwt tokens must have a username claim"));
}
if (bannedUsernames.contains(claim.asString())) {
return bad.get();
}
return good.get();
}
use of com.auth0.jwt.JWT in project spring-boot by spring-projects.
the class OAuth2ResourceServerAutoConfigurationTests method autoConfigurationShouldConfigureResourceServerUsingJwkSetUriAndIssuerUri.
@SuppressWarnings("unchecked")
@Test
void autoConfigurationShouldConfigureResourceServerUsingJwkSetUriAndIssuerUri() throws Exception {
this.server = new MockWebServer();
this.server.start();
String path = "test";
String issuer = this.server.url(path).toString();
String cleanIssuerPath = cleanIssuerPath(issuer);
setupMockResponse(cleanIssuerPath);
this.contextRunner.withPropertyValues("spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://jwk-set-uri.com", "spring.security.oauth2.resourceserver.jwt.issuer-uri=http://" + this.server.getHostName() + ":" + this.server.getPort() + "/" + path).run((context) -> {
assertThat(context).hasSingleBean(JwtDecoder.class);
JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class);
DelegatingOAuth2TokenValidator<Jwt> jwtValidator = (DelegatingOAuth2TokenValidator<Jwt>) ReflectionTestUtils.getField(jwtDecoder, "jwtValidator");
Collection<OAuth2TokenValidator<Jwt>> tokenValidators = (Collection<OAuth2TokenValidator<Jwt>>) ReflectionTestUtils.getField(jwtValidator, "tokenValidators");
assertThat(tokenValidators).hasAtLeastOneElementOfType(JwtIssuerValidator.class);
});
}
use of com.auth0.jwt.JWT in project snow-owl by b2ihealthcare.
the class JWTConfigurationTest method hs512.
@Test
public void hs512() throws Exception {
IdentityConfiguration conf = readConfig("hs512.yml");
new IdentityPlugin().configureJWT(services, identityProvider, conf);
// generate a key then verify it without errors
String jwt = services.getService(JWTGenerator.class).generate("test@example.com", Map.of());
DecodedJWT decoded = services.getService(JWTVerifier.class).verify(jwt);
assertThat(decoded.getAlgorithm()).isEqualTo("HS512");
}
Aggregations