X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2Fserver%2FConnectActionClient.java;fp=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2Fserver%2FConnectActionClient.java;h=1b92b42235a91e471cb650b2e8dc48608a1d6dc3;hb=340e6065e8027c2b3b88549b5761b0b9f6950a53;hp=31b71b92af80eb8383fba1099e548fff5a4cd750;hpb=20739ebf0c2e50257656a9338f316b3ca7eac1d6;p=fanfix.git diff --git a/src/be/nikiroo/utils/serial/server/ConnectActionClient.java b/src/be/nikiroo/utils/serial/server/ConnectActionClient.java index 31b71b9..1b92b42 100644 --- a/src/be/nikiroo/utils/serial/server/ConnectActionClient.java +++ b/src/be/nikiroo/utils/serial/server/ConnectActionClient.java @@ -4,6 +4,8 @@ import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; +import javax.net.ssl.SSLException; + /** * Base class used for the client basic handling. *

@@ -57,6 +59,7 @@ abstract class ConnectActionClient { action = new ConnectAction(s, false, key) { @Override protected void action() throws Exception { + ConnectActionClient.this.clientHello(); ConnectActionClient.this.action(); } @@ -67,6 +70,25 @@ abstract class ConnectActionClient { }; } + /** + * Send the HELLO message (send a String "HELLO" to the server, to check I/O + * and encryption modes). + *

+ * Will automatically handle the answer (the server must answer "HELLO" in + * kind). + * + * @throws IOException + * in case of I/O error + * @throws SSLException + * in case of encryption error + */ + protected void clientHello() throws IOException { + String HELLO = action.sendString("HELLO"); + if (!"HELLO".equals(HELLO)) { + throw new SSLException("Server did not accept the encryption key"); + } + } + /** * Actually start the process and call the action (synchronous). */