Search in sources :

Example 1 with PemWriter

use of com.android.org.bouncycastle.util.io.pem.PemWriter in project android_frameworks_base by AOSPA.

the class Credentials method convertToPem.

/**
     * Convert objects to a PEM format which is used for
     * CA_CERTIFICATE and USER_CERTIFICATE entries.
     */
public static byte[] convertToPem(Certificate... objects) throws IOException, CertificateEncodingException {
    ByteArrayOutputStream bao = new ByteArrayOutputStream();
    Writer writer = new OutputStreamWriter(bao, StandardCharsets.US_ASCII);
    PemWriter pw = new PemWriter(writer);
    for (Certificate o : objects) {
        pw.writeObject(new PemObject("CERTIFICATE", o.getEncoded()));
    }
    pw.close();
    return bao.toByteArray();
}
Also used : PemObject(com.android.org.bouncycastle.util.io.pem.PemObject) PemWriter(com.android.org.bouncycastle.util.io.pem.PemWriter) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) PemWriter(com.android.org.bouncycastle.util.io.pem.PemWriter) X509Certificate(java.security.cert.X509Certificate) Certificate(java.security.cert.Certificate)

Example 2 with PemWriter

use of com.android.org.bouncycastle.util.io.pem.PemWriter in project android_frameworks_base by crdroidandroid.

the class Credentials method convertToPem.

/**
     * Convert objects to a PEM format which is used for
     * CA_CERTIFICATE and USER_CERTIFICATE entries.
     */
public static byte[] convertToPem(Certificate... objects) throws IOException, CertificateEncodingException {
    ByteArrayOutputStream bao = new ByteArrayOutputStream();
    Writer writer = new OutputStreamWriter(bao, StandardCharsets.US_ASCII);
    PemWriter pw = new PemWriter(writer);
    for (Certificate o : objects) {
        pw.writeObject(new PemObject("CERTIFICATE", o.getEncoded()));
    }
    pw.close();
    return bao.toByteArray();
}
Also used : PemObject(com.android.org.bouncycastle.util.io.pem.PemObject) PemWriter(com.android.org.bouncycastle.util.io.pem.PemWriter) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) PemWriter(com.android.org.bouncycastle.util.io.pem.PemWriter) X509Certificate(java.security.cert.X509Certificate) Certificate(java.security.cert.Certificate)

Example 3 with PemWriter

use of com.android.org.bouncycastle.util.io.pem.PemWriter in project android_frameworks_base by ParanoidAndroid.

the class Credentials method convertToPem.

/**
     * Convert objects to a PEM format which is used for
     * CA_CERTIFICATE and USER_CERTIFICATE entries.
     */
public static byte[] convertToPem(Certificate... objects) throws IOException, CertificateEncodingException {
    ByteArrayOutputStream bao = new ByteArrayOutputStream();
    Writer writer = new OutputStreamWriter(bao, Charsets.US_ASCII);
    PemWriter pw = new PemWriter(writer);
    for (Certificate o : objects) {
        pw.writeObject(new PemObject("CERTIFICATE", o.getEncoded()));
    }
    pw.close();
    return bao.toByteArray();
}
Also used : PemObject(com.android.org.bouncycastle.util.io.pem.PemObject) PemWriter(com.android.org.bouncycastle.util.io.pem.PemWriter) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) PemWriter(com.android.org.bouncycastle.util.io.pem.PemWriter) X509Certificate(java.security.cert.X509Certificate) Certificate(java.security.cert.Certificate)

Example 4 with PemWriter

use of com.android.org.bouncycastle.util.io.pem.PemWriter in project platform_frameworks_base by android.

the class Credentials method convertToPem.

/**
     * Convert objects to a PEM format which is used for
     * CA_CERTIFICATE and USER_CERTIFICATE entries.
     */
public static byte[] convertToPem(Certificate... objects) throws IOException, CertificateEncodingException {
    ByteArrayOutputStream bao = new ByteArrayOutputStream();
    Writer writer = new OutputStreamWriter(bao, StandardCharsets.US_ASCII);
    PemWriter pw = new PemWriter(writer);
    for (Certificate o : objects) {
        pw.writeObject(new PemObject("CERTIFICATE", o.getEncoded()));
    }
    pw.close();
    return bao.toByteArray();
}
Also used : PemObject(com.android.org.bouncycastle.util.io.pem.PemObject) PemWriter(com.android.org.bouncycastle.util.io.pem.PemWriter) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) PemWriter(com.android.org.bouncycastle.util.io.pem.PemWriter) X509Certificate(java.security.cert.X509Certificate) Certificate(java.security.cert.Certificate)

Example 5 with PemWriter

use of com.android.org.bouncycastle.util.io.pem.PemWriter in project android_frameworks_base by DirtyUnicorns.

the class Credentials method convertToPem.

/**
     * Convert objects to a PEM format which is used for
     * CA_CERTIFICATE and USER_CERTIFICATE entries.
     */
public static byte[] convertToPem(Certificate... objects) throws IOException, CertificateEncodingException {
    ByteArrayOutputStream bao = new ByteArrayOutputStream();
    Writer writer = new OutputStreamWriter(bao, StandardCharsets.US_ASCII);
    PemWriter pw = new PemWriter(writer);
    for (Certificate o : objects) {
        pw.writeObject(new PemObject("CERTIFICATE", o.getEncoded()));
    }
    pw.close();
    return bao.toByteArray();
}
Also used : PemObject(com.android.org.bouncycastle.util.io.pem.PemObject) PemWriter(com.android.org.bouncycastle.util.io.pem.PemWriter) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) PemWriter(com.android.org.bouncycastle.util.io.pem.PemWriter) X509Certificate(java.security.cert.X509Certificate) Certificate(java.security.cert.Certificate)

Aggregations

PemObject (com.android.org.bouncycastle.util.io.pem.PemObject)6 PemWriter (com.android.org.bouncycastle.util.io.pem.PemWriter)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 OutputStreamWriter (java.io.OutputStreamWriter)6 Writer (java.io.Writer)6 Certificate (java.security.cert.Certificate)6 X509Certificate (java.security.cert.X509Certificate)6