Search in sources :

Example 1 with HexDumpEncoder

use of sun.misc.HexDumpEncoder in project j2objc by google.

the class X509CRLEntryImpl method toString.

/**
     * Returns a printable string of this revoked certificate.
     *
     * @return value of this revoked certificate in a printable form.
     */
@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append(serialNumber.toString());
    sb.append("  On: " + revocationDate.toString());
    if (certIssuer != null) {
        sb.append("\n    Certificate issuer: " + certIssuer);
    }
    if (extensions != null) {
        Collection allEntryExts = extensions.getAllExtensions();
        Object[] objs = allEntryExts.toArray();
        sb.append("\n    CRL Entry Extensions: " + objs.length);
        for (int i = 0; i < objs.length; i++) {
            sb.append("\n    [" + (i + 1) + "]: ");
            Extension ext = (Extension) objs[i];
            try {
                if (OIDMap.getClass(ext.getExtensionId()) == null) {
                    sb.append(ext.toString());
                    byte[] extValue = ext.getExtensionValue();
                    if (extValue != null) {
                        DerOutputStream out = new DerOutputStream();
                        out.putOctetString(extValue);
                        extValue = out.toByteArray();
                        HexDumpEncoder enc = new HexDumpEncoder();
                        sb.append("Extension unknown: " + "DER encoded OCTET string =\n" + enc.encodeBuffer(extValue) + "\n");
                    }
                } else
                    //sub-class exists
                    sb.append(ext.toString());
            } catch (Exception e) {
                sb.append(", Error parsing this extension");
            }
        }
    }
    sb.append("\n");
    return sb.toString();
}
Also used : HexDumpEncoder(sun.misc.HexDumpEncoder) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) CRLException(java.security.cert.CRLException)

Example 2 with HexDumpEncoder

use of sun.misc.HexDumpEncoder in project j2objc by google.

the class X509CRLImpl method toString.

/**
     * Returns a printable string of this CRL.
     *
     * @return value of this CRL in a printable form.
     */
public String toString() {
    StringBuffer sb = new StringBuffer();
    sb.append("X.509 CRL v" + (version + 1) + "\n");
    if (sigAlgId != null)
        sb.append("Signature Algorithm: " + sigAlgId.toString() + ", OID=" + (sigAlgId.getOID()).toString() + "\n");
    if (issuer != null)
        sb.append("Issuer: " + issuer.toString() + "\n");
    if (thisUpdate != null)
        sb.append("\nThis Update: " + thisUpdate.toString() + "\n");
    if (nextUpdate != null)
        sb.append("Next Update: " + nextUpdate.toString() + "\n");
    if (revokedList.isEmpty())
        sb.append("\nNO certificates have been revoked\n");
    else {
        sb.append("\nRevoked Certificates: " + revokedList.size());
        int i = 1;
        for (X509CRLEntry entry : revokedList) {
            sb.append("\n[" + i++ + "] " + entry.toString());
        }
    }
    if (extensions != null) {
        Collection<Extension> allExts = extensions.getAllExtensions();
        Object[] objs = allExts.toArray();
        sb.append("\nCRL Extensions: " + objs.length);
        for (int i = 0; i < objs.length; i++) {
            sb.append("\n[" + (i + 1) + "]: ");
            Extension ext = (Extension) objs[i];
            try {
                if (OIDMap.getClass(ext.getExtensionId()) == null) {
                    sb.append(ext.toString());
                    byte[] extValue = ext.getExtensionValue();
                    if (extValue != null) {
                        DerOutputStream out = new DerOutputStream();
                        out.putOctetString(extValue);
                        extValue = out.toByteArray();
                        HexDumpEncoder enc = new HexDumpEncoder();
                        sb.append("Extension unknown: " + "DER encoded OCTET string =\n" + enc.encodeBuffer(extValue) + "\n");
                    }
                } else
                    // sub-class exists
                    sb.append(ext.toString());
            } catch (Exception e) {
                sb.append(", Error parsing this extension");
            }
        }
    }
    if (signature != null) {
        HexDumpEncoder encoder = new HexDumpEncoder();
        sb.append("\nSignature:\n" + encoder.encodeBuffer(signature) + "\n");
    } else
        sb.append("NOT signed yet\n");
    return sb.toString();
}
Also used : X509CRLEntry(java.security.cert.X509CRLEntry) HexDumpEncoder(sun.misc.HexDumpEncoder) SignatureException(java.security.SignatureException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException) CRLException(java.security.cert.CRLException) NoSuchProviderException(java.security.NoSuchProviderException)

