jdk/test/javax/rmi/ssl/SSLSocketParametersTest.java
author duke
Wed, 05 Jul 2017 16:38:40 +0200
changeset 782 f2e6591ff695
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2004-2007 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
import java.io.File;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.net.ServerSocket;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.net.Socket;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.rmi.Remote;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.rmi.RemoteException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.rmi.server.RMIClientSocketFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.rmi.server.RMIServerSocketFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.rmi.server.UnicastRemoteObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.net.ssl.SSLContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.rmi.ssl.SslRMIClientSocketFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.rmi.ssl.SslRMIServerSocketFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public class SSLSocketParametersTest implements Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    public interface Hello extends Remote {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        public String sayHello() throws RemoteException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    public class HelloImpl extends UnicastRemoteObject implements Hello {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        public HelloImpl(int port,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
                         RMIClientSocketFactory csf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
                         RMIServerSocketFactory ssf)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
            throws RemoteException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            super(port, csf, ssf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        public String sayHello() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            return "Hello World!";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        public Remote runServer() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            System.out.println("Inside HelloImpl::runServer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            // Get a remote stub for this RMI object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            Remote stub = toStub(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
            System.out.println("Stub = " + stub);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            return stub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    public class HelloClient {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        public void runClient(Remote stub) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            System.out.println("Inside HelloClient::runClient");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            // "obj" is the identifier that we'll use to refer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            // to the remote object that implements the "Hello"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            // interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            Hello obj = (Hello) stub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            String message = obj.sayHello();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            System.out.println(message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    public class ClientFactory extends SslRMIClientSocketFactory {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        public ClientFactory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        public Socket createSocket(String host, int port) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            System.out.println("ClientFactory::Calling createSocket(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                               host + "," + port + ")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            return super.createSocket(host, port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public class ServerFactory extends SslRMIServerSocketFactory {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        public ServerFactory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        public ServerFactory(String[] ciphers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                             String[] protocols,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                             boolean need) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            super(ciphers, protocols, need);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        public ServerFactory(SSLContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                             String[] ciphers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                             String[] protocols,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                             boolean need) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            super(context, ciphers, protocols, need);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        public ServerSocket createServerSocket(int port) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            System.out.println("ServerFactory::Calling createServerSocket(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                               port + ")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            return super.createServerSocket(port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public void runTest(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        int test = Integer.parseInt(args[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        String msg1 = "Running SSLSocketParametersTest [" + test + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        String msg2 = "SSLSocketParametersTest [" + test + "] PASSED!";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        String msg3 = "SSLSocketParametersTest [" + test + "] FAILED!";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        switch (test) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        case 1: /* default constructor - default config */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            System.out.println(msg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                HelloImpl server = new HelloImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                          0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                          new ClientFactory(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                          new ServerFactory());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                Remote stub = server.runServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                HelloClient client = new HelloClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                client.runClient(stub);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                System.out.println(msg2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                System.out.println(msg3 + " Exception: " + e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                e.printStackTrace(System.out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                System.exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        case 2: /* non-default constructor - default config */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            System.out.println(msg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                HelloImpl server = new HelloImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                          0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                          new ClientFactory(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                          new ServerFactory(null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                                            null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                                            false));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                Remote stub = server.runServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                HelloClient client = new HelloClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                client.runClient(stub);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                System.out.println(msg2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                System.out.println(msg3 + " Exception: " + e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                e.printStackTrace(System.out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                System.exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        case 3: /* needClientAuth=true */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            System.out.println(msg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                HelloImpl server = new HelloImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                          0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                          new ClientFactory(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                          new ServerFactory(null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                                            null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                                            null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                                            true));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                Remote stub = server.runServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                HelloClient client = new HelloClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                client.runClient(stub);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                System.out.println(msg2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                System.out.println(msg3 + " Exception: " + e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                e.printStackTrace(System.out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                System.exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        case 4: /* server side dummy_ciphersuite */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            System.out.println(msg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                HelloImpl server = new HelloImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                          0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                          new ClientFactory(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                          new ServerFactory(SSLContext.getDefault(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                                            new String[] {"dummy_ciphersuite"},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                                            null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                                            false));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                Remote stub = server.runServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                HelloClient client = new HelloClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                client.runClient(stub);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                System.out.println(msg3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                System.exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                System.out.println(msg2 + " Exception: " + e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                System.exit(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        case 5: /* server side dummy_protocol */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            System.out.println(msg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                HelloImpl server = new HelloImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                          0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                          new ClientFactory(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                          new ServerFactory(null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                                            new String[] {"dummy_protocol"},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                                            false));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                Remote stub = server.runServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                HelloClient client = new HelloClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                client.runClient(stub);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                System.out.println(msg3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                System.exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                System.out.println(msg2 + " Exception: " + e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                System.exit(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        case 6: /* client side dummy_ciphersuite */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            System.out.println(msg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                System.setProperty("javax.rmi.ssl.client.enabledCipherSuites",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                                   "dummy_ciphersuite");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                HelloImpl server = new HelloImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                          0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                          new ClientFactory(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                          new ServerFactory());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                Remote stub = server.runServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                HelloClient client = new HelloClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                client.runClient(stub);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                System.out.println(msg3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                System.exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                System.out.println(msg2 + " Exception: " + e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                System.exit(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        case 7: /* client side dummy_protocol */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            System.out.println(msg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                System.setProperty("javax.rmi.ssl.client.enabledProtocols",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                                   "dummy_protocol");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                HelloImpl server = new HelloImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                          0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                          new ClientFactory(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                          new ServerFactory());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                Remote stub = server.runServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                HelloClient client = new HelloClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                client.runClient(stub);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                System.out.println(msg3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                System.exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                System.out.println(msg2 + " Exception: " + e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                System.exit(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            throw new IllegalArgumentException("invalid test number");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    public static void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        // Set keystore properties (server-side)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        final String keystore = System.getProperty("test.src") +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            File.separator + "keystore";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        System.out.println("KeyStore = " + keystore);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        System.setProperty("javax.net.ssl.keyStore", keystore);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        System.setProperty("javax.net.ssl.keyStorePassword", "password");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        // Set truststore properties (client-side)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        final String truststore = System.getProperty("test.src") +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            File.separator + "truststore";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        System.out.println("TrustStore = " + truststore);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        System.setProperty("javax.net.ssl.trustStore", truststore);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        System.setProperty("javax.net.ssl.trustStorePassword", "trustword");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        // Run test
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        SSLSocketParametersTest test = new SSLSocketParametersTest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        test.runTest(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        System.exit(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
}