Java 8 X509Certificate - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 X509Certificate class.

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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getSubjectDN
         } 
         return null; 
      }  
       
      private String extractCertificateUser(X509Certificate certificate) throws Exception {
         Principal principal = certificate.getSubjectDN();
         String name = principal.getName();
         String user = cache.get(name);
          
         if(user == null) {
            if(!cache.containsKey(name)) {
               Matcher matcher = pattern.matcher(name);
             
               if(matcher.matches()) {
                  user = matcher.group(1);
               } 
               cache.put(name, user);
            } 
         } 
         return user;
Full Snippet Info
3
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Java 8 X509Certificate Methods: