Search in sources :

Example 1 with Claim

use of com.auth0.android.jwt.Claim in project sda-dropwizard-commons by SDA-SE.

the class AuthBuilderTest method shouldAddIntegerClaim.

@Test
public void shouldAddIntegerClaim() {
    String token = authBuilder.addClaim("testKey", 42).buildToken();
    Claim claim = JWT.decode(token).getClaim("testKey");
    assertThat(claim.asInt()).isEqualTo(42);
}
Also used : Claim(com.auth0.jwt.interfaces.Claim) Test(org.junit.Test)

Example 2 with Claim

use of com.auth0.android.jwt.Claim in project sda-dropwizard-commons by SDA-SE.

the class AuthBuilderTest method shouldAddDoubleClaim.

@Test
public void shouldAddDoubleClaim() {
    String token = authBuilder.addClaim("testKey", 3.141D).buildToken();
    Claim claim = JWT.decode(token).getClaim("testKey");
    assertThat(claim.asDouble()).isEqualTo(3.141D);
}
Also used : Claim(com.auth0.jwt.interfaces.Claim) Test(org.junit.Test)

Example 3 with Claim

use of com.auth0.android.jwt.Claim in project sda-dropwizard-commons by SDA-SE.

the class AuthBuilderTest method shouldAddStringArrayClaim.

@Test
public void shouldAddStringArrayClaim() {
    String token = authBuilder.addClaim("testKey", new String[] { "Hello", "World" }).buildToken();
    Claim claim = JWT.decode(token).getClaim("testKey");
    assertThat(claim.asList(String.class)).containsExactly("Hello", "World");
}
Also used : Claim(com.auth0.jwt.interfaces.Claim) Test(org.junit.Test)

Example 4 with Claim

use of com.auth0.android.jwt.Claim in project sda-dropwizard-commons by SDA-SE.

the class AuthBuilderTest method shouldAddBooleanClaim.

@Test
public void shouldAddBooleanClaim() {
    String token = authBuilder.addClaim("testKey", true).buildToken();
    Claim claim = JWT.decode(token).getClaim("testKey");
    assertThat(claim.asBoolean()).isTrue();
}
Also used : Claim(com.auth0.jwt.interfaces.Claim) Test(org.junit.Test)

Example 5 with Claim

use of com.auth0.android.jwt.Claim in project sda-dropwizard-commons by SDA-SE.

the class AuthBuilderTest method shouldAddLongArrayClaim.

@Test
public void shouldAddLongArrayClaim() {
    String token = authBuilder.addClaim("testKey", new Long[] { 1L, 2L }).buildToken();
    Claim claim = JWT.decode(token).getClaim("testKey");
    assertThat(claim.asList(Long.class)).containsExactly(1L, 2L);
}
Also used : Claim(com.auth0.jwt.interfaces.Claim) Test(org.junit.Test)

Aggregations

Claim (com.auth0.jwt.interfaces.Claim)110 Test (org.junit.Test)67 DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)62 JsonNode (com.fasterxml.jackson.databind.JsonNode)42 Algorithm (com.auth0.jwt.algorithms.Algorithm)24 Date (java.util.Date)24 JWTVerificationException (com.auth0.jwt.exceptions.JWTVerificationException)21 RSAPublicKey (java.security.interfaces.RSAPublicKey)21 Test (org.junit.jupiter.api.Test)18 RSAPrivateKey (java.security.interfaces.RSAPrivateKey)17 JWTVerifier (com.auth0.jwt.JWTVerifier)15 JwksTestKeySource (org.sdase.commons.server.auth.service.testsources.JwksTestKeySource)14 JsonObject (com.google.gson.JsonObject)10 HashMap (java.util.HashMap)9 UserPojo (com.auth0.jwt.UserPojo)8 IOException (java.io.IOException)8 Map (java.util.Map)8 TestingProcessManager (io.supertokens.test.TestingProcessManager)7 NullClaim (com.auth0.jwt.impl.NullClaim)5 JWT (com.auth0.jwt.JWT)4