Bug 1061273 - Part 1: Put DEFAULT_PROTOCOLS and DEFAULT_CIPHER_SUITES in GlobalConstants. r=nalexander, a=lizzard
authorRichard Newman <rnewman@mozilla.com>
Thu, 04 Jun 2015 11:07:31 -0700
changeset 266221 d9943a662657
parent 266220 d999d29c8062
child 266222 676ae5e1e869
push id4792
push userryanvm@gmail.com
push date2015-06-10 20:30 +0000
treeherdermozilla-beta@f137fedd1455 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander, lizzard
bugs1061273
milestone39.0
Bug 1061273 - Part 1: Put DEFAULT_PROTOCOLS and DEFAULT_CIPHER_SUITES in GlobalConstants. r=nalexander, a=lizzard
mobile/android/base/background/common/GlobalConstants.java
mobile/android/base/sync/SyncConstants.java
mobile/android/base/sync/net/TLSSocketFactory.java
--- a/mobile/android/base/background/common/GlobalConstants.java
+++ b/mobile/android/base/background/common/GlobalConstants.java
@@ -1,19 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.background.common;
 
 import org.mozilla.gecko.AppConstants;
+import org.mozilla.gecko.AppConstants.Versions;
 
 /**
- * Preprocessed class for storing preprocessed values common to all
- * Android services.
+ * Constant values common to all Android services.
  */
 public class GlobalConstants {
   public static final String BROWSER_INTENT_PACKAGE = AppConstants.ANDROID_PACKAGE_NAME;
   public static final String BROWSER_INTENT_CLASS = AppConstants.BROWSER_INTENT_CLASS_NAME;
 
   /**
    * Bug 800244: this signing-level permission protects broadcast intents that
    * should be received only by the Firefox versions with the given Android
@@ -30,9 +30,31 @@ public class GlobalConstants {
   // do this automatically, but this will do for now. See Bug 800244.
   public static String GECKO_PREFERENCES_CLASS = "org.mozilla.gecko.preferences.GeckoPreferences";
   public static String GECKO_BROADCAST_HEALTHREPORT_UPLOAD_PREF_METHOD  = "broadcastHealthReportUploadPref";
   public static String GECKO_BROADCAST_HEALTHREPORT_PRUNE_METHOD = "broadcastHealthReportPrune";
 
   // Common time values.
   public static final long MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
   public static final long MILLISECONDS_PER_SIX_MONTHS = 180 * MILLISECONDS_PER_DAY;
+
+  // Acceptable cipher suites.
+  /**
+   * See <http://developer.android.com/reference/javax/net/ssl/SSLSocket.html> for
+   * supported Android versions for each set of protocols and cipher suites.
+   */
+  public static final String[] DEFAULT_CIPHER_SUITES;
+  public static final String[] DEFAULT_PROTOCOLS;
+
+  static {
+    DEFAULT_CIPHER_SUITES = new String[]
+        {
+          "TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
+          "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
+          "SSL_RSA_WITH_RC4_128_SHA", // "RC4_SHA"
+        };
+    DEFAULT_PROTOCOLS = new String[]
+        {
+          "SSLv3",
+          "TLSv1",
+        };
+  }
 }
--- a/mobile/android/base/sync/SyncConstants.java
+++ b/mobile/android/base/sync/SyncConstants.java
@@ -1,19 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.sync;
 
 import org.mozilla.gecko.AppConstants;
 
-/**
- * Preprocessed class for storing preprocessed values specific to Android Sync.
- */
 public class SyncConstants {
   public static final String GLOBAL_LOG_TAG = "FxSync";
   public static final String SYNC_MAJOR_VERSION  = "1";
   public static final String SYNC_MINOR_VERSION  = "0";
   public static final String SYNC_VERSION_STRING = SYNC_MAJOR_VERSION + "." +
                                                    AppConstants.MOZ_APP_VERSION + "." +
                                                    SYNC_MINOR_VERSION;
 
--- a/mobile/android/base/sync/net/TLSSocketFactory.java
+++ b/mobile/android/base/sync/net/TLSSocketFactory.java
@@ -5,35 +5,27 @@
 package org.mozilla.gecko.sync.net;
 
 import java.io.IOException;
 import java.net.Socket;
 
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLSocket;
 
+import org.mozilla.gecko.background.common.GlobalConstants;
 import org.mozilla.gecko.background.common.log.Logger;
 
 import ch.boye.httpclientandroidlib.conn.ssl.SSLSocketFactory;
 import ch.boye.httpclientandroidlib.params.HttpParams;
 
 public class TLSSocketFactory extends SSLSocketFactory {
   private static final String LOG_TAG = "TLSSocketFactory";
-  private static final String[] DEFAULT_CIPHER_SUITES = new String[] {
-    "TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
-    "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
-    "SSL_RSA_WITH_RC4_128_SHA", // "RC4_SHA"
-  };
-  private static final String[] DEFAULT_PROTOCOLS = new String[] {
-    "SSLv3",
-    "TLSv1"
-  };
 
   // Guarded by `this`.
-  private static String[] cipherSuites = DEFAULT_CIPHER_SUITES;
+  private static String[] cipherSuites = GlobalConstants.DEFAULT_CIPHER_SUITES;
 
   public TLSSocketFactory(SSLContext sslContext) {
     super(sslContext);
   }
 
   /**
    * Attempt to specify the cipher suites to use for a connection. If
    * setting fails (as it will on Android 2.2, because the wrong names
@@ -58,13 +50,13 @@ public class TLSSocketFactory extends SS
       Logger.warn(LOG_TAG, "Using " + cipherSuites.length + " supported suites.");
       socket.setEnabledCipherSuites(cipherSuites);
     }
   }
 
   @Override
   public Socket createSocket(HttpParams params) throws IOException {
     SSLSocket socket = (SSLSocket) super.createSocket(params);
-    socket.setEnabledProtocols(DEFAULT_PROTOCOLS);
+    socket.setEnabledProtocols(GlobalConstants.DEFAULT_PROTOCOLS);
     setEnabledCipherSuites(socket);
     return socket;
   }
 }