Code example for Certificate

Methods: getEncodedgetPublicKeyverify

0
            throws InvalidKeyException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException, InvalidAlgorithmParameterException, IOException { 
 
        Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
        c1.verify(null);
 
        cert.verify(cert.getPublicKey());
 
        PublicKey k = cert.getPublicKey();
 
        MyModifiablePublicKey changedEncoding = new MyModifiablePublicKey(k);
        changedEncoding.setEncoding(new byte[cert.getEncoded().length - 1]);
 
        try { 
            cert.verify(c1.getPublicKey());
            fail();
        } catch (InvalidKeyException expected) {
        } 
 
        try { 
            cert.verify(changedEncoding);
            fail();
        } catch (Exception expected) {
        } 
    }