Example 3 with HexDumpEncoder

use of sun.misc.HexDumpEncoder in project j2objc by google.

the class KeyIdentifier method toString.

/**
     * Returns a printable representation of the KeyUsage.
     */
public String toString() {
    String s = "KeyIdentifier [\n";
    HexDumpEncoder encoder = new HexDumpEncoder();
    s += encoder.encodeBuffer(octetString);
    s += "]\n";
    return (s);
}
Also used : HexDumpEncoder(sun.misc.HexDumpEncoder)

Example 4 with HexDumpEncoder

use of sun.misc.HexDumpEncoder in project j2objc by google.

the class PKCS9Attribute method toString.

/**
     * Returns a string representation of this attribute.
     */
public String toString() {
    StringBuffer buf = new StringBuffer(100);
    buf.append("[");
    if (index == -1) {
        buf.append(oid.toString());
    } else {
        buf.append(OID_NAME_TABLE.get(PKCS9_OIDS[index]));
    }
    buf.append(": ");
    if (index == -1 || SINGLE_VALUED[index]) {
        if (value instanceof byte[]) {
            // special case for octet string
            HexDumpEncoder hexDump = new HexDumpEncoder();
            buf.append(hexDump.encodeBuffer((byte[]) value));
        } else {
            buf.append(value.toString());
        }
        buf.append("]");
        return buf.toString();
    } else {
        // multi-valued
        boolean first = true;
        Object[] values = (Object[]) value;
        for (int j = 0; j < values.length; j++) {
            if (first)
                first = false;
            else
                buf.append(", ");
            buf.append(values[j].toString());
        }
        return buf.toString();
    }
}
Also used : HexDumpEncoder(sun.misc.HexDumpEncoder)

Example 5 with HexDumpEncoder

use of sun.misc.HexDumpEncoder in project j2objc by google.

the class SignerInfo method toString.

public String toString() {
    HexDumpEncoder hexDump = new HexDumpEncoder();
    String out = "";
    out += "Signer Info for (issuer): " + issuerName + "\n";
    out += "\tversion: " + Debug.toHexString(version) + "\n";
    out += "\tcertificateSerialNumber: " + Debug.toHexString(certificateSerialNumber) + "\n";
    out += "\tdigestAlgorithmId: " + digestAlgorithmId + "\n";
    if (authenticatedAttributes != null) {
        out += "\tauthenticatedAttributes: " + authenticatedAttributes + "\n";
    }
    out += "\tdigestEncryptionAlgorithmId: " + digestEncryptionAlgorithmId + "\n";
    out += "\tencryptedDigest: " + "\n" + hexDump.encodeBuffer(encryptedDigest) + "\n";
    if (unauthenticatedAttributes != null) {
        out += "\tunauthenticatedAttributes: " + unauthenticatedAttributes + "\n";
    }
    return out;
}
Also used : HexDumpEncoder(sun.misc.HexDumpEncoder)

Aggregations

HexDumpEncoder (sun.misc.HexDumpEncoder)51 IOException (java.io.IOException)15 ByteArrayInputStream (java.io.ByteArrayInputStream)6 CRLException (java.security.cert.CRLException)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 CertificateException (java.security.cert.CertificateException)3 NamingException (javax.naming.NamingException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 InvalidKeyException (java.security.InvalidKeyException)2 NoSuchProviderException (java.security.NoSuchProviderException)2 SignatureException (java.security.SignatureException)2 X509CRLEntry (java.security.cert.X509CRLEntry)2 PRF (sun.security.ssl.CipherSuite.PRF)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Constructor (java.lang.reflect.Constructor)1 ByteBuffer (java.nio.ByteBuffer)1 AccessControlContext (java.security.AccessControlContext)1 GeneralSecurityException (java.security.GeneralSecurityException)1 PrivilegedActionException (java.security.PrivilegedActionException)1