@@ -300,9 +300,10 @@ static byte[] toNpnProtocolsList(byte[]... npnProtocols) {
300300 * null if no protocol was negotiated.
301301 *
302302 * @param socket a socket created by this factory.
303+ * @throws IllegalArgumentException if the socket was not created by this factory.
303304 */
304305 public byte [] getNpnSelectedProtocol (Socket socket ) {
305- return (( OpenSSLSocketImpl ) socket ).getNpnSelectedProtocol ();
306+ return castToOpenSSLSocket ( socket ).getNpnSelectedProtocol ();
306307 }
307308
308309 /**
@@ -316,6 +317,38 @@ public void setKeyManagers(KeyManager[] keyManagers) {
316317 mInsecureFactory = null ;
317318 }
318319
320+ /**
321+ * Enables <a href="http://tools.ietf.org/html/rfc5077#section-3.2">session ticket</a>
322+ * support on the given socket.
323+ *
324+ * @param socket a socket created by this factory
325+ * @param useSessionTickets {@code true} to enable session ticket support on this socket.
326+ * @throws IllegalArgumentException if the socket was not created by this factory.
327+ */
328+ public void setUseSessionTickets (Socket socket , boolean useSessionTickets ) {
329+ castToOpenSSLSocket (socket ).setUseSessionTickets (useSessionTickets );
330+ }
331+
332+ /**
333+ * Turns on <a href="http://tools.ietf.org/html/rfc6066#section-3">Server
334+ * Name Indication (SNI)</a> on a given socket.
335+ *
336+ * @param socket a socket created by this factory.
337+ * @param hostName the desired SNI hostname, null to disable.
338+ * @throws IllegalArgumentException if the socket was not created by this factory.
339+ */
340+ public void setHostname (Socket socket , String hostName ) {
341+ castToOpenSSLSocket (socket ).setHostname (hostName );
342+ }
343+
344+ private static OpenSSLSocketImpl castToOpenSSLSocket (Socket socket ) {
345+ if (!(socket instanceof OpenSSLSocketImpl )) {
346+ throw new IllegalArgumentException ("Socket not created by this factory: "
347+ + socket );
348+ }
349+
350+ return (OpenSSLSocketImpl ) socket ;
351+ }
319352
320353 /**
321354 * {@inheritDoc}
0 commit comments