Best code examples for Java 8 X509Certificate class (javax.security.cert.X509Certificate)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 X509Certificate class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 X509Certificate examples from Open Source projects
This code example shows how to use the following methods: getEncoded, getPublicKey, verify
    public void testVerifyPublicKey() throws InvalidKeyException,
            NoSuchAlgorithmException, NoSuchProviderException,
            SignatureException, CertificateException {
 
        // Preconditions 
        assertNotNull(javaxCert.getPublicKey());
        assertNotNull(javaxSSCert.getPublicKey());
        //precondition for self signed certificates 
        /*assertEquals(((X509Certificate) javaxSSCert).getIssuerDN().getName(), 
                ((X509Certificate) javaxSSCert).getSubjectDN());*/ 
 
        // must always evaluate true for self signed 
        // here not self signed: 
        try { 
            javaxCert.verify(javaxCert.getPublicKey());
        } catch (SignatureException e) {
            // ok 
        } 
 
        PublicKey k = javaxCert.getPublicKey();

5
CodeRank
This code example shows how to use the following methods: getSigAlgName
            // The requested certificate type is not available. 
            // Test can not be applied. 
            return; 
        } 
        assertEquals("The name of signature algorithm is not correct.",
                                tbt_cert.getSigAlgName(), cert.getSigAlgName());
    } 
 
    /** 
     * getSigAlgOID() method testing. 
     */ 
    public void testGetSigAlgOID() { 
        if (this.cert == null) {
            // The requested certificate type is not available. 
            // Test can not be applied. 
            return; 
        } 
        assertEquals("The name of OID of signature algorithm is not correct.",
                                tbt_cert.getSigAlgOID(), cert.getSigAlgOID());
    } 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: getSubjectDN
This code example shows how to use the following methods: getEncoded
 
    public static String toPem(final X509Certificate certificate) throws CertificateEncodingException {
        final StringBuilder builder = new StringBuilder();
        builder.append(BEGIN_CERT);
        builder.append('\n');
        builder.append(FlexBase64.encodeString(certificate.getEncoded(), true));
        builder.append('\n');
        builder.append(END_CERT);
        return builder.toString();
    } 
 
    private Certificates() { 
 
    } 
} 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getVersion
            // The requested certificate type is not available. 
            // Test can not be applied. 
            return; 
        } 
        assertEquals("The version is not correct.",
                                                tbt_cert.getVersion(), 2);
    } 
 
    /** 
     * getSerialNumber() method testing. 
     */ 
    public void testGetSerialNumber() { 
        if (this.cert == null) {
            // The requested certificate type is not available. 
            // Test can not be applied. 
            return; 
        } 
        assertEquals("The serial number is not correct.",
                            tbt_cert.getSerialNumber(), cert.getSerialNumber());
    } 
Full Snippet Info
4
CodeRank
See Code Examples for Java 8 X509Certificate Methods: