@Test public void testCustomOct() { String keyId = "hmac-secret-001"; customKeys.forKeyId(keyId).ifPresentOrElse(key -> { assertThat(key.algorithm(), is(JwkOctet.ALG_HS256)); assertThat(key.keyType(), is(Jwk.KEY_TYPE_OCT)); assertThat(key.usage(), is(Optional.empty())); assertThat(key.keyId(), is(keyId)); assertThat(key.operations(), is(Optional.of(List.of(Jwk.OPERATION_SIGN, Jwk.OPERATION_VERIFY)))); assertThat(key, instanceOf(JwkOctet.class)); assertThat(key, not(instanceOf(JwkPki.class))); JwkOctet oct = (JwkOctet) key; assertThat(Base64.getUrlEncoder().encodeToString(oct.getKeyBytes()), is("FdFYFzERwC2uCBB46pZQi4GG85LujR8obt-KWRBICVQ=")); byte[] bytes = "someTextToSign 3232".getBytes(StandardCharsets.UTF_8); byte[] sig = key.sign(bytes); assertThat(sig, notNullValue()); assertThat(sig.length, not(0)); assertThat(key.verifySignature(bytes, sig), is(true)); }, () -> fail("Octet Key with kid \"" + keyId + "\" should be present in " + "jwk_data.json file")); }
public Optional<Jwk> forKeyId(String keyId) { return Optional.ofNullable(keyMap.get(keyId)); }
JwkKeys { public Optional<Jwk> forKeyId(String keyId) { return Optional.ofNullable(keyMap.get(keyId)); } }
JwkKeys { public Optional<Jwk> forKeyId(String keyId) { return Optional.ofNullable(keyMap.get(keyId)); } private  JwkKeys(Builder builder); }
JwkKeys { public Optional<Jwk> forKeyId(String keyId) { return Optional.ofNullable(keyMap.get(keyId)); } private  JwkKeys(Builder builder); static Builder builder(); static JwkKeys create(JsonObject json); Optional<Jwk> forKeyId(String keyId); List<Jwk> keys(); }
JwkKeys { public Optional<Jwk> forKeyId(String keyId) { return Optional.ofNullable(keyMap.get(keyId)); } private  JwkKeys(Builder builder); static Builder builder(); static JwkKeys create(JsonObject json); Optional<Jwk> forKeyId(String keyId); List<Jwk> keys();  }