public boolean verifySignature(String jwksUri, SignedJWT signedJwt) throws JOSEException, InvalidSignatureException, IOException, ParseException {
        var publicKeys = getPublicKeys(jwksUri);
        var kid = signedJwt.getHeader().getKeyID();

        if (kid != null) {
            var key = ((RSAKey) publicKeys.getKeyByKeyId(kid));
            if (key != null) {
                RSASSAVerifier rsaSSAVerifier = new RSASSAVerifier(key.toRSAPublicKey());
                if (signedJwt.verify(rsaSSAVerifier)) return true;
            }
        }

        for (JWK jwk : publicKeys.getKeys()) {
            if (signedJwt.verify(new RSASSAVerifier(((RSAKey) jwk).toRSAPublicKey())))
                return true;
        }

        throw new InvalidSignatureException("Could not validate signature of JWT token");
    }
@Test
    void verifyInvalidSignatureTest() {
        assertThrows(
                InvalidSignatureException.class,
                () -> provider.verifySignature("jwskUri", SignedJWT.parse(VALID_REQUEST))
        );
    }