import java.net.Socket;
import java.net.UnknownHostException;
+import javax.net.ssl.SSLException;
+
/**
* Base class used for the client basic handling.
* <p>
action = new ConnectAction(s, false, key) {
@Override
protected void action() throws Exception {
+ ConnectActionClient.this.clientHello();
ConnectActionClient.this.action();
}
};
}
+ /**
+ * Send the HELLO message (send a String "HELLO" to the server, to check I/O
+ * and encryption modes).
+ * <p>
+ * 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).
*/