use of org.keycloak.representations.JsonWebToken in project keycloak by keycloak.
the class JsonParserTest method testOtherClaims.
@Test
public void testOtherClaims() throws Exception {
String json = "{ \"floatData\" : 555.5," + "\"boolData\": true, " + "\"intData\": 1234," + "\"array\": [ \"val\", \"val2\"] }";
JsonWebToken token = JsonSerialization.readValue(json, JsonWebToken.class);
System.out.println(token.getOtherClaims().get("floatData").getClass().getName());
System.out.println(token.getOtherClaims().get("boolData").getClass().getName());
System.out.println(token.getOtherClaims().get("intData").getClass().getName());
System.out.println(token.getOtherClaims().get("array").getClass().getName());
}
use of org.keycloak.representations.JsonWebToken in project keycloak by keycloak.
the class JsonWebTokenTest method isActiveReturnTrueWhenBeforeTimeInPast.
@Test
public void isActiveReturnTrueWhenBeforeTimeInPast() {
int currentTime = Time.currentTime();
int pastTime = currentTime - 10;
JsonWebToken jsonWebToken = new JsonWebToken();
jsonWebToken.notBefore(pastTime);
assertTrue(jsonWebToken.isActive());
}
use of org.keycloak.representations.JsonWebToken in project keycloak by keycloak.
the class JsonWebTokenTest method isActiveShouldReturnFalseWhenWhenBeforeTimeInFutureOutsideTimeSkew.
@Test
public void isActiveShouldReturnFalseWhenWhenBeforeTimeInFutureOutsideTimeSkew() {
int notBeforeTime = Time.currentTime() + 10;
int allowedClockSkew = 5;
JsonWebToken jsonWebToken = new JsonWebToken();
jsonWebToken.notBefore(notBeforeTime);
assertFalse(jsonWebToken.isActive(allowedClockSkew));
}
use of org.keycloak.representations.JsonWebToken in project keycloak by keycloak.
the class JsonWebTokenTest method testAudArray.
@Test
public void testAudArray() throws IOException {
String single = "{ \"aud\": [\"test\"] }";
JsonWebToken s = JsonSerialization.readValue(single, JsonWebToken.class);
assertArrayEquals(new String[] { "test" }, s.getAudience());
}
use of org.keycloak.representations.JsonWebToken in project keycloak by keycloak.
the class JsonWebTokenTest method isActiveReturnFalseWhenBeforeTimeInFuture.
@Test
public void isActiveReturnFalseWhenBeforeTimeInFuture() {
int currentTime = Time.currentTime();
int futureTime = currentTime + 10;
JsonWebToken jsonWebToken = new JsonWebToken();
jsonWebToken.notBefore(futureTime);
assertFalse(jsonWebToken.isActive());
}
Aggregations