Code example for Certificate

Methods: getPublicKeyverify

    public final void testVerifyPublicKeyString2() throws InvalidKeyException, 
            CertificateException, NoSuchAlgorithmException, 
            NoSuchProviderException, SignatureException { 
        // real test 
        cert.verify(cert.getPublicKey(), usefulProvider.getName());
        // Exception tests 
        try { 
            cert.verify(cert.getPublicKey(), "UnknownProvider");
        } catch (NoSuchProviderException expected) {
        // This test has side effects affecting all other tests running later 
        // on in the same vm instance. Maybe a better way would be to first add 
        // a new provider, test if it works, then remove it and test if the 
        // exception is thrown.