Search in sources :

Example 41 with HexDumpEncoder

use of sun.misc.HexDumpEncoder in project jdk8u_jdk by JetBrains.

the class ESSCertId method toString.

public String toString() {
    StringBuffer buffer = new StringBuffer();
    buffer.append("[\n\tCertificate hash (SHA-1):\n");
    if (hexDumper == null) {
        hexDumper = new HexDumpEncoder();
    }
    buffer.append(hexDumper.encode(certHash));
    if (issuer != null && serialNumber != null) {
        buffer.append("\n\tIssuer: " + issuer + "\n");
        buffer.append("\t" + serialNumber);
    }
    buffer.append("\n]");
    return buffer.toString();
}
Also used : HexDumpEncoder(sun.misc.HexDumpEncoder)

Example 42 with HexDumpEncoder

use of sun.misc.HexDumpEncoder in project jdk8u_jdk by JetBrains.

the class LDAPCertStore method getCRLs.

/*
     * Gets CRLs from an attribute id and location in the LDAP directory.
     * Returns a Collection containing only the CRLs that match the
     * specified CRLSelector.
     *
     * @param name the location holding the attribute
     * @param id the attribute identifier
     * @param sel a CRLSelector that the CRLs must match
     * @return a Collection of CRLs found
     * @throws CertStoreException       if an exception occurs
     */
private Collection<X509CRL> getCRLs(LDAPRequest request, String id, X509CRLSelector sel) throws CertStoreException {
    /* fetch the encoded crls from storage */
    byte[][] encodedCRL;
    try {
        encodedCRL = request.getValues(id);
    } catch (NamingException namingEx) {
        throw new CertStoreException(namingEx);
    }
    int n = encodedCRL.length;
    if (n == 0) {
        return Collections.emptySet();
    }
    List<X509CRL> crls = new ArrayList<>(n);
    /* decode each crl and check if it matches selector */
    for (int i = 0; i < n; i++) {
        try {
            CRL crl = cf.generateCRL(new ByteArrayInputStream(encodedCRL[i]));
            if (sel.match(crl)) {
                crls.add((X509CRL) crl);
            }
        } catch (CRLException e) {
            if (debug != null) {
                debug.println("LDAPCertStore.getCRLs() encountered exception" + " while parsing CRL, skipping the bad data: ");
                HexDumpEncoder encoder = new HexDumpEncoder();
                debug.println("[ " + encoder.encodeBuffer(encodedCRL[i]) + " ]");
            }
        }
    }
    return crls;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) HexDumpEncoder(sun.misc.HexDumpEncoder) NamingException(javax.naming.NamingException)

Example 43 with HexDumpEncoder

use of sun.misc.HexDumpEncoder in project jdk8u_jdk by JetBrains.

the class InputRecord method readFully.

private int readFully(InputStream s, byte[] b, int off, int len) throws IOException {
    int n = 0;
    while (n < len) {
        int readLen = s.read(b, off + n, len - n);
        if (readLen < 0) {
            return readLen;
        }
        if (debug != null && Debug.isOn("packet")) {
            try {
                HexDumpEncoder hd = new HexDumpEncoder();
                ByteBuffer bb = ByteBuffer.wrap(b, off + n, readLen);
                System.out.println("[Raw read]: length = " + bb.remaining());
                hd.encodeBuffer(bb, System.out);
            } catch (IOException e) {
            }
        }
        n += readLen;
        exlen += readLen;
    }
    return n;
}
Also used : HexDumpEncoder(sun.misc.HexDumpEncoder)

Example 44 with HexDumpEncoder

use of sun.misc.HexDumpEncoder in project jdk8u_jdk by JetBrains.

the class OutputRecord method writeBuffer.

/*
     * Actually do the write here.  For SSLEngine's HS data,
     * we'll override this method and let it take the appropriate
     * action.
     */
void writeBuffer(OutputStream s, byte[] buf, int off, int len, int debugOffset) throws IOException {
    s.write(buf, off, len);
    s.flush();
    // Output only the record from the specified debug offset.
    if (debug != null && Debug.isOn("packet")) {
        try {
            HexDumpEncoder hd = new HexDumpEncoder();
            System.out.println("[Raw write]: length = " + (len - debugOffset));
            hd.encodeBuffer(new ByteArrayInputStream(buf, off + debugOffset, len - debugOffset), System.out);
        } catch (IOException e) {
        }
    }
}
Also used : HexDumpEncoder(sun.misc.HexDumpEncoder)

Example 45 with HexDumpEncoder

use of sun.misc.HexDumpEncoder in project jdk8u_jdk by JetBrains.

the class X509CertImpl method toString.

/**
     * Returns a printable representation of the certificate.  This does not
     * contain all the information available to distinguish this from any
     * other certificate.  The certificate must be fully constructed
     * before this function may be called.
     */
public String toString() {
    if (info == null || algId == null || signature == null)
        return "";
    StringBuilder sb = new StringBuilder();
    sb.append("[\n");
    sb.append(info.toString() + "\n");
    sb.append("  Algorithm: [" + algId.toString() + "]\n");
    HexDumpEncoder encoder = new HexDumpEncoder();
    sb.append("  Signature:\n" + encoder.encodeBuffer(signature));
    sb.append("\n]");
    return sb.toString();
}
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