@SuppressWarnings("java:S2583")
  public static boolean verify(@NonNull JWKSet jwks, @NonNull JWSObject jws) {

    if (jwks == null) {
      throw new IllegalArgumentException("no JWKS provided to verify JWS");
    }

    if (jwks.getKeys() == null || jwks.getKeys().isEmpty()) {
      return false;
    }

    var header = jws.getHeader();
    if (!JWSAlgorithm.ES256.equals(header.getAlgorithm())) {
      throw new UnsupportedOperationException(
          "only supports ES256, found: " + header.getAlgorithm());
    }

    var key = jwks.getKeyByKeyId(header.getKeyID());
    if (key == null) {
      return false;
    }

    try {
      var processor = new DefaultJWSVerifierFactory();
      var verifier = processor.createJWSVerifier(jws.getHeader(), key.toECKey().toPublicKey());
      return jws.verify(verifier);
    } catch (JOSEException e) {
      throw FederationExceptions.badSignature(e);
    }
  }
@Test
  void verifyNoJwks() {

    assertThrows(IllegalArgumentException.class, () -> JwsVerifier.verify(null, null));
  }