本文整理匯總了Java中io.netty.buffer.ByteBufUtil.hexDump方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteBufUtil.hexDump方法的具體用法?Java ByteBufUtil.hexDump怎麽用?Java ByteBufUtil.hexDump使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.buffer.ByteBufUtil
的用法示例。
在下文中一共展示了ByteBufUtil.hexDump方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: certificateRejected
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
private void certificateRejected(X509Certificate certificate) {
if (rejectedDir == null) {
return;
}
try {
String[] ss = certificate.getSubjectX500Principal().getName().split(",");
String name = ss.length > 0 ? ss[0] : certificate.getSubjectX500Principal().getName();
String thumbprint = ByteBufUtil.hexDump(Unpooled.wrappedBuffer(DigestUtil.sha1(certificate.getEncoded())));
String filename = String.format("%s [%s].der", URLEncoder.encode(name, "UTF-8"), thumbprint);
File f = new File(rejectedDir.getAbsolutePath() + File.separator + filename);
try (FileOutputStream fos = new FileOutputStream(f)) {
fos.write(certificate.getEncoded());
fos.flush();
}
logger.debug("Added rejected certificate entry: {}", filename);
} catch (CertificateEncodingException | IOException e) {
logger.error("Error adding rejected certificate entry.", e);
}
}
示例2: FingerprintTrustManagerFactory
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
/**
* Creates a new instance.
*
* @param fingerprints a list of SHA1 fingerprints
*/
public FingerprintTrustManagerFactory(byte[]... fingerprints) {
if (fingerprints == null) {
throw new NullPointerException("fingerprints");
}
List<byte[]> list = new ArrayList<byte[]>();
for (byte[] f: fingerprints) {
if (f == null) {
break;
}
if (f.length != SHA1_BYTE_LEN) {
throw new IllegalArgumentException("malformed fingerprint: " +
ByteBufUtil.hexDump(Unpooled.wrappedBuffer(f)) + " (expected: SHA1)");
}
list.add(f.clone());
}
this.fingerprints = list.toArray(new byte[list.size()][]);
}
示例3: channelRead
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof Http2Settings) {
// Expected
} else {
try {
final String typeInfo;
if (msg instanceof ByteBuf) {
typeInfo = msg + " HexDump: " + ByteBufUtil.hexDump((ByteBuf) msg);
} else {
typeInfo = String.valueOf(msg);
}
throw new IllegalStateException("unexpected message type: " + typeInfo);
} finally {
ReferenceCountUtil.release(msg);
}
}
}
示例4: certificateRejected
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
private void certificateRejected(X509Certificate certificate) {
try {
String[] ss = certificate.getSubjectX500Principal().getName().split(",");
String name = ss.length > 0 ? ss[0] : certificate.getSubjectX500Principal().getName();
String thumbprint = ByteBufUtil.hexDump(Unpooled.wrappedBuffer(DigestUtil.sha1(certificate.getEncoded())));
String filename = String.format("%s [%s].der", URLEncoder.encode(name, "UTF-8"), thumbprint);
File f = new File(rejectedDir.getAbsolutePath() + File.separator + filename);
FileOutputStream fos = new FileOutputStream(f);
fos.write(certificate.getEncoded());
fos.flush();
fos.close();
logger.debug("Added rejected certificate entry: {}", filename);
} catch (CertificateEncodingException | IOException e) {
logger.error("Error adding rejected certificate entry.", e);
}
}
示例5: bytesToHex
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
private static String bytesToHex(ByteBuf bytes) {
try {
return ByteBufUtil.hexDump(bytes);
} finally {
bytes.release();
}
}
示例6: asShortText
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
@Override
public String asShortText() {
String shortValue = this.shortValue;
if (shortValue == null) {
this.shortValue = shortValue = ByteBufUtil.hexDump(
data, MACHINE_ID_LEN + PROCESS_ID_LEN + SEQUENCE_LEN + TIMESTAMP_LEN, RANDOM_LEN);
}
return shortValue;
}
示例7: getFilename
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
private static String getFilename(X509Certificate certificate) throws Exception {
String[] ss = certificate.getSubjectX500Principal().getName().split(",");
String name = ss.length > 0 ? ss[0] : certificate.getSubjectX500Principal().getName();
String thumbprint = ByteBufUtil.hexDump(Unpooled.wrappedBuffer(DigestUtil.sha1(certificate.getEncoded())));
return String.format("%s [%s].der", thumbprint, URLEncoder.encode(name, "UTF-8"));
}
示例8: channelRead
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
@Override
public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception {
final ByteBuf byteBuf = (ByteBuf) msg;
final String hexDump = ByteBufUtil.hexDump(byteBuf);
final ByteBuf response = copiedBuffer(hexDump, CharsetUtil.UTF_8);
ctx.writeAndFlush(response);
}
示例9: toString
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
@Override
public String toString() {
if (refCnt() == 0) {
return "SctpFrame{" +
"streamIdentifier=" + streamIdentifier + ", protocolIdentifier=" + protocolIdentifier +
", data=(FREED)}";
}
return "SctpFrame{" +
"streamIdentifier=" + streamIdentifier + ", protocolIdentifier=" + protocolIdentifier +
", data=" + ByteBufUtil.hexDump(content()) + '}';
}
示例10: buildOpaqueValue
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
private static HexString buildOpaqueValue(final ByteBuf buffer) {
final int length = buffer.readUnsignedShort();
final byte[] value = ByteArray.readBytes(buffer, length);
final String hexDump = ByteBufUtil.hexDump(value);
final Iterable<String> splitted = Splitter.fixedLength(2).split(hexDump);
return new HexString(Joiner.on(SEPARATOR).join(splitted));
}
示例11: generateRequestId
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
protected String generateRequestId() {
byte[] id = new byte[16];
// TODO JDK UPGRADE replace to native ThreadLocalRandom
ThreadLocalRandom.current().nextBytes(id);
return ByteBufUtil.hexDump(id);
}
示例12: generateId
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
protected String generateId() {
byte[] id = new byte[16];
// TODO JDK UPGRADE replace to native ThreadLocalRandom
ThreadLocalRandom.current().nextBytes(id);
return ByteBufUtil.hexDump(id);
}
示例13: generateId
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
private String generateId() {
byte[] id = new byte[8];
// TODO JDK UPGRADE replace to native ThreadLocalRandom
ThreadLocalRandom.current().nextBytes(id);
return ByteBufUtil.hexDump(id);
}
示例14: toString
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
@Override
public String toString() {
return "UNKNOWN - " + Integer.toHexString(id) + " - Hex: " + ByteBufUtil.hexDump(buf);
}
示例15: toString
import io.netty.buffer.ByteBufUtil; //導入方法依賴的package包/類
@Override
public String toString() {
return super.toString() + ByteBufUtil.hexDump(data);
}