use of com.auth0.jwt.JWTVerifier in project java-jwt by auth0.
the class JWTVerifierTest method shouldAddCustomLeewayToDateClaims.
@Test
public void shouldAddCustomLeewayToDateClaims() {
Algorithm algorithm = mock(Algorithm.class);
JWTVerifier.BaseVerification verification = (JWTVerifier.BaseVerification) JWTVerifier.init(algorithm);
JWTVerifier verifier = verification.acceptLeeway(1234L).build();
assertThat(verifier.expectedChecks, is(notNullValue()));
assertThat(verification.getLeewayFor(RegisteredClaims.ISSUED_AT), is(1234L));
assertThat(verification.getLeewayFor(RegisteredClaims.EXPIRES_AT), is(1234L));
assertThat(verification.getLeewayFor(RegisteredClaims.NOT_BEFORE), is(1234L));
}
use of com.auth0.jwt.JWTVerifier in project java-jwt by auth0.
the class JWTVerifierTest method shouldOverrideDefaultIssuedAtLeeway.
@Test
public void shouldOverrideDefaultIssuedAtLeeway() {
Algorithm algorithm = mock(Algorithm.class);
JWTVerifier.BaseVerification verification = (JWTVerifier.BaseVerification) JWTVerifier.init(algorithm);
JWTVerifier verifier = verification.acceptLeeway(1234L).acceptIssuedAt(9999L).build();
assertThat(verifier.expectedChecks, is(notNullValue()));
assertThat(verification.getLeewayFor(RegisteredClaims.ISSUED_AT), is(9999L));
assertThat(verification.getLeewayFor(RegisteredClaims.EXPIRES_AT), is(1234L));
assertThat(verification.getLeewayFor(RegisteredClaims.NOT_BEFORE), is(1234L));
}
use of com.auth0.jwt.JWTVerifier in project java-jwt by auth0.
the class ConcurrentVerifyTest method shouldPassECDSA384VerificationWithJOSESignature.
@Test
public void shouldPassECDSA384VerificationWithJOSESignature() throws Exception {
String token = "eyJhbGciOiJFUzM4NCJ9.eyJpc3MiOiJhdXRoMCJ9.50UU5VKNdF1wfykY8jQBKpvuHZoe6IZBJm5NvoB8bR-hnRg6ti-CHbmvoRtlLfnHfwITa_8cJMy6TenMC2g63GQHytc8rYoXqbwtS4R0Ko_AXbLFUmfxnGnMC6v4MS_z";
ECKey key = (ECKey) readPublicKeyFromFile(PUBLIC_KEY_FILE_384, "EC");
Algorithm algorithm = Algorithm.ECDSA384(key);
JWTVerifier verifier = JWTVerifier.init(algorithm).withIssuer("auth0").build();
concurrentVerify(verifier, token);
}
use of com.auth0.jwt.JWTVerifier in project java-jwt by auth0.
the class ConcurrentVerifyTest method shouldPassRSA384Verification.
@Test
public void shouldPassRSA384Verification() throws Exception {
String token = "eyJhbGciOiJSUzM4NCIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhdXRoMCJ9.TZlWjXObwGSQOiu2oMq8kiKz0_BR7bbBddNL6G8eZ_GoR82BXOZDqNrQr7lb_M-78XGBguWLWNIdYhzgxOUL9EoCJlrqVm9s9vo6G8T1sj1op-4TbjXZ61TwIvrJee9BvPLdKUJ9_fp1Js5kl6yXkst40Th8Auc5as4n49MLkipjpEhKDKaENKHpSubs1ripSz8SCQZSofeTM_EWVwSw7cpiM8Fy8jOPvWG8Xz4-e3ODFowvHVsDcONX_4FTMNbeRqDuHq2ZhCJnEfzcSJdrve_5VD5fM1LperBVslTrOxIgClOJ3RmM7-WnaizJrWP3D6Z9OLxPxLhM6-jx6tcxEw";
Algorithm algorithm = Algorithm.RSA384((RSAKey) readPublicKeyFromFile(PUBLIC_KEY_FILE, "RSA"));
JWTVerifier verifier = JWTVerifier.init(algorithm).withIssuer("auth0").build();
concurrentVerify(verifier, token);
}
use of com.auth0.jwt.JWTVerifier in project java-jwt by auth0.
the class ConcurrentVerifyTest method shouldPassHMAC512Verification.
@Test
public void shouldPassHMAC512Verification() throws Exception {
String token = "eyJhbGciOiJIUzUxMiIsImN0eSI6IkpXVCJ9.eyJpc3MiOiJhdXRoMCJ9.VUo2Z9SWDV-XcOc_Hr6Lff3vl7L9e5Vb8ThXpmGDFjHxe3Dr1ZBmUChYF-xVA7cAdX1P_D4ZCUcsv3IefpVaJw";
Algorithm algorithm = Algorithm.HMAC512("secret");
JWTVerifier verifier = JWTVerifier.init(algorithm).withIssuer("auth0").build();
concurrentVerify(verifier, token);
}
Aggregations