diff --git a/maverick-synergy-callback-client/src/main/java/com/sshtools/callback/client/CallbackSession.java b/maverick-synergy-callback-client/src/main/java/com/sshtools/callback/client/CallbackSession.java index b80d8753..e6c2af61 100644 --- a/maverick-synergy-callback-client/src/main/java/com/sshtools/callback/client/CallbackSession.java +++ b/maverick-synergy-callback-client/src/main/java/com/sshtools/callback/client/CallbackSession.java @@ -132,7 +132,8 @@ public void connect() throws IOException, SshException { future = app.getSshEngine().connect( hostname, port, - createContext(config)); + createContext(config), + 30000L); future.waitFor(30000L); if(future.isDone() && future.isSuccess()) { diff --git a/maverick-synergy-client/src/main/java/com/sshtools/client/AuthenticationProtocolClient.java b/maverick-synergy-client/src/main/java/com/sshtools/client/AuthenticationProtocolClient.java index 0482d5f8..2c66426e 100644 --- a/maverick-synergy-client/src/main/java/com/sshtools/client/AuthenticationProtocolClient.java +++ b/maverick-synergy-client/src/main/java/com/sshtools/client/AuthenticationProtocolClient.java @@ -117,11 +117,6 @@ public boolean processMessage(byte[] msg) throws IOException, SshException { ByteArrayReader bar = new ByteArrayReader(msg); try { - - ClientAuthenticator currentAuthenticator; - synchronized (this) { - currentAuthenticator = this.currentAuthenticator; - } /** * Try the authenticator first. It may want to handle @@ -149,14 +144,17 @@ public boolean processMessage(byte[] msg) throws IOException, SshException { transport.setActiveService(con); con.start(); + synchronized(currentAuthenticator) { - completedAuthentications.add(currentAuthenticator.getName()); + completedAuthentications.add(currentAuthenticator.getName()); + + if(currentAuthenticator.getName().equals("none")) { + transport.getConnectFuture().connected(transport, transport.getConnection()); + } - if(currentAuthenticator.getName().equals("none")) { - transport.getConnectFuture().connected(transport, transport.getConnection()); - } - - currentAuthenticator.success(); + currentAuthenticator.success(); + + } EventServiceImplementation @@ -195,26 +193,31 @@ public boolean processMessage(byte[] msg) throws IOException, SshException { while(t.hasMoreTokens()) { supportedAuths.add(t.nextToken()); } - - if(currentAuthenticator.getName().equals("none")) { - transport.getConnectFuture().connected(transport, transport.getConnection()); - } - - if(partial) { - completedAuthentications.add(currentAuthenticator.getName()); - currentAuthenticator.success(true, auths.split(",")); - } else { - currentAuthenticator.failure(); - } - if(!doNextAuthentication()) { - transport.addTask(ExecutorOperationSupport.EVENTS, new ConnectionTaskWrapper(transport.getConnection(), new Runnable() { - public void run() { - for (ClientStateListener stateListener : context.getStateListeners()) { - stateListener.authenticate(AuthenticationProtocolClient.this, transport.getConnection(), supportedAuths, partial); + synchronized(currentAuthenticator) { + + if(currentAuthenticator.getName().equals("none")) { + transport.getConnectFuture().connected(transport, transport.getConnection()); + } + + if(partial) { + completedAuthentications.add(currentAuthenticator.getName()); + currentAuthenticator.success(true, auths.split(",")); + } else { + currentAuthenticator.failure(); + } + + + if(!doNextAuthentication()) { + transport.addTask(ExecutorOperationSupport.EVENTS, new ConnectionTaskWrapper(transport.getConnection(), new Runnable() { + public void run() { + for (ClientStateListener stateListener : context.getStateListeners()) { + stateListener.authenticate(AuthenticationProtocolClient.this, transport.getConnection(), supportedAuths, partial); + } } - } - })); + })); + } + } return true;