@Test public void socketSecurityTls() throws Exception { Certificate local = mock(Certificate.class); Certificate remote = mock(Certificate.class); when(local.getEncoded()).thenReturn("localcert".getBytes(Charsets.UTF_8)); when(remote.getEncoded()).thenReturn("remotecert".getBytes(Charsets.UTF_8)); socket.security = new InternalChannelz.Security( new InternalChannelz.Tls("TLS_NULL_WITH_NULL_NULL", local, remote)); assertEquals( Security.newBuilder().setTls( Tls.newBuilder() .setStandardName("TLS_NULL_WITH_NULL_NULL") .setLocalCertificate(ByteString.copyFrom("localcert", Charsets.UTF_8)) .setRemoteCertificate(ByteString.copyFrom("remotecert", Charsets.UTF_8))) .build(), ChannelzProtoUtil.toSocket(socket).getSecurity()); socket.security = new InternalChannelz.Security( new InternalChannelz.Tls("TLS_NULL_WITH_NULL_NULL", null, remote)); assertEquals( Security.newBuilder().setTls( Tls.newBuilder() .setStandardName("TLS_NULL_WITH_NULL_NULL") .setRemoteCertificate(ByteString.copyFrom("remotecert", Charsets.UTF_8))) .build(), ChannelzProtoUtil.toSocket(socket).getSecurity()); socket.security = new InternalChannelz.Security( new InternalChannelz.Tls("TLS_NULL_WITH_NULL_NULL", local, null)); assertEquals( Security.newBuilder().setTls( Tls.newBuilder() .setStandardName("TLS_NULL_WITH_NULL_NULL") .setLocalCertificate(ByteString.copyFrom("localcert", Charsets.UTF_8))) .build(), ChannelzProtoUtil.toSocket(socket).getSecurity()); }
static Socket toSocket(InternalInstrumented<SocketStats> obj) { SocketStats socketStats = getFuture(obj.getStats()); Socket.Builder builder = Socket.newBuilder() .setRef(toSocketRef(obj)) .setLocal(toAddress(socketStats.local)); if (socketStats.security != null) { builder.setSecurity(toSecurity(socketStats.security)); } if (socketStats.remote != null) { builder.setRemote(toAddress(socketStats.remote)); } builder.setData(extractSocketData(socketStats)); return builder.build(); }
ChannelzProtoUtil { static Socket toSocket(InternalInstrumented<SocketStats> obj) { SocketStats socketStats = getFuture(obj.getStats()); Socket.Builder builder = Socket.newBuilder() .setRef(toSocketRef(obj)) .setLocal(toAddress(socketStats.local)); if (socketStats.security != null) { builder.setSecurity(toSecurity(socketStats.security)); } if (socketStats.remote != null) { builder.setRemote(toAddress(socketStats.remote)); } builder.setData(extractSocketData(socketStats)); return builder.build(); } }
ChannelzProtoUtil { static Socket toSocket(InternalInstrumented<SocketStats> obj) { SocketStats socketStats = getFuture(obj.getStats()); Socket.Builder builder = Socket.newBuilder() .setRef(toSocketRef(obj)) .setLocal(toAddress(socketStats.local)); if (socketStats.security != null) { builder.setSecurity(toSecurity(socketStats.security)); } if (socketStats.remote != null) { builder.setRemote(toAddress(socketStats.remote)); } builder.setData(extractSocketData(socketStats)); return builder.build(); } private  ChannelzProtoUtil(); }
ChannelzProtoUtil { static Socket toSocket(InternalInstrumented<SocketStats> obj) { SocketStats socketStats = getFuture(obj.getStats()); Socket.Builder builder = Socket.newBuilder() .setRef(toSocketRef(obj)) .setLocal(toAddress(socketStats.local)); if (socketStats.security != null) { builder.setSecurity(toSecurity(socketStats.security)); } if (socketStats.remote != null) { builder.setRemote(toAddress(socketStats.remote)); } builder.setData(extractSocketData(socketStats)); return builder.build(); } private  ChannelzProtoUtil();  }
ChannelzProtoUtil { static Socket toSocket(InternalInstrumented<SocketStats> obj) { SocketStats socketStats = getFuture(obj.getStats()); Socket.Builder builder = Socket.newBuilder() .setRef(toSocketRef(obj)) .setLocal(toAddress(socketStats.local)); if (socketStats.security != null) { builder.setSecurity(toSecurity(socketStats.security)); } if (socketStats.remote != null) { builder.setRemote(toAddress(socketStats.remote)); } builder.setData(extractSocketData(socketStats)); return builder.build(); } private  ChannelzProtoUtil();  static final String SO_LINGER; static final String SO_TIMEOUT; static final String TCP_INFO; }