本文整理汇总了Java中sun.misc.HexDumpEncoder类的典型用法代码示例。如果您正苦于以下问题:Java HexDumpEncoder类的具体用法?Java HexDumpEncoder怎么用?Java HexDumpEncoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HexDumpEncoder类属于sun.misc包,在下文中一共展示了HexDumpEncoder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import sun.misc.HexDumpEncoder; //导入依赖的package包/类
/**
* 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();
}
示例2: readFully
import sun.misc.HexDumpEncoder; //导入依赖的package包/类
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;
}
示例3: writeBuffer
import sun.misc.HexDumpEncoder; //导入依赖的package包/类
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) { }
}
}
示例4: dumpPacket
import sun.misc.HexDumpEncoder; //导入依赖的package包/类
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) { }
}
示例5: toString
import sun.misc.HexDumpEncoder; //导入依赖的package包/类
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;
}
示例6: encode
import sun.misc.HexDumpEncoder; //导入依赖的package包/类
/**
* Encode the CertId using ASN.1 DER.
* The hash algorithm used is SHA-1.
*/
public void encode(DerOutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
hashAlgId.encode(tmp);
tmp.putOctetString(issuerNameHash);
tmp.putOctetString(issuerKeyHash);
certSerialNumber.encode(tmp);
out.write(DerValue.tag_Sequence, tmp);
if (debug) {
HexDumpEncoder encoder = new HexDumpEncoder();
System.out.println("Encoded certId is " +
encoder.encode(out.toByteArray()));
}
}
示例7: dumpBER
import sun.misc.HexDumpEncoder; //导入依赖的package包/类
public static void dumpBER(OutputStream outStream, String tag, byte[] bytes,
int from, int to) {
try {
outStream.write('\n');
outStream.write(tag.getBytes("UTF8"));
new HexDumpEncoder().encodeBuffer(
new ByteArrayInputStream(bytes, from, to),
outStream);
outStream.write('\n');
} catch (IOException e) {
try {
outStream.write(
"Ber.dumpBER(): error encountered\n".getBytes("UTF8"));
} catch (IOException e2) {
// ignore
}
}
}
示例8: CertId
import sun.misc.HexDumpEncoder; //导入依赖的package包/类
public CertId(X500Principal issuerName, PublicKey issuerKey,
SerialNumber serialNumber) throws IOException {
// compute issuerNameHash
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA1");
} catch (NoSuchAlgorithmException nsae) {
throw new IOException("Unable to create CertId", nsae);
}
hashAlgId = SHA1_ALGID;
md.update(issuerName.getEncoded());
issuerNameHash = md.digest();
// compute issuerKeyHash (remove the tag and length)
byte[] pubKey = issuerKey.getEncoded();
DerValue val = new DerValue(pubKey);
DerValue[] seq = new DerValue[2];
seq[0] = val.data.getDerValue(); // AlgorithmID
seq[1] = val.data.getDerValue(); // Key
byte[] keyBytes = seq[1].getBitString();
md.update(keyBytes);
issuerKeyHash = md.digest();
certSerialNumber = serialNumber;
if (debug) {
HexDumpEncoder encoder = new HexDumpEncoder();
System.out.println("Issuer Name is " + issuerName);
System.out.println("issuerNameHash is " +
encoder.encodeBuffer(issuerNameHash));
System.out.println("issuerKeyHash is " +
encoder.encodeBuffer(issuerKeyHash));
System.out.println("SerialNumber is " + serialNumber.getNumber());
}
}