T fromJson(JsonObject json) { // key type agnostic values keyType(asString(json, PARAM_KEY_TYPE, "JWK Key type")); keyId(asString(json, PARAM_KEY_ID, "JWK Key id")); getString(json, PARAM_ALGORITHM).ifPresent(this::algorithm); /* sig - signatures or MAC enc - encryption */ getString(json, PARAM_USE).ifPresent(this::usage); /* sign - compute digital signature or MAC verify - verify digital signature encrypt - encrypt content decrypt - decrypt content wrapKey - encrypt key unwrapKey - decrypt key deriveKey - derive key deriveBits - derive bits not to be used as a key */ getStrings(json, PARAM_OPERATIONS).ifPresent(this::operations); return myInstance; } }
/** * Create an instance from Json object. * * @param json with definition of a web key (any key type) * @return new instance of a descendant of this class constructed from json, based on key type */ public static Jwk create(JsonObject json) { String keyType = asString(json, PARAM_KEY_TYPE, "JWK Key type"); // gather key type specific values switch (keyType) { case KEY_TYPE_EC: return JwkEC.create(json); case KEY_TYPE_RSA: return JwkRSA.create(json); case KEY_TYPE_OCT: return JwkOctet.create(json); default: throw new JwtException("Unknown JWK type: " + keyType); } }
String curve = asString(json, PARAM_CURVE, "EC curve");
T fromJson(JsonObject json) { // key type agnostic values keyType(asString(json, PARAM_KEY_TYPE, "JWK Key type")); keyId(asString(json, PARAM_KEY_ID, "JWK Key id")); getString(json, PARAM_ALGORITHM).ifPresent(this::algorithm); /* sig - signatures or MAC enc - encryption */ getString(json, PARAM_USE).ifPresent(this::usage); /* sign - compute digital signature or MAC verify - verify digital signature encrypt - encrypt content decrypt - decrypt content wrapKey - encrypt key unwrapKey - decrypt key deriveKey - derive key deriveBits - derive bits not to be used as a key */ getStrings(json, PARAM_OPERATIONS).ifPresent(this::operations); return myInstance; } }
/** * Create an instance from Json object. * * @param json with definition of a web key (any key type) * @return new instance of a descendant of this class constructed from json, based on key type */ public static Jwk create(JsonObject json) { String keyType = asString(json, PARAM_KEY_TYPE, "JWK Key type"); // gather key type specific values switch (keyType) { case KEY_TYPE_EC: return JwkEC.create(json); case KEY_TYPE_RSA: return JwkRSA.create(json); case KEY_TYPE_OCT: return JwkOctet.create(json); default: throw new JwtException("Unknown JWK type: " + keyType); } }
String curve = asString(json, PARAM_CURVE, "EC curve");