|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jsslutils.sslcontext.test.MiniSslClientServer
public abstract class MiniSslClientServer
This class contains both a client and a server that can be used to build small tests, to test the SSLContextFactory. These examples come with a demo CA (a few certificates and keys). These are not to be used in real-life application. DO NOT add them to your set of trusted certificates in your web-browser or similar application.
Nested Class Summary | |
---|---|
protected static class |
MiniSslClientServer.RequestHandler
Small class that handles a server request. |
Field Summary | |
---|---|
static String |
CERTIFICATES_DIRECTORY
|
static String |
KEYSTORE_PASSWORD
|
protected Exception |
listeningServerException
|
protected LinkedBlockingQueue<Future<Object>> |
serverRequestsFutures
|
protected int |
serverTimeout
|
protected boolean |
stopServer
|
protected int |
testPort
|
protected boolean |
verboseExceptions
|
Constructor Summary | |
---|---|
MiniSslClientServer()
|
Method Summary | |
---|---|
KeyStore |
getBadClientCertKeyStore()
Returns the keystore containing a test key and certificate that is not to be trusted by the server when CRLs are enabled. |
KeyStore |
getCaKeyStore()
Returns the store of CA certificates, to be used as a trust store. |
protected String |
getCertificatesDirectory()
|
KeyStore |
getGoodClientCertKeyStore()
Returns the keystore containing a test key and certificate that is to be trusted by the server. |
Collection<X509CRL> |
getLocalCRLs()
Returns a collection of CRLs to be used by the tests. |
KeyStore |
getServerCertKeyStore()
Returns the keystore containing the key and the certificate to be used by the server. |
protected Exception |
makeClientRequest(SSLContext sslClientContext)
|
protected SSLServerSocket |
prepareServerSocket(SSLContext sslServerContext)
Creates and binds the SSLServerSocket to a port after trying a few port numbers. |
protected Throwable |
printSslException(String prefix,
SSLException sslException,
SSLSocket socket)
Used for printing out more info when there's a problem. |
protected void |
printSslSocketInfo(SSLSocket socket)
Used for printing out more info when there's a problem. |
protected Thread |
runServer(SSLServerSocket serverSocket)
Starts the mini server. |
boolean |
runTest(SSLContext sslClientContext,
SSLContext sslServerContext)
This runs the main test: it runs a client and a server. |
protected void |
setServerRequestNumber(int serverRequestNumber)
Sets the number of requests the mini server is supposed to accept. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String CERTIFICATES_DIRECTORY
public static final String KEYSTORE_PASSWORD
protected volatile boolean stopServer
protected boolean verboseExceptions
protected volatile int serverTimeout
protected int testPort
protected final LinkedBlockingQueue<Future<Object>> serverRequestsFutures
protected volatile Exception listeningServerException
Constructor Detail |
---|
public MiniSslClientServer()
Method Detail |
---|
protected String getCertificatesDirectory()
public KeyStore getCaKeyStore() throws IOException, NoSuchAlgorithmException, KeyStoreException, CertificateException
IOException
NoSuchAlgorithmException
KeyStoreException
CertificateException
public KeyStore getServerCertKeyStore() throws IOException, NoSuchAlgorithmException, KeyStoreException, CertificateException
IOException
NoSuchAlgorithmException
KeyStoreException
CertificateException
public KeyStore getGoodClientCertKeyStore() throws IOException, NoSuchAlgorithmException, KeyStoreException, CertificateException
IOException
NoSuchAlgorithmException
KeyStoreException
CertificateException
public KeyStore getBadClientCertKeyStore() throws IOException, NoSuchAlgorithmException, KeyStoreException, CertificateException
IOException
NoSuchAlgorithmException
KeyStoreException
CertificateException
public Collection<X509CRL> getLocalCRLs() throws IOException, NoSuchAlgorithmException, KeyStoreException, CertificateException, CRLException
IOException
NoSuchAlgorithmException
KeyStoreException
CertificateException
CRLException
protected void setServerRequestNumber(int serverRequestNumber)
serverRequestNumber
- protected SSLServerSocket prepareServerSocket(SSLContext sslServerContext)
sslServerContext
- SSLContext from which to build the socket and its
SSLSocketFactory.
protected Thread runServer(SSLServerSocket serverSocket)
serverSocket
- bound SSLServerSocket for this server.public boolean runTest(SSLContext sslClientContext, SSLContext sslServerContext) throws IOException, InterruptedException
sslClientContext
- SSLContext to be used by the client.sslServerContext
- SSLContext to be used by the server.
SSLContextFactoryException
IOException
InterruptedException
protected Exception makeClientRequest(SSLContext sslClientContext) throws IOException
sslClientSocketFactory
-
IOException
protected Throwable printSslException(String prefix, SSLException sslException, SSLSocket socket)
prefix
- sslException
- socket
-
protected void printSslSocketInfo(SSLSocket socket)
socket
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |