From: Niki Roo Date: Mon, 22 Apr 2019 19:12:28 +0000 (+0200) Subject: remote: better handling of key error X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=commitdiff_plain;h=7e51d91c4b65a72cd74f62b300ef31b10ccdd8aa;hp=3358927d64264e9b8dafa794450057b0ea61365f remote: better handling of key error --- diff --git a/libs/nikiroo-utils-4.7.2-dev-sources.jar b/libs/nikiroo-utils-4.7.2-dev-sources.jar index b7efc28..9ce0b0e 100644 Binary files a/libs/nikiroo-utils-4.7.2-dev-sources.jar and b/libs/nikiroo-utils-4.7.2-dev-sources.jar differ diff --git a/src/be/nikiroo/fanfix/library/RemoteLibrary.java b/src/be/nikiroo/fanfix/library/RemoteLibrary.java index 63e45ef..c2ed310 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibrary.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibrary.java @@ -7,6 +7,8 @@ import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; +import javax.net.ssl.SSLException; + import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Story; @@ -60,22 +62,22 @@ public class RemoteLibrary extends BasicLibrary { new ConnectActionClientObject(host, port, key) { @Override public void action(Version serverVersion) throws Exception { - try { - Object rep = send(new Object[] { "PING" }); + Object rep = send(new Object[] { "PING" }); - if ("PONG".equals(rep)) { - result[0] = Status.READY; - } else { - result[0] = Status.UNAUTORIZED; - } - } catch (IllegalArgumentException e) { + if ("PONG".equals(rep)) { + result[0] = Status.READY; + } else { result[0] = Status.UNAUTORIZED; } } @Override protected void onError(Exception e) { - result[0] = Status.UNAVAILABLE; + if (e instanceof SSLException) { + result[0] = Status.UNAUTORIZED; + } else { + result[0] = Status.UNAVAILABLE; + } } }.connect(); } catch (UnknownHostException e) { @@ -104,7 +106,12 @@ public class RemoteLibrary extends BasicLibrary { @Override protected void onError(Exception e) { - Instance.getTraceHandler().error(e); + if (e instanceof SSLException) { + Instance.getTraceHandler().error( + "Connection refused (bad key)"); + } else { + Instance.getTraceHandler().error(e); + } } }.connect(); } catch (Exception e) { @@ -139,7 +146,12 @@ public class RemoteLibrary extends BasicLibrary { @Override protected void onError(Exception e) { - Instance.getTraceHandler().error(e); + if (e instanceof SSLException) { + Instance.getTraceHandler().error( + "Connection refused (bad key)"); + } else { + Instance.getTraceHandler().error(e); + } } }.connect(); } catch (Exception e) { @@ -185,7 +197,12 @@ public class RemoteLibrary extends BasicLibrary { @Override protected void onError(Exception e) { - Instance.getTraceHandler().error(e); + if (e instanceof SSLException) { + Instance.getTraceHandler().error( + "Connection refused (bad key)"); + } else { + Instance.getTraceHandler().error(e); + } } }.connect(); } catch (Exception e) { @@ -234,7 +251,12 @@ public class RemoteLibrary extends BasicLibrary { @Override protected void onError(Exception e) { - Instance.getTraceHandler().error(e); + if (e instanceof SSLException) { + Instance.getTraceHandler().error( + "Connection refused (bad key)"); + } else { + Instance.getTraceHandler().error(e); + } } }.connect(); @@ -264,7 +286,12 @@ public class RemoteLibrary extends BasicLibrary { @Override protected void onError(Exception e) { - Instance.getTraceHandler().error(e); + if (e instanceof SSLException) { + Instance.getTraceHandler().error( + "Connection refused (bad key)"); + } else { + Instance.getTraceHandler().error(e); + } } }.connect(); } @@ -291,7 +318,12 @@ public class RemoteLibrary extends BasicLibrary { @Override protected void onError(Exception e) { - Instance.getTraceHandler().error(e); + if (e instanceof SSLException) { + Instance.getTraceHandler().error( + "Connection refused (bad key)"); + } else { + Instance.getTraceHandler().error(e); + } } }.connect(); } catch (IOException e) { @@ -344,7 +376,12 @@ public class RemoteLibrary extends BasicLibrary { @Override protected void onError(Exception e) { - Instance.getTraceHandler().error(e); + if (e instanceof SSLException) { + Instance.getTraceHandler().error( + "Connection refused (bad key)"); + } else { + Instance.getTraceHandler().error(e); + } } }.connect(); } catch (IOException e) { @@ -388,7 +425,12 @@ public class RemoteLibrary extends BasicLibrary { @Override protected void onError(Exception e) { - Instance.getTraceHandler().error(e); + if (e instanceof SSLException) { + Instance.getTraceHandler().error( + "Connection refused (bad key)"); + } else { + Instance.getTraceHandler().error(e); + } } }.connect(); } catch (IOException e) { @@ -415,7 +457,12 @@ public class RemoteLibrary extends BasicLibrary { @Override protected void onError(Exception e) { - Instance.getTraceHandler().error(e); + if (e instanceof SSLException) { + Instance.getTraceHandler().error( + "Connection refused (bad key)"); + } else { + Instance.getTraceHandler().error(e); + } } }.connect(); } catch (IOException e) { @@ -515,7 +562,12 @@ public class RemoteLibrary extends BasicLibrary { @Override protected void onError(Exception e) { - Instance.getTraceHandler().error(e); + if (e instanceof SSLException) { + Instance.getTraceHandler().error( + "Connection refused (bad key)"); + } else { + Instance.getTraceHandler().error(e); + } } }.connect(); } catch (Exception e) { diff --git a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java index f623163..c2edeb3 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java @@ -6,6 +6,8 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import javax.net.ssl.SSLException; + import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.MetaData; @@ -201,7 +203,11 @@ public class RemoteLibraryServer extends ServerObject { @Override protected void onError(Exception e) { - getTraceHandler().error(e); + if (e instanceof SSLException) { + System.out.println("[Client connection refused (bad key)]"); + } else { + getTraceHandler().error(e); + } } /**