test/jdk/javax/net/ssl/SSLEngine/ConnectionTest.java
author xuelei
Mon, 25 Jun 2018 13:41:39 -0700
changeset 50768 68fa3d4026ea
parent 47216 71c04702a3d5
permissions -rw-r--r--
8196584: TLS 1.3 Implementation Reviewed-by: ascarpino, coffeys, dfuchs, jjiang, jnimeh, mullan, rhalade, ssahoo, valeriep, weijun, wetmore, xuelei Contributed-by: Adam Petcher <adam.petcher@oracle.com>, Amanda Jiang <amanda.jiang@oracle.com>, Anthony Scarpino <anthony.scarpino@oracle.com>, Bradford Wetmore <bradford.wetmore@oracle.com>, Jamil Nimeh <jamil.j.nimeh@oracle.com>, John Jiang <sha.jiang@oracle.com>, Rajan Halade <rajan.halade@oracle.com>, Sibabrata Sahoo <sibabrata.sahoo@oracle.com>, Valerie Peng <valerie.peng@oracle.com>, Weijun Wang <weijun.wang@oracle.com>, Xuelei Fan <xuelei.fan@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
29902
dc24eacaae11 8076221: Disable RC4 cipher suites
asmotrak
parents: 23052
diff changeset
     2
 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5182
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5182
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5182
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @bug 4495742
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @summary Add non-blocking SSL/TLS functionality, usable with any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *      I/O abstraction
50768
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 47216
diff changeset
    29
 * @ignore the dependent implementation details are changed
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * @author Brad Wetmore
29902
dc24eacaae11 8076221: Disable RC4 cipher suites
asmotrak
parents: 23052
diff changeset
    31
 *
dc24eacaae11 8076221: Disable RC4 cipher suites
asmotrak
parents: 23052
diff changeset
    32
 * @run main/othervm ConnectionTest
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
50768
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 47216
diff changeset
    35
/*
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 47216
diff changeset
    36
 * This is a bit hacky, meant to test various conditions.  The main
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 47216
diff changeset
    37
 * thing I wanted to do with this was to do buffer reads/writes
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 47216
diff changeset
    38
 * when buffers were not empty.  (buffer.position() = 10)
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 47216
diff changeset
    39
 * The code could certainly be tightened up a lot.
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 47216
diff changeset
    40
 */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import javax.net.ssl.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import javax.net.ssl.SSLEngineResult.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.nio.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
public class ConnectionTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private SSLContext sslc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private SSLEngine ssle1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private SSLEngine ssle2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
23052
241885315119 8032473: Restructure JSSE regression test hierarchy in jdk test
xuelei
parents: 6856
diff changeset
    53
    private static String pathToStores = "../etc";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private static String keyStoreFile = "keystore";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private static String trustStoreFile = "truststore";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static String passwd = "passphrase";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    private static String keyFilename =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            System.getProperty("test.src", "./") + "/" + pathToStores +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                "/" + keyStoreFile;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private static String trustFilename =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
            System.getProperty("test.src", "./") + "/" + pathToStores +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                "/" + trustStoreFile;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private ByteBuffer appIn1, appOut1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private ByteBuffer appIn2, appOut2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private ByteBuffer oneToTwo, twoToOne;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private ByteBuffer emptyBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private ByteBuffer  oneToTwoShifter, twoToOneShifter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private String hostname = "hostname";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private int portNumber = 77;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public ConnectionTest()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        sslc = getSSLContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        ssle1 = sslc.createSSLEngine(hostname, portNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        ssle2 = sslc.createSSLEngine();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        ssle1.setEnabledCipherSuites(new String [] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            "SSL_RSA_WITH_RC4_128_MD5"});
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
31706
895170f33881 8043202: Prohibit RC4 cipher suites
asmotrak
parents: 29902
diff changeset
    85
        ssle2.setEnabledCipherSuites(new String [] {
895170f33881 8043202: Prohibit RC4 cipher suites
asmotrak
parents: 29902
diff changeset
    86
            "SSL_RSA_WITH_RC4_128_MD5"});
