public void setNpnProtocols(SSLSocket socket, List<Protocol> npnProtocols) { boolean alpnSupported = SET_ALPN_PROTOCOLS.isSupported(socket); boolean npnSupported = SET_NPN_PROTOCOLS.isSupported(socket); if (alpnSupported || npnSupported) { byte[] protocols = concatLengthPrefixed(npnProtocols); if (alpnSupported) { SET_ALPN_PROTOCOLS.invokeWithoutCheckedException(socket, protocols); } if (npnSupported) { SET_NPN_PROTOCOLS.invokeWithoutCheckedException(socket, protocols); } } }
public ByteString getNpnSelectedProtocol(SSLSocket socket) { boolean alpnSupported = GET_ALPN_SELECTED_PROTOCOL.isSupported(socket); boolean npnSupported = GET_NPN_SELECTED_PROTOCOL.isSupported(socket); if (!alpnSupported && !npnSupported) { return null; } if (alpnSupported) { byte[] alpnResult = (byte[]) GET_ALPN_SELECTED_PROTOCOL.invokeWithoutCheckedException(socket, new Object[0]); if (alpnResult != null) { return ByteString.of(alpnResult); } } if (npnSupported) { byte[] npnResult = (byte[]) GET_NPN_SELECTED_PROTOCOL.invokeWithoutCheckedException(socket, new Object[0]); if (npnResult != null) { return ByteString.of(npnResult); } } return null; }
public void enableTlsExtensions(SSLSocket socket, String uriHost) { SET_USE_SESSION_TICKETS.invokeOptionalWithoutCheckedException(socket, Boolean.valueOf(true)); SET_HOSTNAME.invokeOptionalWithoutCheckedException(socket, uriHost); }