test/sun/security/ssl/javax/net/ssl/TLSv11/GenericStreamCipher.java

Print this page


   1 /*
   2  * Copyright (c) 2010, 2011, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27  * @test
  28  * @bug 4873188
  29  * @summary Support TLS 1.1
  30  * @run main/othervm GenericStreamCipher
  31  *
  32  *     SunJSSE does not support dynamic system properties, no way to re-use
  33  *     system properties in samevm/agentvm mode.
  34  *
  35  * @author Xuelei Fan
  36  */
  37 
  38 import java.io.*;
  39 import java.net.*;
  40 import javax.net.ssl.*;
  41 
  42 public class GenericStreamCipher {
  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?
  59      */


 143 
 144         sslOS.write('B');
 145         sslOS.flush();
 146         sslIS.read();
 147 
 148         sslSocket.close();
 149     }
 150 
 151     /*
 152      * =============================================================
 153      * The remainder is just support stuff
 154      */
 155 
 156     // use any free port by default
 157     volatile int serverPort = 0;
 158 
 159     volatile Exception serverException = null;
 160     volatile Exception clientException = null;
 161 
 162     public static void main(String[] args) throws Exception {




 163         String keyFilename =
 164             System.getProperty("test.src", ".") + "/" + pathToStores +
 165                 "/" + keyStoreFile;
 166         String trustFilename =
 167             System.getProperty("test.src", ".") + "/" + pathToStores +
 168                 "/" + trustStoreFile;
 169 
 170         System.setProperty("javax.net.ssl.keyStore", keyFilename);
 171         System.setProperty("javax.net.ssl.keyStorePassword", passwd);
 172         System.setProperty("javax.net.ssl.trustStore", trustFilename);
 173         System.setProperty("javax.net.ssl.trustStorePassword", passwd);
 174 
 175         if (debug)
 176             System.setProperty("javax.net.debug", "all");
 177 
 178         /*
 179          * Start the tests.
 180          */
 181         new GenericStreamCipher();
 182     }


   1 /*
   2  * Copyright (c) 2010, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27  * @test
  28  * @bug 4873188
  29  * @summary Support TLS 1.1
  30  * @run main/othervm GenericStreamCipher
  31  *
  32  *     SunJSSE does not support dynamic system properties, no way to re-use
  33  *     system properties in samevm/agentvm mode.
  34  *
  35  * @author Xuelei Fan
  36  */
  37 
  38 import java.io.*;
  39 import java.security.Security;
  40 import javax.net.ssl.*;
  41 
  42 public class GenericStreamCipher {
  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?
  59      */


 143 
 144         sslOS.write('B');
 145         sslOS.flush();
 146         sslIS.read();
 147 
 148         sslSocket.close();
 149     }
 150 
 151     /*
 152      * =============================================================
 153      * The remainder is just support stuff
 154      */
 155 
 156     // use any free port by default
 157     volatile int serverPort = 0;
 158 
 159     volatile Exception serverException = null;
 160     volatile Exception clientException = null;
 161 
 162     public static void main(String[] args) throws Exception {
 163         // reset the security property to make sure that the algorithms
 164         // and keys used in this test are not disabled.
 165         Security.setProperty("jdk.tls.disabledAlgorithms", "");
 166 
 167         String keyFilename =
 168             System.getProperty("test.src", ".") + "/" + pathToStores +
 169                 "/" + keyStoreFile;
 170         String trustFilename =
 171             System.getProperty("test.src", ".") + "/" + pathToStores +
 172                 "/" + trustStoreFile;
 173 
 174         System.setProperty("javax.net.ssl.keyStore", keyFilename);
 175         System.setProperty("javax.net.ssl.keyStorePassword", passwd);
 176         System.setProperty("javax.net.ssl.trustStore", trustFilename);
 177         System.setProperty("javax.net.ssl.trustStorePassword", passwd);
 178 
 179         if (debug)
 180             System.setProperty("javax.net.debug", "all");
 181 
 182         /*
 183          * Start the tests.
 184          */
 185         new GenericStreamCipher();
 186     }