X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2Fserver%2FConnectActionServer.java;fp=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2Fserver%2FConnectActionServer.java;h=42a562d2069bcf275d15dc7dc9316ea1875dcd83;hb=340e6065e8027c2b3b88549b5761b0b9f6950a53;hp=d0ddb92acd253cb5befda49760c5803e379e1688;hpb=20739ebf0c2e50257656a9338f316b3ca7eac1d6;p=fanfix.git diff --git a/src/be/nikiroo/utils/serial/server/ConnectActionServer.java b/src/be/nikiroo/utils/serial/server/ConnectActionServer.java index d0ddb92..42a562d 100644 --- a/src/be/nikiroo/utils/serial/server/ConnectActionServer.java +++ b/src/be/nikiroo/utils/serial/server/ConnectActionServer.java @@ -1,7 +1,10 @@ package be.nikiroo.utils.serial.server; +import java.io.IOException; import java.net.Socket; +import javax.net.ssl.SSLException; + /** * Base class used for the server basic handling. *

@@ -33,6 +36,7 @@ abstract class ConnectActionServer { action = new ConnectAction(s, true, key) { @Override protected void action() throws Exception { + ConnectActionServer.this.serverHello(); ConnectActionServer.this.action(); } @@ -43,6 +47,23 @@ abstract class ConnectActionServer { }; } + /** + * Send the HELLO message (check that the client sends a String "HELLO" and + * send it back, to check I/O and encryption modes). + * + * @throws IOException + * in case of I/O error + * @throws SSLException + * in case of encryption error + */ + protected void serverHello() throws IOException, SSLException { + String HELLO = action.recString(); + if (!"HELLO".equals(HELLO)) { + throw new SSLException("Server did not accept the encryption key"); + } + action.sendString(HELLO); + } + /** * Actually start the process and call the action (synchronous). */