public static boolean verify(byte[] text, byte[] signatureValue, PublicKey key, String algorithm)
        throws SignatureException {
        Signature signature;
        try {
            signature = Signature.getInstance(algorithm);
            signature.initVerify(key);
        } catch (GeneralSecurityException e) {
            throw new IllegalArgumentException("cannot initialize signature for algorithm " + algorithm, e);
        }
        signature.update(text);
        return signature.verify(signatureValue);
    }
public static boolean verify ( byte [ ] text , byte [ ] signatureValue , PublicKey key , String algorithm ) throws SignatureException { Signature signature ; try { signature = Signature . getInstance ( algorithm ) ; signature . initVerify ( key ) ; } catch ( GeneralSecurityException e ) { throw new IllegalArgumentException ( "cannot initialize signature for algorithm " + algorithm , e ) ; } signature . update ( text ) ; return signature . verify ( signatureValue ) ; }
verifies if the given data is valid for the given signature and public key.

@throws SignatureException if the algorithm cannot be initialized