X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2Fserver%2FConnectActionClient.java;h=cb6bef3988c94e8f07d0306a8714ff85f3a9b1d8;hb=601003e69e1dc81774243c6eadf7982b6b563b33;hp=db06a9f247544cef1d210531d7db45429af1a78b;hpb=f4053377fa15da2f11e82955bfab86e673fa371c;p=fanfix.git diff --git a/src/be/nikiroo/utils/serial/server/ConnectActionClient.java b/src/be/nikiroo/utils/serial/server/ConnectActionClient.java index db06a9f..cb6bef3 100644 --- a/src/be/nikiroo/utils/serial/server/ConnectActionClient.java +++ b/src/be/nikiroo/utils/serial/server/ConnectActionClient.java @@ -23,26 +23,17 @@ abstract class ConnectActionClient { protected ConnectAction action; /** - * Create a new {@link ConnectActionClient} with the current application - * version (see {@link Version#getCurrentVersion()}) as the client version. - * - * @param s - * the socket to bind to - */ - public ConnectActionClient(Socket s) { - this(s, Version.getCurrentVersion()); - } - - /** - * Create a new {@link ConnectActionClient} with the current application - * version (see {@link Version#getCurrentVersion()}) as the client version. + * Create a new {@link ConnectActionClient}, using the current version of + * the program. * * @param host * the host to bind to * @param port * the port to bind to - * @param ssl - * TRUE for an SSL connection, FALSE for plain text + * @param key + * an optional key to encrypt all the communications (if NULL, + * everything will be sent in clear text) + * * * @throws IOException * in case of I/O error @@ -52,9 +43,9 @@ abstract class ConnectActionClient { * if the port parameter is outside the specified range of valid * port values, which is between 0 and 65535, inclusive */ - public ConnectActionClient(String host, int port, boolean ssl) + public ConnectActionClient(String host, int port, String key) throws IOException { - this(Server.createSocket(host, port, ssl), Version.getCurrentVersion()); + this(host, port, key, Version.getCurrentVersion()); } /** @@ -64,11 +55,13 @@ abstract class ConnectActionClient { * the host to bind to * @param port * the port to bind to - * @param ssl - * TRUE for an SSL connection, FALSE for plain text - * @param version + * @param key + * an optional key to encrypt all the communications (if NULL, + * everything will be sent in clear text) + * @param clientVersion * the client version * + * * @throws IOException * in case of I/O error * @throws UnknownHostException @@ -77,9 +70,23 @@ abstract class ConnectActionClient { * if the port parameter is outside the specified range of valid * port values, which is between 0 and 65535, inclusive */ - public ConnectActionClient(String host, int port, boolean ssl, - Version version) throws IOException { - this(Server.createSocket(host, port, ssl), version); + public ConnectActionClient(String host, int port, String key, + Version clientVersion) throws IOException { + this(new Socket(host, port), key, clientVersion); + } + + /** + * Create a new {@link ConnectActionClient}, using the current version of + * the program. + * + * @param s + * the socket to bind to + * @param key + * an optional key to encrypt all the communications (if NULL, + * everything will be sent in clear text) + */ + public ConnectActionClient(Socket s, String key) { + this(s, key, Version.getCurrentVersion()); } /** @@ -87,11 +94,14 @@ abstract class ConnectActionClient { * * @param s * the socket to bind to - * @param version + * @param key + * an optional key to encrypt all the communications (if NULL, + * everything will be sent in clear text) + * @param clientVersion * the client version */ - public ConnectActionClient(Socket s, Version version) { - action = new ConnectAction(s, false, version) { + public ConnectActionClient(Socket s, String key, Version clientVersion) { + action = new ConnectAction(s, false, key, clientVersion) { @Override protected void action(Version serverVersion) throws Exception { ConnectActionClient.this.action(serverVersion); @@ -134,7 +144,7 @@ abstract class ConnectActionClient { * Method that will be called when an action is performed on the client. * * @param serverVersion - * the server version + * the version of the server connected to this client * * @throws Exception * in case of I/O error