Path: blob/master/test/jdk/sun/security/ssl/GenSSLConfigs/TestThread.java
41152 views
/*1* Copyright (c) 1997, 2001, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.PrintStream;24import java.security.SecureRandom;2526//27// This holds all the configuration data that's shared between28// threads that are associated with passive and active SSL sockets.29//30// Passive sockets are SSLServer sockets, which produce active ones31// (SSLSockets) that inherit attributes specified here.32//33// Active sockets are associated with a client or server side handler.34// Those are almost identical from the application perspective.35//36class TestThread extends Thread37{38protected String basicCipherSuites [];39protected SecureRandom prng;40protected int iterations = -1;4142// basic test flags43protected boolean doRenegotiate;44protected boolean initiateHandshake;45protected boolean listenHandshake;46protected boolean reverseRole;4748// how much output to have, where49protected int verbosity = 0;50protected PrintStream out = System.out;5152TestThread (String s)53{ super (s); }545556//57// Defines the cipher suites that'll be used in initial58// handshaking59//60public void setBasicCipherSuites (String suites [])61{ basicCipherSuites = suites; }6263//64// Says whether to register a callback on handshake65// completeion.66//67public void setListenHandshake (boolean flag)68{ listenHandshake = flag; }6970//71// Says whether to renegotiate after sending some72// initial data.73//74public void setDoRenegotiate (boolean flag)75{ doRenegotiate = flag; }7677//78// Says whether to try initiating handshaking. It's79// fine of both client and server do this, or if neither80// does it; sending data triggers it regardless.81//82public void setInitiateHandshake (boolean flag)83{ initiateHandshake = flag; }8485//86// For half-duplex tests, who sends data first?87//88public void setReverseRole (boolean flag)89{ reverseRole = flag; }9091//92// Where does the diagnostic output go?93//94public void setOutput (PrintStream out)95{ this.out = out; }969798//99// How much output is desired? 2 == noisy-typical, lower is less100//101public void setVerbosity (int level)102{ verbosity = level; }103104//105// How many loops of random data should a given "client" start?106//107public void setIterations (int level)108{ iterations = level; }109110//111// Provide some randomness for use with random data I/O.112// By default, the "random" data is fully predictable (the113// data is generated with a fixed seed). However, both the114// client and server could agree to use truly random data.115//116void setPRNG (SecureRandom prng)117{ this.prng = prng; }118}119120121