Java Code Examples for sun.security.util.HexDumpEncoder#encodeBuffer()

The following examples show how to use sun.security.util.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: DTLSOverDatagram.java    From SigFW with GNU Affero General Public License v3.0 6 votes vote down vote up
final static void printHex(String prefix,
        byte[] bytes, int offset, int length) {

    HexDumpEncoder  dump = new HexDumpEncoder();

    synchronized (System.out) {
        System.out.println(prefix);
        try {
            ByteBuffer bb = ByteBuffer.wrap(bytes, offset, length);
            dump.encodeBuffer(bb, System.out);
        } catch (Exception e) {
            // ignore
        }
        System.out.flush();
    }
}
 
Example 2
Source File: SignerInfo.java    From openjdk-jdk9 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 3
Source File: CertStatusExtension.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@Override
public String toString() {
    MessageFormat messageFormat = new MessageFormat(
        "\"certificate status type\": {0}\n" +
        "\"encoded certificate status\": '{'\n" +
        "{1}\n" +
        "'}'",
        Locale.ENGLISH);

    HexDumpEncoder hexEncoder = new HexDumpEncoder();
    String encoded = hexEncoder.encodeBuffer(encodedRequest);

    Object[] messageFields = {
        CertStatusRequestType.nameOf(statusType),
        Utilities.indent(encoded)
    };

    return messageFormat.format(messageFields);
}
 
Example 4
Source File: SSLExtensions.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private static String toString(int extId, byte[] extData) {
    MessageFormat messageFormat = new MessageFormat(
        "\"unknown extension ({0})\": '{'\n" +
        "{1}\n" +
        "'}'",
        Locale.ENGLISH);

    HexDumpEncoder hexEncoder = new HexDumpEncoder();
    String encoded = hexEncoder.encodeBuffer(extData);

    Object[] messageFields = {
        extId,
        Utilities.indent(encoded)
    };

    return messageFormat.format(messageFields);
}
 
Example 5
Source File: ClientHelloChromeInterOp.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected byte[] createClientHelloMessage() {
    byte[] bytes = Base64.getMimeDecoder().decode(ClientHelloMsg);

    // Dump the hex codes of the ClientHello message so that developers
    // can easily check whether the message is captured correct or not.
    HexDumpEncoder dump = new HexDumpEncoder();
    System.out.println("The ClientHello message used");
    try {
        dump.encodeBuffer(bytes, System.out);
    } catch (Exception e) {
        // ignore
    }

    return bytes;
}
 
Example 6
Source File: X509Key.java    From openjdk-jdk9 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 7
Source File: DTLSOverDatagram.java    From SigFW with GNU Affero General Public License v3.0 5 votes vote down vote up
final static void printHex(String prefix, ByteBuffer bb) {
    HexDumpEncoder  dump = new HexDumpEncoder();

    synchronized (System.out) {
        System.out.println(prefix);
        try {
            dump.encodeBuffer(bb.slice(), System.out);
        } catch (Exception e) {
            // ignore
        }
        System.out.flush();
    }
}
 
Example 8
Source File: Debug.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void printHex(String prefix, byte[] bytes, int offset, int length) {
    HexDumpEncoder dump = new HexDumpEncoder();

    synchronized (System.out) {
        System.out.println(prefix);
        try {
            ByteBuffer bb = ByteBuffer.wrap(bytes, offset, length);
            dump.encodeBuffer(bb, System.out);
        } catch (Exception e) {
            // ignore
        }
        System.out.flush();
    }
}
 
Example 9
Source File: KeyImpl.java    From openjdk-jdk9 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 10
Source File: BlockCipherParamsCore.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public String toString() {
    String LINE_SEP = System.getProperty("line.separator");

    String ivString = LINE_SEP + "    iv:" + LINE_SEP + "[";
    HexDumpEncoder encoder = new HexDumpEncoder();
    ivString += encoder.encodeBuffer(this.iv);
    ivString += "]" + LINE_SEP;
    return ivString;
}
 
Example 11
Source File: GCMParameters.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
protected String engineToString() {
    String LINE_SEP = System.lineSeparator();
    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 Bytecoder with Apache License 2.0 5 votes vote down vote up
protected String engineToString() {
    String LINE_SEP = System.lineSeparator();
    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: BlockCipherParamsCore.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public String toString() {
    String LINE_SEP = System.lineSeparator();

    String ivString = LINE_SEP + "    iv:" + LINE_SEP + "[";
    HexDumpEncoder encoder = new HexDumpEncoder();
    ivString += encoder.encodeBuffer(this.iv);
    ivString += "]" + LINE_SEP;
    return ivString;
}
 
Example 14
Source File: RC2Parameters.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
protected String engineToString() {
    String LINE_SEP = System.lineSeparator();
    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: PBEParameters.java    From openjdk-jdk9 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 16
Source File: DTLSOverDatagram.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
final static void printHex(String prefix, ByteBuffer bb) {
    HexDumpEncoder  dump = new HexDumpEncoder();

    synchronized (System.out) {
        System.out.println(prefix);
        try {
            dump.encodeBuffer(bb.slice(), System.out);
        } catch (Exception e) {
            // ignore
        }
        System.out.flush();
    }
}
 
Example 17
Source File: SSLLogger.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private static String formatByteArrayInputStream(
        ByteArrayInputStream bytes) {
    StringBuilder builder = new StringBuilder(512);

    try (ByteArrayOutputStream bytesOut = new ByteArrayOutputStream()) {
        HexDumpEncoder hexEncoder = new HexDumpEncoder();
        hexEncoder.encodeBuffer(bytes, bytesOut);

        builder.append(Utilities.indent(bytesOut.toString()));
    } catch (IOException ioe) {
        // ignore it, just for debugging.
    }

    return builder.toString();
}
 
Example 18
Source File: Handshaker.java    From openjdk-jdk9 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 19
Source File: X509Key.java    From Bytecoder with Apache License 2.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 20
Source File: IPAddressName.java    From Bytecoder with Apache License 2.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);
    }
}