test/jdk/javax/net/ssl/SSLEngine/NoAuthClientAuth.java
branchJDK-8145252-TLS13-branch
changeset 56594 99e0f3f3f0e4
parent 56542 56aaa6cb3693
equal deleted inserted replaced
56593:3223aa3fcc6c 56594:99e0f3f3f0e4
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    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
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
       
    24 //
       
    25 // SunJSSE does not support dynamic system properties, no way to re-use
       
    26 // system properties in samevm/agentvm mode.
       
    27 //
       
    28 
    24 /*
    29 /*
    25  * @test
    30  * @test
    26  * @bug 4495742
    31  * @bug 4495742
    27  * @summary Demonstrate SSLEngine switch from no client auth to client auth.
    32  * @summary Demonstrate SSLEngine switch from no client auth to client auth.
    28  * @run main/othervm NoAuthClientAuth
    33  * @run main/othervm NoAuthClientAuth SSLv3
    29  *
    34  * @run main/othervm NoAuthClientAuth TLSv1
    30  *     SunJSSE does not support dynamic system properties, no way to re-use
    35  * @run main/othervm NoAuthClientAuth TLSv1.1
    31  *     system properties in samevm/agentvm mode.
    36  * @run main/othervm NoAuthClientAuth TLSv1.2
    32  *
       
    33  * @author Brad R. Wetmore
    37  * @author Brad R. Wetmore
    34  */
    38  */
    35 
    39 
    36 /**
    40 /**
    37  * A SSLEngine usage example which simplifies the presentation
    41  * A SSLEngine usage example which simplifies the presentation
    76 import javax.net.ssl.SSLEngineResult.*;
    80 import javax.net.ssl.SSLEngineResult.*;
    77 import java.io.*;
    81 import java.io.*;
    78 import java.security.*;
    82 import java.security.*;
    79 import java.nio.*;
    83 import java.nio.*;
    80 
    84 
       
    85 // Note that this test case depends on JSSE provider implementation details.
    81 public class NoAuthClientAuth {
    86 public class NoAuthClientAuth {
    82 
    87 
    83     /*
    88     /*
    84      * Enables logging of the SSLEngine operations.
    89      * Enables logging of the SSLEngine operations.
    85      */
    90      */
   126             System.getProperty("test.src", ".") + "/" + pathToStores +
   131             System.getProperty("test.src", ".") + "/" + pathToStores +
   127                 "/" + keyStoreFile;
   132                 "/" + keyStoreFile;
   128     private static String trustFilename =
   133     private static String trustFilename =
   129             System.getProperty("test.src", ".") + "/" + pathToStores +
   134             System.getProperty("test.src", ".") + "/" + pathToStores +
   130                 "/" + trustStoreFile;
   135                 "/" + trustStoreFile;
       
   136     // the specified protocol
       
   137     private static String tlsProtocol;
   131 
   138 
   132     /*
   139     /*
   133      * Main entry point for this test.
   140      * Main entry point for this test.
   134      */
   141      */
   135     public static void main(String args[]) throws Exception {
   142     public static void main(String args[]) throws Exception {
       
   143         Security.setProperty("jdk.tls.disabledAlgorithms", "");
       
   144 
   136         if (debug) {
   145         if (debug) {
   137             System.setProperty("javax.net.debug", "all");
   146             System.setProperty("javax.net.debug", "all");
   138         }
   147         }
       
   148 
       
   149         tlsProtocol = args[0];
   139 
   150 
   140         NoAuthClientAuth test = new NoAuthClientAuth();
   151         NoAuthClientAuth test = new NoAuthClientAuth();
   141         test.runTest();
   152         test.runTest();
   142 
   153 
   143         System.out.println("Test Passed.");
   154         System.out.println("Test Passed.");
   296         /*
   307         /*
   297          * Similar to above, but using client mode instead.
   308          * Similar to above, but using client mode instead.
   298          */
   309          */
   299         clientEngine = sslc.createSSLEngine("client", 80);
   310         clientEngine = sslc.createSSLEngine("client", 80);
   300         clientEngine.setUseClientMode(true);
   311         clientEngine.setUseClientMode(true);
       
   312         clientEngine.setEnabledProtocols(new String[] { tlsProtocol });
   301     }
   313     }
   302 
   314 
   303     /*
   315     /*
   304      * Create and size the buffers appropriately.
   316      * Create and size the buffers appropriately.
   305      */
   317      */