Java Code Examples for sun.misc.HexDumpEncoder#encodeBuffer()

The following examples show how to use sun.misc.HexDumpEncoder#encodeBuffer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InputRecord.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: EngineWriter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void dumpPacket(EngineArgs ea, boolean hsData) {
    try {
        HexDumpEncoder hd = new HexDumpEncoder();

        ByteBuffer bb = ea.netData.duplicate();

        int pos = bb.position();
        bb.position(pos - ea.deltaNet());
        bb.limit(pos);

        System.out.println("[Raw write" +
            (hsData ? "" : " (bb)") + "]: length = " +
            bb.remaining());
        hd.encodeBuffer(bb, System.out);
    } catch (IOException e) { }
}
 
Example 3
Source File: OutputRecord.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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) { }
    }
}
 
Example 4
Source File: OutputRecord.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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) { }
    }
}
 
Example 5
Source File: SignerInfo.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 6
Source File: InputRecord.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 7
Source File: KeyImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public String toString() {
    HexDumpEncoder hd = new HexDumpEncoder();
    return "EncryptionKey: keyType=" + keyType
                      + " keyBytes (hex dump)="
                      + (keyBytes == null || keyBytes.length == 0 ?
                         " Empty Key" :
                         '\n' + hd.encodeBuffer(keyBytes)
                      + '\n');


}
 
Example 8
Source File: InputRecord.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void hashInternal(byte databuf [], int offset, int len) {
    if (debug != null && Debug.isOn("data")) {
        try {
            HexDumpEncoder hd = new HexDumpEncoder();

            System.out.println("[read] MD5 and SHA1 hashes:  len = "
                + len);
            hd.encodeBuffer(new ByteArrayInputStream(databuf, offset, len),
                System.out);
        } catch (IOException e) { }
    }
    handshakeHash.update(databuf, offset, len);
}
 
Example 9
Source File: X509Key.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public String toString()
{
    HexDumpEncoder  encoder = new HexDumpEncoder();

    return "algorithm = " + algid.toString()
        + ", unparsed keybits = \n" + encoder.encodeBuffer(key);
}
 
Example 10
Source File: KeyIdentifier.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 11
Source File: GCMParameters.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected String engineToString() {
    String LINE_SEP = System.getProperty("line.separator");
    HexDumpEncoder encoder = new HexDumpEncoder();
    StringBuilder sb
        = new StringBuilder(LINE_SEP + "    iv:" + LINE_SEP + "["
            + encoder.encodeBuffer(iv) + "]");

    sb.append(LINE_SEP + "tLen(bits):" + LINE_SEP + tLen*8 + LINE_SEP);
    return sb.toString();
}
 
Example 12
Source File: PBEParameters.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected String engineToString() {
    String LINE_SEP = System.getProperty("line.separator");
    String saltString = LINE_SEP + "    salt:" + LINE_SEP + "[";
    HexDumpEncoder encoder = new HexDumpEncoder();
    saltString += encoder.encodeBuffer(salt);
    saltString += "]";

    return saltString + LINE_SEP + "    iterationCount:"
        + LINE_SEP + Debug.toHexString(BigInteger.valueOf(iCount))
        + LINE_SEP;
}
 
Example 13
Source File: Handshaker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void printHex(HexDumpEncoder dump, byte[] bytes) {
    if (bytes == null) {
        System.out.println("(key bytes not available)");
    } else {
        try {
            dump.encodeBuffer(bytes, System.out);
        } catch (IOException e) {
            // just for debugging, ignore this
        }
    }
}
 
Example 14
Source File: RC2Parameters.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected String engineToString() {
    String LINE_SEP = System.getProperty("line.separator");
    HexDumpEncoder encoder = new HexDumpEncoder();
    StringBuilder sb
        = new StringBuilder(LINE_SEP + "    iv:" + LINE_SEP + "["
            + encoder.encodeBuffer(iv) + "]");

    if (version != 0) {
        sb.append(LINE_SEP + "version:" + LINE_SEP
            + version + LINE_SEP);
    }
    return sb.toString();
}
 
Example 15
Source File: InputRecord.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void hashInternal(byte databuf [], int offset, int len) {
    if (debug != null && Debug.isOn("data")) {
        try {
            HexDumpEncoder hd = new HexDumpEncoder();

            System.out.println("[read] MD5 and SHA1 hashes:  len = "
                + len);
            hd.encodeBuffer(new ByteArrayInputStream(databuf, offset, len),
                System.out);
        } catch (IOException e) { }
    }
    handshakeHash.update(databuf, offset, len);
}
 
Example 16
Source File: PBEParameters.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected String engineToString() {
    String LINE_SEP = System.getProperty("line.separator");
    String saltString = LINE_SEP + "    salt:" + LINE_SEP + "[";
    HexDumpEncoder encoder = new HexDumpEncoder();
    saltString += encoder.encodeBuffer(salt);
    saltString += "]";

    return saltString + LINE_SEP + "    iterationCount:"
        + LINE_SEP + Debug.toHexString(BigInteger.valueOf(iCount))
        + LINE_SEP;
}
 
Example 17
Source File: OutputRecord.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void hashInternal(byte buf [], int offset, int len) {
    if (debug != null && Debug.isOn("data")) {
        try {
            HexDumpEncoder hd = new HexDumpEncoder();

            System.out.println("[write] MD5 and SHA1 hashes:  len = "
                + len);
            hd.encodeBuffer(new ByteArrayInputStream(buf,
                lastHashed, len), System.out);
        } catch (IOException e) { }
    }

    handshakeHash.update(buf, lastHashed, len);
    lastHashed = count;
}
 
Example 18
Source File: InputRecord.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void hashInternal(byte databuf [], int offset, int len) {
    if (debug != null && Debug.isOn("data")) {
        try {
            HexDumpEncoder hd = new HexDumpEncoder();

            System.out.println("[read] MD5 and SHA1 hashes:  len = "
                + len);
            hd.encodeBuffer(new ByteArrayInputStream(databuf, offset, len),
                System.out);
        } catch (IOException e) { }
    }
    handshakeHash.update(databuf, offset, len);
}
 
Example 19
Source File: Handshaker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void printHex(HexDumpEncoder dump, byte[] bytes) {
    if (bytes == null) {
        System.out.println("(key bytes not available)");
    } else {
        try {
            dump.encodeBuffer(bytes, System.out);
        } catch (IOException e) {
            // just for debugging, ignore this
        }
    }
}
 
Example 20
Source File: IPAddressName.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a printable string of IPaddress
 */
public String toString() {
    try {
        return "IPAddress: " + getName();
    } catch (IOException ioe) {
        // dump out hex rep for debugging purposes
        HexDumpEncoder enc = new HexDumpEncoder();
        return "IPAddress: " + enc.encodeBuffer(address);
    }
}