Class SslPortTest
- java.lang.Object
-
- com.dkfqs.measuringagent.javascript.executor.SslPortTest
-
- All Implemented Interfaces:
java.util.EventListener,javax.net.ssl.HandshakeCompletedListener
public class SslPortTest extends java.lang.Object implements javax.net.ssl.HandshakeCompletedListenerTest the connection to a SSL server port and get the certificate chain.
-
-
Constructor Summary
Constructors Constructor Description SslPortTest(java.lang.String host, int port)Create a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonArraygetCertificateChainArray()Get a JSON array of the received SSL server certificates.java.util.ArrayList<java.lang.String>getConnectLog()Get the connect log.java.util.List<java.security.cert.X509Certificate>getPeerCertificateChain()Get the chain of the received SSL server certificates.longgetSslHandshakeTime()Get the SSL handshake time in milliseconds.longgetTcpConnectTime()Get the TCP connect time in milliseconds.voidhandshakeCompleted(javax.net.ssl.HandshakeCompletedEvent handshakeCompletedEvent)Implementation of HandshakeCompletedListener interface.voidsetClientAuthKeyManagers(javax.net.ssl.KeyManager[] clientAuthKeyManagers)Set SSL key managers for client authentication.voidsetLocalOutboundAddress(java.lang.String localOutboundAddress)Set the local outbound address.voidsetSSLHandshakeTimeout(int sslHandshakeTimeoutMillis)Set the SSL handshake timeout.voidsetTCPConnectTimeout(int tcpConnectTimeoutMillis)Set the TCP connect timeout.booleantestConnection()Test the TCP connection.
-
-
-
Method Detail
-
setTCPConnectTimeout
public void setTCPConnectTimeout(int tcpConnectTimeoutMillis)
Set the TCP connect timeout.- Parameters:
tcpConnectTimeoutMillis- the TCP connect timeout in milliseconds
-
setSSLHandshakeTimeout
public void setSSLHandshakeTimeout(int sslHandshakeTimeoutMillis)
Set the SSL handshake timeout.- Parameters:
sslHandshakeTimeoutMillis- the SSL handshake timeout in milliseconds
-
setClientAuthKeyManagers
public void setClientAuthKeyManagers(javax.net.ssl.KeyManager[] clientAuthKeyManagers)
Set SSL key managers for client authentication.- Parameters:
clientAuthKeyManagers- the key managers for SSL client authentication
-
setLocalOutboundAddress
public void setLocalOutboundAddress(java.lang.String localOutboundAddress) throws java.net.UnknownHostExceptionSet the local outbound address.- Parameters:
localOutboundAddress- the local outbound address- Throws:
java.net.UnknownHostException- if the local outbound address is invalid
-
testConnection
public boolean testConnection()
Test the TCP connection.- Returns:
- true if the TCP connection was established and then closed, or false if connecting to the server has failed.
-
getConnectLog
public java.util.ArrayList<java.lang.String> getConnectLog()
Get the connect log.- Returns:
- the connect log
-
getTcpConnectTime
public long getTcpConnectTime()
Get the TCP connect time in milliseconds.- Returns:
- the TCP connect time in milliseconds, or -1 if no such information is available
-
getSslHandshakeTime
public long getSslHandshakeTime()
Get the SSL handshake time in milliseconds.- Returns:
- the SSL handshake time in milliseconds, or -1 if no such information is available
-
getPeerCertificateChain
public java.util.List<java.security.cert.X509Certificate> getPeerCertificateChain()
Get the chain of the received SSL server certificates.- Returns:
- a list of the received SSL server certificates
-
getCertificateChainArray
public JsonArray getCertificateChainArray() throws java.lang.Exception
Get a JSON array of the received SSL server certificates.- Returns:
- the JSON array of the received SSL server certificates
- Throws:
java.lang.Exception- if somewhat fails
-
handshakeCompleted
public void handshakeCompleted(javax.net.ssl.HandshakeCompletedEvent handshakeCompletedEvent)
Implementation of HandshakeCompletedListener interface.- Specified by:
handshakeCompletedin interfacejavax.net.ssl.HandshakeCompletedListener- Parameters:
handshakeCompletedEvent- the event identifying when the SSL Handshake completed on a given SSL connection
-
-