895170f33881 8043202: Prohibit RC4 cipher suites
asmotrak
parents: 29902
diff changeset
    87
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        createBuffers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private SSLContext getSSLContext() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        KeyStore ks = KeyStore.getInstance("JKS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        KeyStore ts = KeyStore.getInstance("JKS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        char[] passphrase = "passphrase".toCharArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        ks.load(new FileInputStream(keyFilename), passphrase);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        ts.load(new FileInputStream(trustFilename), passphrase);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        kmf.init(ks, passphrase);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        tmf.init(ts);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        SSLContext sslCtx = SSLContext.getInstance("TLS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        return sslCtx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    private void createBuffers() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        // Size the buffers as appropriate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        SSLSession session = ssle1.getSession();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        int appBufferMax = session.getApplicationBufferSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        int netBufferMax = session.getPacketBufferSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        appIn1 = ByteBuffer.allocateDirect(appBufferMax + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        appIn2 = ByteBuffer.allocateDirect(appBufferMax + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        appIn1.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        appIn2.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        oneToTwo = ByteBuffer.allocateDirect(netBufferMax + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        twoToOne = ByteBuffer.allocateDirect(netBufferMax + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        oneToTwo.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        twoToOne.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        oneToTwoShifter = oneToTwo.slice();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        twoToOneShifter = twoToOne.slice();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        appOut1 = ByteBuffer.wrap("Hi Engine2, I'm SSLEngine1".getBytes());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        appOut2 = ByteBuffer.wrap("Hello Engine1, I'm SSLEngine2".getBytes());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        emptyBuffer = ByteBuffer.allocate(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        emptyBuffer.limit(5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        emptyBuffer.position(emptyBuffer.limit());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        System.out.println("AppOut1 = " + appOut1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        System.out.println("AppOut2 = " + appOut2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        System.out.println();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    private void checkResult(SSLEngineResult result, Status status,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            HandshakeStatus hsStatus, int consumed, int produced,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            boolean done) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        if ((status != null) && (result.getStatus() != status)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            throw new Exception("Unexpected Status: need = " + status +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                " got = " + result.getStatus());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        if ((hsStatus != null) && (result.getHandshakeStatus() != hsStatus)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            throw new Exception("Unexpected hsStatus: need = " + hsStatus +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                " got = " + result.getHandshakeStatus());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        if ((consumed != -1) && (consumed != result.bytesConsumed())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            throw new Exception("Unexpected consumed: need = " + consumed +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                " got = " + result.bytesConsumed());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        if ((produced != -1) && (produced != result.bytesProduced())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            throw new Exception("Unexpected produced: need = " + produced +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                " got = " + result.bytesProduced());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        if (done && (hsStatus == HandshakeStatus.FINISHED)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            throw new Exception(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                "Handshake already reported finished");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    private boolean isHandshaking(SSLEngine e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        return (e.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    private void test() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        ssle1.setUseClientMode(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        ssle2.setUseClientMode(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        ssle2.setNeedClientAuth(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        System.out.println("Testing for early unwrap/wrap");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        SSLEngineResult result1 = ssle1.unwrap(twoToOne, appIn1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        SSLEngineResult result2 = ssle2.wrap(appOut2, oneToTwo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
         * These should not consume/produce data, because they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
         * are client and server, respectively, and don't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
         * start handshaking this way.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        checkResult(result1, Status.OK, HandshakeStatus.NEED_WRAP,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            0, 0, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        checkResult(result2, Status.OK, HandshakeStatus.NEED_UNWRAP,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            0, 0, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        System.out.println("Doing Initial Handshake");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        boolean done1 = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        boolean done2 = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
         * Do initial handshaking
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        while (isHandshaking(ssle1) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                isHandshaking(ssle2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            System.out.println("================");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            result1 = ssle1.wrap(emptyBuffer, oneToTwo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            checkResult(result1, null, null, 0, -1, done1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            result2 = ssle2.wrap(emptyBuffer, twoToOne);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            checkResult(result2, null, null, 0, -1, done2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            if (result1.getHandshakeStatus() == HandshakeStatus.FINISHED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                done1 = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            if (result2.getHandshakeStatus() == HandshakeStatus.FINISHED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                done2 = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            System.out.println("wrap1 = " + result1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            System.out.println("wrap2 = " + result2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            if (result1.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                Runnable runnable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                while ((runnable = ssle1.getDelegatedTask()) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                    runnable.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            if (result2.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                Runnable runnable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                while ((runnable = ssle2.getDelegatedTask()) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                    runnable.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            oneToTwo.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            twoToOne.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            oneToTwo.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            twoToOne.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            System.out.println("----");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            result1 = ssle1.unwrap(twoToOne, appIn1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            checkResult(result1, null, null, -1, 0, done1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            result2 = ssle2.unwrap(oneToTwo, appIn2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            checkResult(result2, null, null, -1, 0, done2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            if (result1.getHandshakeStatus() == HandshakeStatus.FINISHED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                done1 = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            if (result2.getHandshakeStatus() == HandshakeStatus.FINISHED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                done2 = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            if (result1.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                Runnable runnable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                while ((runnable = ssle1.getDelegatedTask()) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                    runnable.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            if (result2.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                Runnable runnable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                while ((runnable = ssle2.getDelegatedTask()) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                    runnable.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            System.out.println("unwrap1 = " + result1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            System.out.println("unwrap2 = " + result2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            oneToTwoShifter.position(oneToTwo.position() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            oneToTwoShifter.limit(oneToTwo.limit() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            twoToOneShifter.position(twoToOne.position() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            twoToOneShifter.limit(twoToOne.limit() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            oneToTwoShifter.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            twoToOneShifter.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            oneToTwo.position(oneToTwoShifter.position() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            oneToTwo.limit(oneToTwoShifter.limit() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            twoToOne.position(twoToOneShifter.position() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            twoToOne.limit(twoToOneShifter.limit() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        System.out.println("\nDONE HANDSHAKING");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        System.out.println("================");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        if (!done1 || !done2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            throw new Exception("Both should be true:\n" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                " done1 = " + done1 + " done2 = " + done2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        String host = ssle1.getPeerHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        int port = ssle1.getPeerPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        if (!host.equals(hostname) || (port != portNumber)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            throw new Exception("unexpected host/port " + host + ":" + port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        host = ssle2.getPeerHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        port = ssle2.getPeerPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        if ((host != null) || (port != -1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            throw new Exception("unexpected host/port " + host + ":" + port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        SSLSession ssls1 = ssle1.getSession();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        host = ssls1.getPeerHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        port = ssls1.getPeerPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        if (!host.equals(hostname) || (port != portNumber)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            throw new Exception("unexpected host/port " + host + ":" + port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        SSLSession ssls2 = ssle2.getSession();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        host = ssls2.getPeerHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        port = ssls2.getPeerPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        if ((host != null) || (port != -1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            throw new Exception("unexpected host/port " + host + ":" + port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
         * Should be able to write/read a small buffer like this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        int appOut1Len = appOut1.remaining();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        int appOut2Len = appOut2.remaining();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        int net1Len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        int net2Len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        result1 = ssle1.wrap(appOut1, oneToTwo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        checkResult(result1, Status.OK, HandshakeStatus.NOT_HANDSHAKING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            appOut1Len, -1, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        result2 = ssle2.wrap(appOut2, twoToOne);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        checkResult(result2, Status.OK, HandshakeStatus.NOT_HANDSHAKING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            appOut2Len, -1, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        net1Len = result1.bytesProduced();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        net2Len = result2.bytesProduced();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        System.out.println("wrap1 = " + result1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        System.out.println("wrap2 = " + result2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        oneToTwo.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        twoToOne.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        oneToTwo.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        twoToOne.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        System.out.println("----");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        result1 = ssle1.unwrap(twoToOne, appIn1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        checkResult(result1, Status.OK, HandshakeStatus.NOT_HANDSHAKING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            net2Len, appOut2Len, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        result2 = ssle2.unwrap(oneToTwo, appIn2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        checkResult(result2, Status.OK, HandshakeStatus.NOT_HANDSHAKING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            net1Len, appOut1Len, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        System.out.println("unwrap1 = " + result1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        System.out.println("unwrap2 = " + result2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        oneToTwoShifter.position(oneToTwo.position() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        oneToTwoShifter.limit(oneToTwo.limit() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        twoToOneShifter.position(twoToOne.position() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        twoToOneShifter.limit(twoToOne.limit() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        oneToTwoShifter.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        twoToOneShifter.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        oneToTwo.position(oneToTwoShifter.position() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        oneToTwo.limit(oneToTwoShifter.limit() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        twoToOne.position(twoToOneShifter.position() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        twoToOne.limit(twoToOneShifter.limit() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        ssls2.invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        ssle2.beginHandshake();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        System.out.println("\nRENEGOTIATING");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        System.out.println("=============");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        done1 = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        done2 = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        appIn1.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        appIn2.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
         * Do a quick test to see if this can do a switch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
         * into client mode, at this point, you shouldn't be able
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
         * to switch back.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            System.out.println("Try to change client mode");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            ssle2.setUseClientMode(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            throw new Exception("Should have thrown IllegalArgumentException");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            System.out.println("Caught correct IllegalArgumentException");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        while (isHandshaking(ssle1) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                isHandshaking(ssle2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            System.out.println("================");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            result1 = ssle1.wrap(emptyBuffer, oneToTwo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            checkResult(result1, null, null, 0, -1, done1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            result2 = ssle2.wrap(emptyBuffer, twoToOne);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            checkResult(result2, null, null, 0, -1, done2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            if (result1.getHandshakeStatus() == HandshakeStatus.FINISHED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                done1 = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            if (result2.getHandshakeStatus() == HandshakeStatus.FINISHED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                done2 = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            System.out.println("wrap1 = " + result1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            System.out.println("wrap2 = " + result2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            if (result1.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                Runnable runnable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                while ((runnable = ssle1.getDelegatedTask()) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                    runnable.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            if (result2.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                Runnable runnable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                while ((runnable = ssle2.getDelegatedTask()) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                    runnable.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            oneToTwo.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            twoToOne.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            oneToTwo.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            twoToOne.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            System.out.println("----");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            result1 = ssle1.unwrap(twoToOne, appIn1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            checkResult(result1, null, null, -1, 0, done1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            result2 = ssle2.unwrap(oneToTwo, appIn2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            checkResult(result2, null, null, -1, 0, done2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            if (result1.getHandshakeStatus() == HandshakeStatus.FINISHED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                done1 = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            if (result2.getHandshakeStatus() == HandshakeStatus.FINISHED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                done2 = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            System.out.println("unwrap1 = " + result1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            System.out.println("unwrap2 = " + result2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            if (result1.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                Runnable runnable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                while ((runnable = ssle1.getDelegatedTask()) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                    runnable.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            if (result2.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                Runnable runnable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                while ((runnable = ssle2.getDelegatedTask()) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                    runnable.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            oneToTwoShifter.position(oneToTwo.position() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            oneToTwoShifter.limit(oneToTwo.limit() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            twoToOneShifter.position(twoToOne.position() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            twoToOneShifter.limit(twoToOne.limit() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            oneToTwoShifter.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            twoToOneShifter.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            oneToTwo.position(oneToTwoShifter.position() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            oneToTwo.limit(oneToTwoShifter.limit() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            twoToOne.position(twoToOneShifter.position() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            twoToOne.limit(twoToOneShifter.limit() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        host = ssle1.getPeerHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        port = ssle1.getPeerPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        if (!host.equals(hostname) || (port != portNumber)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            throw new Exception("unexpected host/port " + host + ":" + port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        host = ssle2.getPeerHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        port = ssle2.getPeerPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        if ((host != null) || (port != -1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            throw new Exception("unexpected host/port " + host + ":" + port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        SSLSession ssls3 = ssle2.getSession();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        host = ssls1.getPeerHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        port = ssls1.getPeerPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        if (!host.equals(hostname) || (port != portNumber)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            throw new Exception("unexpected host/port " + host + ":" + port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        SSLSession ssls4 = ssle2.getSession();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        host = ssls2.getPeerHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        port = ssls2.getPeerPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        if ((host != null) || (port != -1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            throw new Exception("unexpected host/port " + host + ":" + port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        System.out.println("\nDoing close");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        System.out.println("===========");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        ssle1.closeOutbound();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        ssle2.closeOutbound();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        oneToTwo.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        twoToOne.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        oneToTwo.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        twoToOne.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        appIn1.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        appIn2.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        System.out.println("LAST UNWRAP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        result1 = ssle1.unwrap(twoToOne, appIn1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        checkResult(result1, Status.BUFFER_UNDERFLOW,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            HandshakeStatus.NEED_WRAP, 0, 0, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        result2 = ssle2.unwrap(oneToTwo, appIn2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        checkResult(result2, Status.BUFFER_UNDERFLOW,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            HandshakeStatus.NEED_WRAP, 0, 0, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        System.out.println("unwrap1 = " + result1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        System.out.println("unwrap2 = " + result2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        oneToTwoShifter.position(oneToTwo.position() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        oneToTwoShifter.limit(oneToTwo.limit() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        twoToOneShifter.position(twoToOne.position() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        twoToOneShifter.limit(twoToOne.limit() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        oneToTwoShifter.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        twoToOneShifter.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        oneToTwo.position(oneToTwoShifter.position() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        oneToTwo.limit(oneToTwoShifter.limit() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        twoToOne.position(twoToOneShifter.position() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        twoToOne.limit(twoToOneShifter.limit() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        System.out.println("LAST WRAP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        result1 = ssle1.wrap(appOut1, oneToTwo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        checkResult(result1, Status.CLOSED, HandshakeStatus.NEED_UNWRAP,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
            0, -1, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        result2 = ssle2.wrap(appOut2, twoToOne);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        checkResult(result2, Status.CLOSED, HandshakeStatus.NEED_UNWRAP,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            0, -1, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        System.out.println("wrap1 = " + result1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        System.out.println("wrap2 = " + result2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        net1Len = result1.bytesProduced();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        net2Len = result2.bytesProduced();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        oneToTwo.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        twoToOne.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        oneToTwo.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        twoToOne.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        result1 = ssle1.unwrap(twoToOne, appIn1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        checkResult(result1, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            net1Len, 0, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        result2 = ssle2.unwrap(oneToTwo, appIn2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        checkResult(result2, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            net2Len, 0, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        System.out.println("unwrap1 = " + result1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        System.out.println("unwrap2 = " + result2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        oneToTwoShifter.position(oneToTwo.position() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        oneToTwoShifter.limit(oneToTwo.limit() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        twoToOneShifter.position(twoToOne.position() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        twoToOneShifter.limit(twoToOne.limit() - 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        oneToTwoShifter.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        twoToOneShifter.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        oneToTwo.position(oneToTwoShifter.position() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        oneToTwo.limit(oneToTwoShifter.limit() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        twoToOne.position(twoToOneShifter.position() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        twoToOne.limit(twoToOneShifter.limit() + 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        System.out.println("EXTRA WRAP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        result1 = ssle1.wrap(appOut1, oneToTwo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        checkResult(result1, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            0, 0, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        result2 = ssle2.wrap(appOut2, twoToOne);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        checkResult(result2, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            0, 0, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        System.out.println("wrap1 = " + result1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        System.out.println("wrap2 = " + result2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        oneToTwo.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        twoToOne.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        oneToTwo.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        twoToOne.position(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        System.out.println("EXTRA UNWRAP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        result1 = ssle1.unwrap(twoToOne, appIn1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        checkResult(result1, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            0, 0, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        result2 = ssle2.unwrap(oneToTwo, appIn2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        checkResult(result2, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            0, 0, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        System.out.println("unwrap1 = " + result1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        System.out.println("unwrap2 = " + result2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        checkSession(ssls1, ssls2, ssls3, ssls4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        System.out.println(ssle1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        System.out.println(ssle2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    private static void checkSession(SSLSession ssls1, SSLSession ssls2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            SSLSession ssls3, SSLSession ssls4) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        System.out.println("\nSession Info for SSLEngine1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        System.out.println(ssls1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        System.out.println(ssls1.getCreationTime());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        String peer1 = ssls1.getPeerHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        System.out.println(peer1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        String protocol1 = ssls1.getProtocol();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        System.out.println(protocol1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        java.security.cert.Certificate cert1 = ssls1.getPeerCertificates()[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        System.out.println(cert1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        String ciphersuite1 = ssls1.getCipherSuite();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        System.out.println(ciphersuite1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        System.out.println();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        System.out.println("\nSession Info for SSLEngine2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        System.out.println(ssls2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        System.out.println(ssls2.getCreationTime());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        String peer2 = ssls2.getPeerHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        System.out.println(peer2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        String protocol2 = ssls2.getProtocol();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        System.out.println(protocol2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        java.security.cert.Certificate cert2 = ssls2.getPeerCertificates()[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        System.out.println(cert2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        String ciphersuite2 = ssls2.getCipherSuite();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        System.out.println(ciphersuite2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        System.out.println();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        if (peer1.equals(peer2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            throw new Exception("peer hostnames not equal");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        if (!protocol1.equals(protocol2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            throw new Exception("protocols not equal");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        if (!cert1.equals(cert2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            throw new Exception("certs not equal");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        if (!ciphersuite1.equals(ciphersuite2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            throw new Exception("ciphersuites not equal");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        System.out.println("\nSession Info for SSLEngine3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        System.out.println(ssls3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        System.out.println("\nSession Info for SSLEngine4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        System.out.println(ssls4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        if (ssls3.equals(ssls1) || ssls4.equals(ssls2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
            throw new Exception("sessions should not be equals");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    public static void main(String args[]) throws Exception {
29902
dc24eacaae11 8076221: Disable RC4 cipher suites
asmotrak
parents: 23052
diff changeset
   678
        // reset the security property to make sure that the algorithms
dc24eacaae11 8076221: Disable RC4 cipher suites
asmotrak
parents: 23052
diff changeset
   679
        // and keys used in this test are not disabled.
dc24eacaae11 8076221: Disable RC4 cipher suites
asmotrak
parents: 23052
diff changeset
   680
        Security.setProperty("jdk.tls.disabledAlgorithms", "");
dc24eacaae11 8076221: Disable RC4 cipher suites
asmotrak
parents: 23052
diff changeset
   681
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        ConnectionTest ct = new ConnectionTest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        ct.test();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
}