test/sun/security/ssl/javax/net/ssl/SSLParameters/UseCipherSuitesOrder.java

Print this page


   1 /*
   2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 //
  25 // SunJSSE does not support dynamic system properties, no way to re-use
  26 // system properties in samevm/agentvm mode.
  27 //
  28 
  29 /*
  30  * @test
  31  * @bug 7188657
  32  * @summary There should be a way to reorder the JSSE ciphers
  33  * @run main/othervm UseCipherSuitesOrder
  34  *     TLS_RSA_WITH_AES_128_CBC_SHA,SSL_RSA_WITH_RC4_128_SHA
  35  */
  36 
  37 import java.io.*;
  38 import java.net.*;
  39 import javax.net.ssl.*;
  40 import java.util.Arrays;
  41 
  42 public class UseCipherSuitesOrder {
  43 
  44     /*
  45      * =============================================================
  46      * Set the various variables needed for the tests, then
  47      * specify what tests to run on each side.
  48      */
  49 
  50     /*
  51      * Should we run the client or server in a separate thread?
  52      * Both sides can throw exceptions, but do you have a preference
  53      * as to which side should be the main thread.
  54      */
  55     static boolean separateServerThread = false;
  56 
  57     /*
  58      * Where do we find the keystores?


 178         srvEnabledCipherSuites = Arrays.<String>copyOf(
 179                                             cliEnabledCipherSuites, 2);
 180 
 181         // Reverse the cipher suite preference in server side.
 182         srvEnabledCipherSuites[0] = cliEnabledCipherSuites[1];
 183         srvEnabledCipherSuites[1] = cliEnabledCipherSuites[0];
 184     }
 185 
 186     /*
 187      * =============================================================
 188      * The remainder is just support stuff
 189      */
 190 
 191     // use any free port by default
 192     volatile int serverPort = 0;
 193 
 194     volatile Exception serverException = null;
 195     volatile Exception clientException = null;
 196 
 197     public static void main(String[] args) throws Exception {




 198         // parse the arguments
 199         parseArguments(args);
 200 
 201         String keyFilename =
 202             System.getProperty("test.src", ".") + "/" + pathToStores +
 203                 "/" + keyStoreFile;
 204         String trustFilename =
 205             System.getProperty("test.src", ".") + "/" + pathToStores +
 206                 "/" + trustStoreFile;
 207 
 208         System.setProperty("javax.net.ssl.keyStore", keyFilename);
 209         System.setProperty("javax.net.ssl.keyStorePassword", passwd);
 210         System.setProperty("javax.net.ssl.trustStore", trustFilename);
 211         System.setProperty("javax.net.ssl.trustStorePassword", passwd);
 212 
 213         if (debug)
 214             System.setProperty("javax.net.debug", "all");
 215 
 216         /*
 217          * Start the tests.


   1 /*
   2  * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 //
  25 // SunJSSE does not support dynamic system properties, no way to re-use
  26 // system properties in samevm/agentvm mode.
  27 //
  28 
  29 /*
  30  * @test
  31  * @bug 7188657
  32  * @summary There should be a way to reorder the JSSE ciphers
  33  * @run main/othervm UseCipherSuitesOrder
  34  *     TLS_RSA_WITH_AES_128_CBC_SHA,SSL_RSA_WITH_RC4_128_SHA
  35  */
  36 
  37 import java.io.*;
  38 import java.security.Security;
  39 import javax.net.ssl.*;
  40 import java.util.Arrays;
  41 
  42 public class UseCipherSuitesOrder {
  43 
  44     /*
  45      * =============================================================
  46      * Set the various variables needed for the tests, then
  47      * specify what tests to run on each side.
  48      */
  49 
  50     /*
  51      * Should we run the client or server in a separate thread?
  52      * Both sides can throw exceptions, but do you have a preference
  53      * as to which side should be the main thread.
  54      */
  55     static boolean separateServerThread = false;
  56 
  57     /*
  58      * Where do we find the keystores?


 178         srvEnabledCipherSuites = Arrays.<String>copyOf(
 179                                             cliEnabledCipherSuites, 2);
 180 
 181         // Reverse the cipher suite preference in server side.
 182         srvEnabledCipherSuites[0] = cliEnabledCipherSuites[1];
 183         srvEnabledCipherSuites[1] = cliEnabledCipherSuites[0];
 184     }
 185 
 186     /*
 187      * =============================================================
 188      * The remainder is just support stuff
 189      */
 190 
 191     // use any free port by default
 192     volatile int serverPort = 0;
 193 
 194     volatile Exception serverException = null;
 195     volatile Exception clientException = null;
 196 
 197     public static void main(String[] args) throws Exception {
 198         // reset the security property to make sure that the algorithms
 199         // and keys used in this test are not disabled.
 200         Security.setProperty("jdk.tls.disabledAlgorithms", "");
 201 
 202         // parse the arguments
 203         parseArguments(args);
 204 
 205         String keyFilename =
 206             System.getProperty("test.src", ".") + "/" + pathToStores +
 207                 "/" + keyStoreFile;
 208         String trustFilename =
 209             System.getProperty("test.src", ".") + "/" + pathToStores +
 210                 "/" + trustStoreFile;
 211 
 212         System.setProperty("javax.net.ssl.keyStore", keyFilename);
 213         System.setProperty("javax.net.ssl.keyStorePassword", passwd);
 214         System.setProperty("javax.net.ssl.trustStore", trustFilename);
 215         System.setProperty("javax.net.ssl.trustStorePassword", passwd);
 216 
 217         if (debug)
 218             System.setProperty("javax.net.debug", "all");
 219 
 220         /*
 221          * Start the tests.