Code example for PublicKey

Methods: getAlgorithm

0
     */ 
    public static boolean verify(PublicKey verificationKey, String jcaAlgorithmID, byte[] signature, byte[] input)
            throws SecurityException { 
 
        log.debug("Verifying signature over input using public key of type {} and JCA algorithm ID {}", verificationKey
                .getAlgorithm(), jcaAlgorithmID);
 
        try { 
            Signature sig = Signature.getInstance(jcaAlgorithmID);
            sig.initVerify(verificationKey);
            sig.update(input);
            return sig.verify(signature);
        } catch (GeneralSecurityException e) {
            log.error("Error during signature verification", e);
            throw new SecurityException("Error during signature verification", e);
        } 
    } 
 
    /** 
     * Verify the Message Authentication Code (MAC) value computed over the supplied input against the supplied MAC 
     * value.