1 /*
2 * Copyright (c) 1997, 2001, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import java.io.PrintStream;
25 import java.security.SecureRandom;
26
27 //
28 // This holds all the configuration data that's shared between
29 // threads that are associated with passive and active SSL sockets.
30 //
makeDecoder(Boolean lsbFirst) const31 // Passive sockets are SSLServer sockets, which produce active ones
32 // (SSLSockets) that inherit attributes specified here.
33 //
34 // Active sockets are associated with a client or server side handler.
35 // Those are almost identical from the application perspective.
36 //
37 class TestThread extends Thread
38 {
39 protected String basicCipherSuites [];
40 protected SecureRandom prng;
41 protected int iterations = -1;
42
43 // basic test flags
44 protected boolean doRenegotiate;
45 protected boolean initiateHandshake;
46 protected boolean listenHandshake;
47 protected boolean reverseRole;
48
49 // how much output to have, where
50 protected int verbosity = 0;
51 protected PrintStream out = System.out;
52
53 TestThread (String s)
54 { super (s); }
55
56
57 //
58 // Defines the cipher suites that'll be used in initial
59 // handshaking
60 //
61 public void setBasicCipherSuites (String suites [])
62 { basicCipherSuites = suites; }
63
64 //
65 // Says whether to register a callback on handshake
66 // completeion.
67 //
68 public void setListenHandshake (boolean flag)
69 { listenHandshake = flag; }
70
71 //
72 // Says whether to renegotiate after sending some
73 // initial data.
74 //
75 public void setDoRenegotiate (boolean flag)
76 { doRenegotiate = flag; }
77
78 //
79 // Says whether to try initiating handshaking. It's
80 // fine of both client and server do this, or if neither
81 // does it; sending data triggers it regardless.
82 //
83 public void setInitiateHandshake (boolean flag)
84 { initiateHandshake = flag; }
85
86 //
87 // For half-duplex tests, who sends data first?
88 //
89 public void setReverseRole (boolean flag)
90 { reverseRole = flag; }
91
92 //
93 // Where does the diagnostic output go?
94 //
95 public void setOutput (PrintStream out)
96 { this.out = out; }
97
98
99 //
100 // How much output is desired? 2 == noisy-typical, lower is less
101 //
102 public void setVerbosity (int level)
103 { verbosity = level; }
104
105 //
106 // How many loops of random data should a given "client" start?
107 //
108 public void setIterations (int level)
109 { iterations = level; }
110
111 //
112 // Provide some randomness for use with random data I/O.
113 // By default, the "random" data is fully predictable (the
114 // data is generated with a fixed seed). However, both the
115 // client and server could agree to use truly random data.
116 //
117 void setPRNG (SecureRandom prng)
118 { this.prng = prng; }
119 }
120