jwt structures are claims based
parent
cd0a117031
commit
febad61730
|
@ -50,12 +50,14 @@ public class JwtClaims extends ClaimSet {
|
|||
setJwtId(element.getValue().getAsString());
|
||||
} else if (element.getKey().equals(TYPE)) {
|
||||
setType(element.getValue().getAsString());
|
||||
} else if (element.getValue().isJsonPrimitive()){
|
||||
// we handle all primitives in here
|
||||
JsonPrimitive prim = element.getValue().getAsJsonPrimitive();
|
||||
setClaim(element.getKey(), prim);
|
||||
} else {
|
||||
setClaim(element.getKey(), element.getValue());
|
||||
if (element.getValue().isJsonPrimitive()){
|
||||
// we handle all primitives in here
|
||||
JsonPrimitive prim = element.getValue().getAsJsonPrimitive();
|
||||
setClaim(element.getKey(), prim);
|
||||
} else {
|
||||
setClaim(element.getKey(), element.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Map.Entry;
|
|||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
public class JwtHeader extends ClaimSet {
|
||||
|
||||
|
@ -34,8 +35,13 @@ public class JwtHeader extends ClaimSet {
|
|||
} else if (element.getKey().equals(ENCRYPTION_METHOD)) {
|
||||
this.setEncryptionMethod(json.get(ENCRYPTION_METHOD).getAsString());
|
||||
} else {
|
||||
// TODO: this assumes string encoding for extensions, probably not quite correct
|
||||
setClaim(element.getKey(), element.getValue().getAsString());
|
||||
if (element.getValue().isJsonPrimitive()){
|
||||
// we handle all primitives in here
|
||||
JsonPrimitive prim = element.getValue().getAsJsonPrimitive();
|
||||
setClaim(element.getKey(), prim);
|
||||
} else {
|
||||
setClaim(element.getKey(), element.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ public class JwtTest {
|
|||
public void testToStringPlaintext() {
|
||||
Jwt jwt = new Jwt();
|
||||
jwt.getHeader().setAlgorithm("none");
|
||||
jwt.getClaims().setIssuer("joe");
|
||||
jwt.getClaims().setExpiration(new Date(1300819380L * 1000L));
|
||||
jwt.getClaims().setIssuer("joe");
|
||||
jwt.getClaims().setClaim("http://example.com/is_root", Boolean.TRUE);
|
||||
|
||||
// sign it with a blank signature
|
||||
|
@ -48,8 +48,8 @@ public class JwtTest {
|
|||
Jwt jwt = new Jwt();
|
||||
jwt.getHeader().setType("JWT");
|
||||
jwt.getHeader().setAlgorithm("HS256");
|
||||
jwt.getClaims().setIssuer("joe");
|
||||
jwt.getClaims().setExpiration(new Date(1300819380L * 1000L));
|
||||
jwt.getClaims().setIssuer("joe");
|
||||
jwt.getClaims().setClaim("http://example.com/is_root", Boolean.TRUE);
|
||||
|
||||
// sign it
|
||||
|
|
Loading…
Reference in New Issue