本文整理汇总了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);
}