Certificate getEncoded - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Certificate getEncoded method.

This code example shows how to use the following methods:getEncoded
    if (cert == null)
    { 
      return null; 
    } 
 
    byte[] rawOctets = cert.getEncoded();
 
    SHA1Digest digest = new SHA1Digest();
 
    byte[] digestOctets = new byte[digest.getDigestSize()];
 
    digest.update(rawOctets, 0, rawOctets.length);
 
    digest.doFinal(digestOctets, 0);
 
    return new String(Base64.encode(digestOctets));
  } 
 
} 
6
CodeRank
This code example shows how to use the following methods:getEncoded, getSerialNumber
    } 
 
    static IssuerAndSerialNumber getIssuerAndSerialNumber(X509Certificate cert)
        throws CertificateEncodingException 
    { 
        Certificate certStruct = Certificate.getInstance(cert.getEncoded());
 
        return new IssuerAndSerialNumber(certStruct.getIssuer(), cert.getSerialNumber());
    } 
 
 
    static byte[] getSubjectKeyId(X509Certificate cert)
    { 
        byte[] ext = cert.getExtensionValue(X509Extension.subjectKeyIdentifier.getId());
 
        if (ext != null)
        { 
            return ASN1OctetString.getInstance(ASN1OctetString.getInstance(ext).getOctets()).getOctets();
        } 
        else 
7
CodeRank
This code example shows how to use the following methods:getEncoded
        Certificate other = (Certificate)o;
 
        try 
        { 
            byte[] b1 = this.getEncoded();
            byte[] b2 = other.getEncoded();
 
            return Arrays.areEqual(b1, b2);
        } 
        catch (CertificateEncodingException e)
        { 
            return false; 
        } 
    } 
     
    public synchronized int hashCode() 
    { 
        if (!hashValueSet)
        { 
            hashValue = calculateHashCode();
6
CodeRank
This code example shows how to use the following methods:getEncoded, getType
        DataOutputStream    dOut)
        throws IOException 
    { 
        try 
        { 
            byte[]      cEnc = cert.getEncoded();
 
            dOut.writeUTF(cert.getType());
            dOut.writeInt(cEnc.length);
            dOut.write(cEnc);
        } 
        catch (CertificateEncodingException ex)
        { 
            throw new IOException(ex.toString());
        } 
    } 
 
    private Certificate decodeCertificate(
        DataInputStream   dIn)
        throws IOException 
6
CodeRank
This code example shows how to use the following methods:getEncoded, getSerialNumber
    } 
 
    static IssuerAndSerialNumber getIssuerAndSerialNumber(X509Certificate cert)
        throws CertificateEncodingException 
    { 
        Certificate certStruct = Certificate.getInstance(cert.getEncoded());
 
        return new IssuerAndSerialNumber(certStruct.getIssuer(), cert.getSerialNumber());
    } 
 
 
    static byte[] getSubjectKeyId(X509Certificate cert)
    { 
        byte[] ext = cert.getExtensionValue(X509Extension.subjectKeyIdentifier.getId());
 
        if (ext != null)
        { 
            return ASN1OctetString.getInstance(ASN1OctetString.getInstance(ext).getOctets()).getOctets();
        } 
        else 
6
CodeRank
This code example shows how to use the following methods:getEncoded
        dir.setReadable(true, false);
        dir.setExecutable(true, false);
        OutputStream os = null;
        try { 
            os = new FileOutputStream(file);
            os.write(cert.getEncoded());
        } finally { 
            IoUtils.closeQuietly(os);
        } 
        file.setReadable(true, false);
    } 
 
    private boolean isDeletedSystemCertificate(X509Certificate x) {
        return exists(getCertificateFile(deletedDir, x));
    } 
 
    public Date getCreationDate(String alias) {
        // containsAlias check ensures the later fileForAlias result 
        // was not a deleted system cert. 
        if (!containsAlias(alias)) {
6
CodeRank
This code example shows how to use the following methods:getEncoded, getType
        DataOutputStream    dOut)
        throws IOException 
    { 
        try 
        { 
            byte[]      cEnc = cert.getEncoded();
 
            dOut.writeUTF(cert.getType());
            dOut.writeInt(cEnc.length);
            dOut.write(cEnc);
        } 
        catch (CertificateEncodingException ex)
        { 
            throw new IOException(ex.toString());
        } 
    } 
 
    private Certificate decodeCertificate(
        DataInputStream   dIn)
        throws IOException 
6
CodeRank
This code example shows how to use the following methods:getEncoded
        Certificate other = (Certificate)o;
 
        try 
        { 
            byte[] b1 = this.getEncoded();
            byte[] b2 = other.getEncoded();
 
            return Arrays.areEqual(b1, b2);
        } 
        catch (CertificateEncodingException e)
        { 
            return false; 
        } 
    } 
     
    public synchronized int hashCode() 
    { 
        if (!hashValueSet)
        { 
            hashValue = calculateHashCode();
5
CodeRank
This code example shows how to use the following methods:getEncoded
This code example shows how to use the following methods:getEncoded
     * @throws CertificateEncodingException if there is a problem extracting the certificate information. 
     */ 
    public JcaX509CertificateHolder(X509Certificate cert)
        throws CertificateEncodingException 
    { 
        super(Certificate.getInstance(cert.getEncoded()));
    } 
} 
5
CodeRank

Related Certificate getEncoded Questions & Answers:

getEncoded Method Overview
Returns the encoded form of this certificate.
See Code Examples for other Java 8 Certificate Methods: