Package org.opennms.core.utils
Class SocketUtils
- java.lang.Object
-
- org.opennms.core.utils.SocketUtils
-
-
Constructor Summary
Constructors Constructor Description SocketUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
validResponse(java.lang.String request, java.lang.String responsePattern, java.io.BufferedReader r, java.io.Writer wr)
Writesrequest
towr
then reads the response fromr
and validates that it matches the pattern provided inresponsePattern
.static java.net.Socket
wrapSocketInSslContext(java.net.Socket socket)
static javax.net.ssl.SSLSocket
wrapSocketInSslContext(java.net.Socket socket, java.lang.String protocol)
static javax.net.ssl.SSLSocket
wrapSocketInSslContext(java.net.Socket socket, java.lang.String protocol, java.lang.String[] cipherSuites)
-
-
-
Method Detail
-
wrapSocketInSslContext
public static java.net.Socket wrapSocketInSslContext(java.net.Socket socket) throws java.io.IOException
- Throws:
java.io.IOException
-
wrapSocketInSslContext
public static javax.net.ssl.SSLSocket wrapSocketInSslContext(java.net.Socket socket, java.lang.String protocol) throws java.io.IOException
- Throws:
java.io.IOException
-
wrapSocketInSslContext
public static javax.net.ssl.SSLSocket wrapSocketInSslContext(java.net.Socket socket, java.lang.String protocol, java.lang.String[] cipherSuites) throws java.io.IOException
- Throws:
java.io.IOException
-
validResponse
public static boolean validResponse(java.lang.String request, java.lang.String responsePattern, java.io.BufferedReader r, java.io.Writer wr) throws java.io.IOException
Writes
request
towr
then reads the response fromr
and validates that it matches the pattern provided inresponsePattern
.To obtain
r
from ajava.util.Socket socket
:
new BufferedReader(new InputStreamReader(socket.getInputStream()));
To obtain
wr
from ajava.util.Socket socket
:
new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
- Parameters:
request
- the String to write to wrresponsePattern
- a String representing a regular expression pattern you expect to match the response received fromr
after writing request to wrr
- the BufferedReader from which to get the responsewr
- the Writer on which the request is written- Throws:
java.io.IOException
-
-