summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2012-09-19 01:31:34 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-19 01:31:36 -0700
commit5d1a870a25f7495755432a42cf8c81818dc369fa (patch)
tree5c354c95de0cd340f2e2efe3ff9694060042091f /core/java
parent5d4206a55c5336a163408422ba3302f5fd8463f7 (diff)
parentb4db962da0fecd9a6f2714148bbdea023610842f (diff)
downloadframeworks_base-5d1a870a25f7495755432a42cf8c81818dc369fa.zip
frameworks_base-5d1a870a25f7495755432a42cf8c81818dc369fa.tar.gz
frameworks_base-5d1a870a25f7495755432a42cf8c81818dc369fa.tar.bz2
Merge "Add APIs to enable SNI and session tickets on sockets." into jb-mr1-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/net/SSLCertificateSocketFactory.java35
1 files changed, 34 insertions, 1 deletions
diff --git a/core/java/android/net/SSLCertificateSocketFactory.java b/core/java/android/net/SSLCertificateSocketFactory.java
index 2703f1d..27cabef 100644
--- a/core/java/android/net/SSLCertificateSocketFactory.java
+++ b/core/java/android/net/SSLCertificateSocketFactory.java
@@ -300,9 +300,10 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory {
* null if no protocol was negotiated.
*
* @param socket a socket created by this factory.
+ * @throws IllegalArgumentException if the socket was not created by this factory.
*/
public byte[] getNpnSelectedProtocol(Socket socket) {
- return ((OpenSSLSocketImpl) socket).getNpnSelectedProtocol();
+ return castToOpenSSLSocket(socket).getNpnSelectedProtocol();
}
/**
@@ -316,6 +317,38 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory {
mInsecureFactory = null;
}
+ /**
+ * Enables <a href="http://tools.ietf.org/html/rfc5077#section-3.2">session ticket</a>
+ * support on the given socket.
+ *
+ * @param socket a socket created by this factory
+ * @param useSessionTickets {@code true} to enable session ticket support on this socket.
+ * @throws IllegalArgumentException if the socket was not created by this factory.
+ */
+ public void setUseSessionTickets(Socket socket, boolean useSessionTickets) {
+ castToOpenSSLSocket(socket).setUseSessionTickets(useSessionTickets);
+ }
+
+ /**
+ * Turns on <a href="http://tools.ietf.org/html/rfc6066#section-3">Server
+ * Name Indication (SNI)</a> on a given socket.
+ *
+ * @param socket a socket created by this factory.
+ * @param hostName the desired SNI hostname, null to disable.
+ * @throws IllegalArgumentException if the socket was not created by this factory.
+ */
+ public void setHostname(Socket socket, String hostName) {
+ castToOpenSSLSocket(socket).setHostname(hostName);
+ }
+
+ private static OpenSSLSocketImpl castToOpenSSLSocket(Socket socket) {
+ if (!(socket instanceof OpenSSLSocketImpl)) {
+ throw new IllegalArgumentException("Socket not created by this factory: "
+ + socket);
+ }
+
+ return (OpenSSLSocketImpl) socket;
+ }
/**
* {@inheritDoc}