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 booleanvalidResponse(String request, String responsePattern, BufferedReader r, Writer wr)Writesrequesttowrthen reads the response fromrand validates that it matches the pattern provided inresponsePattern.static SocketwrapSocketInSslContext(Socket socket)static SSLSocketwrapSocketInSslContext(Socket socket, String protocol)static SSLSocketwrapSocketInSslContext(Socket socket, String protocol, String[] cipherSuites)
-
-
-
Method Detail
-
wrapSocketInSslContext
public static Socket wrapSocketInSslContext(Socket socket) throws IOException
- Throws:
IOException
-
wrapSocketInSslContext
public static SSLSocket wrapSocketInSslContext(Socket socket, String protocol) throws IOException
- Throws:
IOException
-
wrapSocketInSslContext
public static SSLSocket wrapSocketInSslContext(Socket socket, String protocol, String[] cipherSuites) throws IOException
- Throws:
IOException
-
validResponse
public static boolean validResponse(String request, String responsePattern, BufferedReader r, Writer wr) throws IOException
Writes
requesttowrthen reads the response fromrand validates that it matches the pattern provided inresponsePattern.To obtain
rfrom ajava.util.Socket socket:
new BufferedReader(new InputStreamReader(socket.getInputStream()));To obtain
wrfrom 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 fromrafter writing request to wrr- the BufferedReader from which to get the responsewr- the Writer on which the request is written- Throws:
IOException
-
-