You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2015/06/30 12:26:45 UTC
[2/2] mina-sshd git commit: [SSHD-509] Use targeted derived
NamedFactory(ies) for the various generic parameters
[SSHD-509] Use targeted derived NamedFactory(ies) for the various generic parameters
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/84d41b58
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/84d41b58
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/84d41b58
Branch: refs/heads/master
Commit: 84d41b5822b26d3d5307dfa83da854ed30c93235
Parents: e06cfdc
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Tue Jun 30 13:26:25 2015 +0300
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Tue Jun 30 13:26:25 2015 +0300
----------------------------------------------------------------------
.../org/apache/sshd/agent/SshAgentFactory.java | 3 +-
.../agent/local/ChannelAgentForwarding.java | 4 +-
.../sshd/agent/local/ProxyAgentFactory.java | 6 +-
.../sshd/agent/unix/ChannelAgentForwarding.java | 4 +-
.../sshd/agent/unix/UnixAgentFactory.java | 22 +--
.../sshd/client/ClientFactoryManager.java | 2 +
.../java/org/apache/sshd/client/SshClient.java | 15 +-
.../java/org/apache/sshd/client/UserAuth.java | 39 ----
.../org/apache/sshd/client/UserInteraction.java | 41 ----
.../org/apache/sshd/client/auth/UserAuth.java | 39 ++++
.../sshd/client/auth/UserAuthFactory.java | 36 ++++
.../auth/UserAuthKeyboardInteractive.java | 5 +-
.../sshd/client/auth/UserAuthPassword.java | 4 +-
.../sshd/client/auth/UserAuthPublicKey.java | 27 +--
.../sshd/client/auth/UserInteraction.java | 52 +++++
.../client/channel/AbstractClientChannel.java | 6 +-
.../org/apache/sshd/client/kex/DHGClient.java | 5 +-
.../org/apache/sshd/client/kex/DHGEXClient.java | 5 +-
.../client/session/ClientConnectionService.java | 7 +-
.../sshd/client/session/ClientSession.java | 2 +-
.../sshd/client/session/ClientSessionImpl.java | 2 +-
.../client/session/ClientUserAuthService.java | 11 +-
.../org/apache/sshd/common/NamedFactory.java | 24 +--
.../org/apache/sshd/common/NamedResource.java | 14 +-
.../org/apache/sshd/common/ServiceFactory.java | 20 +-
.../sshd/common/channel/ChannelFactory.java | 36 ++++
.../common/channel/ChannelRequestHandler.java | 36 ++++
.../org/apache/sshd/common/cipher/Cipher.java | 33 ++--
.../sshd/common/digest/BuiltinDigests.java | 2 +-
.../sshd/common/digest/DigestFactory.java | 37 ++++
.../common/forward/DefaultTcpipForwarder.java | 5 +-
.../apache/sshd/common/io/IoHandlerFactory.java | 37 ++++
.../sshd/common/kex/KeyExchangeFactory.java | 37 ++++
.../ConnectionServiceRequestHandler.java | 38 ++++
.../apache/sshd/common/util/GenericUtils.java | 20 +-
.../org/apache/sshd/server/ServerBuilder.java | 15 +-
.../sshd/server/ServerFactoryManager.java | 1 +
.../java/org/apache/sshd/server/SshServer.java | 1 +
.../java/org/apache/sshd/server/UserAuth.java | 70 -------
.../sshd/server/auth/AbstractUserAuth.java | 1 -
.../org/apache/sshd/server/auth/UserAuth.java | 70 +++++++
.../sshd/server/auth/UserAuthFactory.java | 37 ++++
.../auth/UserAuthKeyboardInteractive.java | 4 +-
.../apache/sshd/server/auth/UserAuthNone.java | 4 +-
.../sshd/server/auth/UserAuthPassword.java | 4 +-
.../sshd/server/auth/UserAuthPublicKey.java | 3 +-
.../sshd/server/auth/gss/UserAuthGSS.java | 12 +-
.../sshd/server/channel/ChannelSession.java | 43 ++--
.../server/channel/PuttyRequestHandler.java | 8 +-
.../sshd/server/forward/TcpipServerChannel.java | 4 +-
.../global/CancelTcpipForwardHandler.java | 7 +-
.../sshd/server/global/KeepAliveHandler.java | 6 +-
.../server/global/NoMoreSessionsHandler.java | 6 +-
.../sshd/server/global/TcpipForwardHandler.java | 5 +-
.../org/apache/sshd/server/kex/DHGEXServer.java | 5 +-
.../org/apache/sshd/server/kex/DHGServer.java | 5 +-
.../server/session/ServerUserAuthService.java | 2 +-
.../org/apache/sshd/AuthenticationTest.java | 8 +-
.../java/org/apache/sshd/WelcomeBannerTest.java | 2 +-
.../java/org/apache/sshd/client/ClientTest.java | 6 +-
.../client/session/ClientSessionImplTest.java | 4 +-
.../apache/sshd/common/cipher/CipherTest.java | 196 ++++++++++---------
.../sshd/common/config/keys/KeyUtilsTest.java | 8 +-
.../deprecated/ClientUserAuthServiceOld.java | 2 +-
.../deprecated/UserAuthKeyboardInteractive.java | 2 +-
.../java/org/apache/sshd/server/ServerTest.java | 4 +-
66 files changed, 797 insertions(+), 424 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java b/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java
index ba12eaf..33ff448 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java
@@ -31,11 +31,10 @@ import org.apache.sshd.common.session.ConnectionService;
public interface SshAgentFactory {
/**
- * Retrieve the channel factory used to create channels on the client side.
* The channels are requested by the ssh server when forwarding a client request.
* The channel will receive agent requests and need to forward them to the agent,
* either local or through another proxy.
- * @return
+ * @return The channel factory used to create channels on the client side
*/
NamedFactory<Channel> getChannelForwardingFactory();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
index 6aef192..a59d7d2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
@@ -25,9 +25,9 @@ import org.apache.sshd.agent.SshAgent;
import org.apache.sshd.agent.common.AbstractAgentClient;
import org.apache.sshd.client.future.DefaultOpenFuture;
import org.apache.sshd.client.future.OpenFuture;
-import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.channel.Channel;
+import org.apache.sshd.common.channel.ChannelFactory;
import org.apache.sshd.common.channel.ChannelOutputStream;
import org.apache.sshd.common.future.CloseFuture;
import org.apache.sshd.common.future.SshFutureListener;
@@ -40,7 +40,7 @@ import org.apache.sshd.server.channel.AbstractServerChannel;
*/
public class ChannelAgentForwarding extends AbstractServerChannel {
- public static class ChannelAgentForwardingFactory implements NamedFactory<Channel> {
+ public static class ChannelAgentForwardingFactory implements ChannelFactory {
public static final ChannelAgentForwardingFactory INSTANCE = new ChannelAgentForwardingFactory();
public ChannelAgentForwardingFactory() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java
index 4b3e02a..11d30ef 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java
@@ -39,9 +39,13 @@ public class ProxyAgentFactory implements SshAgentFactory {
private final Map<String, AgentServerProxy> proxies = new ConcurrentHashMap<String, AgentServerProxy>();
+ public ProxyAgentFactory() {
+ super();
+ }
+
@Override
public NamedFactory<Channel> getChannelForwardingFactory() {
- return new ChannelAgentForwarding.ChannelAgentForwardingFactory();
+ return ChannelAgentForwarding.ChannelAgentForwardingFactory.INSTANCE;
}
@Override
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
index 7a38bdd..6cfc81a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
@@ -28,9 +28,9 @@ import org.apache.sshd.agent.SshAgent;
import org.apache.sshd.client.future.DefaultOpenFuture;
import org.apache.sshd.client.future.OpenFuture;
import org.apache.sshd.common.FactoryManagerUtils;
-import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.channel.Channel;
+import org.apache.sshd.common.channel.ChannelFactory;
import org.apache.sshd.common.channel.ChannelOutputStream;
import org.apache.sshd.common.future.CloseFuture;
import org.apache.sshd.common.future.SshFutureListener;
@@ -49,7 +49,7 @@ import org.apache.tomcat.jni.Status;
*/
public class ChannelAgentForwarding extends AbstractServerChannel {
- public static class ChannelAgentForwardingFactory implements NamedFactory<Channel>, ExecutorServiceCarrier {
+ public static class ChannelAgentForwardingFactory implements ChannelFactory, ExecutorServiceCarrier {
public static final ChannelAgentForwardingFactory INSTANCE = new ChannelAgentForwardingFactory();
public ChannelAgentForwardingFactory() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java
index c101842..e2c9ea5 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java
@@ -40,17 +40,17 @@ public class UnixAgentFactory implements SshAgentFactory, ExecutorServiceConfigu
private ExecutorService executor;
private boolean shutdownExecutor;
private final NamedFactory<Channel> factory = new ChannelAgentForwarding.ChannelAgentForwardingFactory() {
- @Override
- public ExecutorService getExecutorService() {
- return UnixAgentFactory.this.getExecutorService();
- }
-
- @Override
- public boolean isShutdownOnExit() {
- return UnixAgentFactory.this.isShutdownOnExit();
- }
-
- };
+ @Override
+ public ExecutorService getExecutorService() {
+ return UnixAgentFactory.this.getExecutorService();
+ }
+
+ @Override
+ public boolean isShutdownOnExit() {
+ return UnixAgentFactory.this.isShutdownOnExit();
+ }
+
+ };
public UnixAgentFactory() {
super();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java b/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java
index 0af6014..cf105d2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java
@@ -20,6 +20,8 @@ package org.apache.sshd.client;
import java.util.List;
+import org.apache.sshd.client.auth.UserAuth;
+import org.apache.sshd.client.auth.UserInteraction;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.NamedFactory;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
index 9b814d7..659e718 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
@@ -38,9 +38,12 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
+import org.apache.sshd.agent.SshAgentFactory;
+import org.apache.sshd.client.auth.UserAuth;
import org.apache.sshd.client.auth.UserAuthKeyboardInteractive;
import org.apache.sshd.client.auth.UserAuthPassword;
import org.apache.sshd.client.auth.UserAuthPublicKey;
+import org.apache.sshd.client.auth.UserInteraction;
import org.apache.sshd.client.channel.ChannelShell;
import org.apache.sshd.client.channel.ClientChannel;
import org.apache.sshd.client.config.keys.ClientIdentity;
@@ -166,26 +169,28 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa
ValidateUtils.checkNotNull(getServerKeyVerifier(), "ServerKeyVerifier not set", GenericUtils.EMPTY_OBJECT_ARRAY);
// Register the additional agent forwarding channel if needed
- if (getAgentFactory() != null) {
+ SshAgentFactory agentFactory = getAgentFactory();
+ if (agentFactory != null) {
List<NamedFactory<Channel>> factories = getChannelFactories();
if (GenericUtils.isEmpty(factories)) {
factories = new ArrayList<NamedFactory<Channel>>();
} else {
factories = new ArrayList<NamedFactory<Channel>>(factories);
}
- factories.add(getAgentFactory().getChannelForwardingFactory());
+ factories.add(ValidateUtils.checkNotNull(agentFactory.getChannelForwardingFactory(), "No agent channel forwarding factory for %s", agentFactory));
+
setChannelFactories(factories);
}
if (GenericUtils.isEmpty(getServiceFactories())) {
setServiceFactories(Arrays.asList(
- new ClientUserAuthService.Factory(),
- new ClientConnectionService.Factory()
+ ClientUserAuthService.ClientUserAuthServiceFactory.INSTANCE,
+ ClientConnectionService.ClientConnectionServiceFactory.INSTANCE
));
}
if (GenericUtils.isEmpty(getUserAuthFactories())) {
- setUserAuthFactories(Arrays.asList(
+ setUserAuthFactories(Arrays.<NamedFactory<UserAuth>>asList(
UserAuthPublicKey.UserAuthPublicKeyFactory.INSTANCE,
UserAuthKeyboardInteractive.UserAuthKeyboardInteractiveFactory.INSTANCE,
UserAuthPassword.UserAuthPasswordFactory.INSTANCE
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/UserAuth.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/UserAuth.java b/sshd-core/src/main/java/org/apache/sshd/client/UserAuth.java
deleted file mode 100644
index 7e8d337..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/UserAuth.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd.client;
-
-import java.util.Collection;
-
-import org.apache.sshd.client.session.ClientSession;
-import org.apache.sshd.common.util.buffer.Buffer;
-
-/**
- * TODO Add javadoc
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public interface UserAuth {
-
- void init(ClientSession session, String service, Collection<?> identities) throws Exception;
-
- boolean process(Buffer buffer) throws Exception;
-
- void destroy();
-
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/UserInteraction.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/UserInteraction.java b/sshd-core/src/main/java/org/apache/sshd/client/UserInteraction.java
deleted file mode 100644
index d828a6b..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/UserInteraction.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd.client;
-
-/**
- * Interface used by the ssh client to communicate with the end user.
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see <a href="https://www.ietf.org/rfc/rfc4256.txt">RFC 4256</A>
- */
-public interface UserInteraction {
-
- /**
- * Displays the welcome banner to the user.
- *
- * @param banner the welcome banner
- */
- void welcome(String banner);
-
- String[] interactive(String destination,
- String name,
- String instruction,
- String lang,
- String[] prompt,
- boolean[] echo);
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuth.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuth.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuth.java
new file mode 100644
index 0000000..808ef14
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuth.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.client.auth;
+
+import java.util.Collection;
+
+import org.apache.sshd.client.session.ClientSession;
+import org.apache.sshd.common.util.buffer.Buffer;
+
+/**
+ * TODO Add javadoc
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface UserAuth {
+
+ void init(ClientSession session, String service, Collection<?> identities) throws Exception;
+
+ boolean process(Buffer buffer) throws Exception;
+
+ void destroy();
+
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthFactory.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthFactory.java
new file mode 100644
index 0000000..e72f409
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthFactory.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.client.auth;
+
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface UserAuthFactory extends NamedFactory<UserAuth> {
+ // required because of generics issues
+ Transformer<UserAuthFactory,NamedFactory<UserAuth>> FAC2NAMED=new Transformer<UserAuthFactory,NamedFactory<UserAuth>>() {
+ @Override
+ public NamedFactory<UserAuth> transform(UserAuthFactory input) {
+ return input;
+ }
+ };
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java
index 4cbdc8f..57ade35 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java
@@ -28,10 +28,7 @@ import java.util.Iterator;
import java.util.List;
import org.apache.sshd.client.ClientFactoryManager;
-import org.apache.sshd.client.UserAuth;
-import org.apache.sshd.client.UserInteraction;
import org.apache.sshd.client.session.ClientSession;
-import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.buffer.Buffer;
@@ -44,7 +41,7 @@ import org.apache.sshd.common.util.logging.AbstractLoggingBean;
*/
public class UserAuthKeyboardInteractive extends AbstractLoggingBean implements UserAuth {
- public static class UserAuthKeyboardInteractiveFactory implements NamedFactory<UserAuth> {
+ public static class UserAuthKeyboardInteractiveFactory implements UserAuthFactory {
public static final UserAuthKeyboardInteractiveFactory INSTANCE = new UserAuthKeyboardInteractiveFactory();
public UserAuthKeyboardInteractiveFactory() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
index b9e885b..d0482f9 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
@@ -23,9 +23,7 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import org.apache.sshd.client.UserAuth;
import org.apache.sshd.client.session.ClientSession;
-import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.logging.AbstractLoggingBean;
@@ -37,7 +35,7 @@ import org.apache.sshd.common.util.logging.AbstractLoggingBean;
*/
public class UserAuthPassword extends AbstractLoggingBean implements UserAuth {
- public static class UserAuthPasswordFactory implements NamedFactory<UserAuth> {
+ public static class UserAuthPasswordFactory implements UserAuthFactory {
public static final UserAuthPasswordFactory INSTANCE = new UserAuthPasswordFactory();
public UserAuthPasswordFactory() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
index e691825..e737d57 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
@@ -18,8 +18,6 @@
*/
package org.apache.sshd.client.auth;
-import static org.apache.sshd.common.config.keys.KeyUtils.getKeyType;
-
import java.io.IOException;
import java.security.KeyPair;
import java.security.PublicKey;
@@ -30,13 +28,12 @@ import java.util.List;
import org.apache.sshd.agent.SshAgent;
import org.apache.sshd.agent.SshAgentFactory;
-import org.apache.sshd.client.UserAuth;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.SshConstants;
+import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.keyprovider.KeyPairProvider;
-import org.apache.sshd.common.session.AbstractSession;
import org.apache.sshd.common.signature.Signature;
import org.apache.sshd.common.util.Pair;
import org.apache.sshd.common.util.ValidateUtils;
@@ -51,7 +48,7 @@ import org.apache.sshd.common.util.logging.AbstractLoggingBean;
*/
public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
- public static class UserAuthPublicKeyFactory implements NamedFactory<UserAuth> {
+ public static class UserAuthPublicKeyFactory implements UserAuthFactory {
public static final String NAME = "publickey";
public static final UserAuthPublicKeyFactory INSTANCE = new UserAuthPublicKeyFactory();
@@ -117,8 +114,9 @@ public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
if (keys.hasNext()) {
current = keys.next();
PublicKey key = current.getPublicKey();
- String algo = getKeyType(key);
- log.debug("Send SSH_MSG_USERAUTH_REQUEST for publickey");
+ String algo = KeyUtils.getKeyType(key);
+ log.debug("Send SSH_MSG_USERAUTH_REQUEST request publickey algo={}", algo);
+
buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST);
buffer.putString(session.getUsername());
buffer.putString(service);
@@ -129,13 +127,16 @@ public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
session.writePacket(buffer);
return true;
}
+
+ log.debug("No more keys to send");
return false;
}
+
byte cmd = buffer.getByte();
if (cmd == SshConstants.SSH_MSG_USERAUTH_PK_OK) {
PublicKey key = current.getPublicKey();
- String algo = getKeyType(key);
- log.debug("Send SSH_MSG_USERAUTH_REQUEST for publickey");
+ String algo = KeyUtils.getKeyType(key);
+ log.debug("Send SSH_MSG_USERAUTH_REQUEST reply publickey algo={}", algo);
buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST);
buffer.putString(session.getUsername());
buffer.putString(service);
@@ -145,7 +146,7 @@ public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
buffer.putPublicKey(key);
Buffer bs = new ByteArrayBuffer();
- bs.putBytes(((AbstractSession) session).getKex().getH());
+ bs.putBytes(session.getKex().getH());
bs.putByte(SshConstants.SSH_MSG_USERAUTH_REQUEST);
bs.putString(session.getUsername());
bs.putString(service);
@@ -153,8 +154,8 @@ public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
bs.putByte((byte) 1);
bs.putString(algo);
bs.putPublicKey(key);
- byte[] sig = current.sign(bs.getCompactData());
+ byte[] sig = current.sign(bs.getCompactData());
bs = new ByteArrayBuffer();
bs.putString(algo);
bs.putBytes(sig);
@@ -164,7 +165,7 @@ public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
return true;
}
- throw new IllegalStateException("Received unknown packet");
+ throw new IllegalStateException("Received unknown packet: cmd=" + cmd);
}
@Override
@@ -219,7 +220,7 @@ public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
@Override
public byte[] sign(byte[] data) throws Exception {
- String keyType = getKeyType(pair);
+ String keyType = KeyUtils.getKeyType(pair);
Signature verif = ValidateUtils.checkNotNull(
NamedFactory.Utils.create(manager.getSignatureFactories(), keyType),
"No signer could be located for key type=%s",
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/auth/UserInteraction.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserInteraction.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserInteraction.java
new file mode 100644
index 0000000..fad4694
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserInteraction.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.client.auth;
+
+/**
+ * Interface used by the ssh client to communicate with the end user.
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @see <a href="https://www.ietf.org/rfc/rfc4256.txt">RFC 4256</A>
+ */
+public interface UserInteraction {
+
+ /**
+ * Displays the welcome banner to the user.
+ * @param banner The welcome banner
+ */
+ void welcome(String banner);
+
+ /**
+ * @param destination The session identifier
+ * @param name The interaction name (may be empty)
+ * @param instruction The instruction (may be empty)
+ * @param lang The language for the data (may be empty)
+ * @param prompt The prompts to be displayed (may be empty)
+ * @param echo For each prompt whether to echo the user's response
+ * @return The replies - <B>Note:</B> the protocol states that the number
+ * of replies should be <U>exactly</U> the same as the number of prompts,
+ * however we do not enforce it since it is defined as the <U>server's</U>
+ * job to check and manage this violation
+ */
+ String[] interactive(String destination,
+ String name,
+ String instruction,
+ String lang,
+ String[] prompt,
+ boolean[] echo);
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
index b444c16..dd2de79 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
@@ -32,7 +32,7 @@ import org.apache.sshd.common.channel.AbstractChannel;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.channel.ChannelAsyncInputStream;
import org.apache.sshd.common.channel.ChannelAsyncOutputStream;
-import org.apache.sshd.common.channel.RequestHandler;
+import org.apache.sshd.common.channel.ChannelRequestHandler;
import org.apache.sshd.common.io.IoInputStream;
import org.apache.sshd.common.io.IoOutputStream;
import org.apache.sshd.common.util.buffer.Buffer;
@@ -328,7 +328,7 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C
return exitStatus;
}
- private class ExitStatusChannelRequestHandler implements RequestHandler<Channel> {
+ private class ExitStatusChannelRequestHandler implements ChannelRequestHandler {
public ExitStatusChannelRequestHandler() {
super();
}
@@ -345,7 +345,7 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C
}
}
- private class ExitSignalChannelRequestHandler implements RequestHandler<Channel> {
+ private class ExitSignalChannelRequestHandler implements ChannelRequestHandler {
public ExitSignalChannelRequestHandler() {
super();
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
index 4667987..cdbf6a4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
@@ -26,6 +26,7 @@ import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.kex.AbstractDH;
import org.apache.sshd.common.kex.DHFactory;
import org.apache.sshd.common.kex.KeyExchange;
+import org.apache.sshd.common.kex.KeyExchangeFactory;
import org.apache.sshd.common.session.AbstractSession;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.signature.Signature;
@@ -46,8 +47,8 @@ public class DHGClient extends AbstractDHClientKeyExchange {
protected final DHFactory factory;
protected AbstractDH dh;
- public static final NamedFactory<KeyExchange> newFactory(final DHFactory delegate) {
- return new NamedFactory<KeyExchange>() {
+ public static final KeyExchangeFactory newFactory(final DHFactory delegate) {
+ return new KeyExchangeFactory() {
@Override
public String getName() {
return delegate.getName();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
index 00319b8..79c1a4a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
@@ -29,6 +29,7 @@ import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.kex.AbstractDH;
import org.apache.sshd.common.kex.DHFactory;
import org.apache.sshd.common.kex.KeyExchange;
+import org.apache.sshd.common.kex.KeyExchangeFactory;
import org.apache.sshd.common.session.AbstractSession;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.signature.Signature;
@@ -52,8 +53,8 @@ public class DHGEXClient extends AbstractDHClientKeyExchange {
protected byte[] p;
protected byte[] g;
- public static final NamedFactory<KeyExchange> newFactory(final DHFactory delegate) {
- return new NamedFactory<KeyExchange>() {
+ public static final KeyExchangeFactory newFactory(final DHFactory delegate) {
+ return new KeyExchangeFactory() {
@Override
public String getName() {
return delegate.getName();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
index 9be89e3..38bd7be 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
@@ -41,7 +41,12 @@ import org.apache.sshd.common.util.buffer.Buffer;
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class ClientConnectionService extends AbstractConnectionService {
- public static class Factory implements ServiceFactory {
+ public static class ClientConnectionServiceFactory implements ServiceFactory {
+ public static final ClientConnectionServiceFactory INSTANCE = new ClientConnectionServiceFactory();
+
+ public ClientConnectionServiceFactory() {
+ super();
+ }
@Override
public String getName() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
index d694b75..442c5d2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
@@ -25,7 +25,7 @@ import java.util.Map;
import org.apache.sshd.client.ClientFactoryManager;
import org.apache.sshd.client.SshClient;
-import org.apache.sshd.client.UserInteraction;
+import org.apache.sshd.client.auth.UserInteraction;
import org.apache.sshd.client.channel.ChannelDirectTcpip;
import org.apache.sshd.client.channel.ChannelExec;
import org.apache.sshd.client.channel.ChannelShell;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
index 50c0d5a..305c53b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
@@ -31,7 +31,7 @@ import java.util.Map;
import org.apache.sshd.client.ClientFactoryManager;
import org.apache.sshd.client.ServerKeyVerifier;
-import org.apache.sshd.client.UserInteraction;
+import org.apache.sshd.client.auth.UserInteraction;
import org.apache.sshd.client.channel.ChannelDirectTcpip;
import org.apache.sshd.client.channel.ChannelExec;
import org.apache.sshd.client.channel.ChannelShell;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
index 1658e48..42a728a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
@@ -24,8 +24,8 @@ import java.util.Arrays;
import java.util.List;
import org.apache.sshd.client.ClientFactoryManager;
-import org.apache.sshd.client.UserAuth;
-import org.apache.sshd.client.UserInteraction;
+import org.apache.sshd.client.auth.UserAuth;
+import org.apache.sshd.client.auth.UserInteraction;
import org.apache.sshd.client.future.AuthFuture;
import org.apache.sshd.client.future.DefaultAuthFuture;
import org.apache.sshd.common.FactoryManagerUtils;
@@ -46,7 +46,12 @@ import org.apache.sshd.common.util.buffer.Buffer;
*/
public class ClientUserAuthService extends CloseableUtils.AbstractCloseable implements Service {
- public static class Factory implements ServiceFactory {
+ public static class ClientUserAuthServiceFactory implements ServiceFactory {
+ public static final ClientUserAuthServiceFactory INSTANCE = new ClientUserAuthServiceFactory();
+
+ public ClientUserAuthServiceFactory() {
+ super();
+ }
@Override
public String getName() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java
index 76c1e0c..16e797b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.Transformer;
/**
@@ -50,7 +49,6 @@ public interface NamedFactory<T> extends Factory<T>, NamedResource {
/**
* Create an instance of the specified name by looking up the needed factory
* in the list.
- *
* @param factories list of available factories
* @param name the factory name to use
* @param <T> type of object to create
@@ -67,7 +65,6 @@ public interface NamedFactory<T> extends Factory<T>, NamedResource {
/**
* Get a comma separated list of the factory names from the given list.
- *
* @param factories list of available factories
* @return a comma separated list of factory names
* @deprecated Use {@link NamedResource.Utils#getNames(Collection)}
@@ -79,7 +76,6 @@ public interface NamedFactory<T> extends Factory<T>, NamedResource {
/**
* Remove the factory identified by the name from the list.
- *
* @param factories list of factories
* @param name the name of the factory to remove
* @param <T> type of object to create
@@ -95,23 +91,15 @@ public interface NamedFactory<T> extends Factory<T>, NamedResource {
/**
* Retrieve the factory identified by its name from the list.
- *
* @param factories list of available factories
- * @param name the name of the factory to retrieve
- * @param <T> type of object create by the factories
- * @return a factory or <code>null</code> if not found in the list
+ * @param name the name of the factory to retrieve - ignored if {@code null}/empty
+ * @param <T> type of object create by the factories - ignored if {@code null}/empty
+ * @return A (case <U>insensitive</U>) matching factory or {@code null} if not found in the list
+ * @deprecated Use {@link NamedResource.Utils#findByName(String, java.util.Comparator, Collection)
*/
+ @Deprecated
public static <T> NamedFactory<T> get(Collection<? extends NamedFactory<T>> factories, String name) {
- if (GenericUtils.isEmpty(factories)) {
- return null;
- }
-
- for (NamedFactory<T> f : factories) {
- if (f.getName().equals(name)) {
- return f;
- }
- }
- return null;
+ return NamedResource.Utils.findByName(name, String.CASE_INSENSITIVE_ORDER, factories);
}
public static final <S extends OptionalFeature,T,E extends NamedFactory<T>> List<NamedFactory<T>> setUpTransformedFactories(
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java b/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java
index e1c2287..c5032d8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java
@@ -95,11 +95,21 @@ public interface NamedResource {
/**
* @param name Name of the resource - ignored if {@code null}/empty
+ * @param resources The {@link NamedResource} to check - ignored if {@code null}/empty
+ * @return The <U>first</U> resource whose name matches case <U>sensitive</U>
+ * the given name - {@code null} if no match found
+ */
+ public static <R extends NamedResource> R findByName(String name, Collection<? extends R> resources) {
+ return findByName(name, GenericUtils.CASE_SENSITIVE_ORDER, resources);
+ }
+
+ /**
+ * @param name Name of the resource - ignored if {@code null}/empty
* @param c The {@link Comparator} to decide whether the {@link NamedResource#getName()}
* matches the <tt>name</tt> parameter
* @param resources The {@link NamedResource} to check - ignored if {@code null}/empty
- * @return The <U>first</U> resource whose name matches the parameter - {@code null}
- * if no match found
+ * @return The <U>first</U> resource whose name matches the parameter (by invoking
+ * {@link Comparator#compare(Object, Object)} - {@code null} if no match found
*/
public static <R extends NamedResource> R findByName(String name, Comparator<? super String> c, Collection<? extends R> resources) {
if (GenericUtils.isEmpty(name) || GenericUtils.isEmpty(resources)) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java
index 340f827..b6fd3df 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java
@@ -22,7 +22,6 @@ import java.io.IOException;
import java.util.Collection;
import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.GenericUtils;
public interface ServiceFactory extends NamedResource {
Service create(Session session) throws IOException;
@@ -31,27 +30,22 @@ public interface ServiceFactory extends NamedResource {
* Utility class to help using NamedFactories
*/
public static class Utils {
-
/**
* Create an instance of the specified name by looking up the needed factory
- * in the list.
- *
+ * in the list (case <U>insensitive</U>.
* @param factories list of available factories
* @param name the factory name to use
* @return a newly created object or <code>null</code> if the factory is not in the list
+ * @throws IOException if session creation failed
+ * @see ServiceFactory#create(Session)
*/
public static Service create(Collection<? extends ServiceFactory> factories, String name, Session session) throws IOException {
- if (GenericUtils.isEmpty(factories)) {
+ ServiceFactory factory = NamedResource.Utils.findByName(name, String.CASE_INSENSITIVE_ORDER, factories);
+ if (factory == null) {
return null;
+ } else {
+ return factory.create(session);
}
-
- for (ServiceFactory f : factories) {
- if (f.getName().equals(name)) {
- return f.create(session);
- }
- }
-
- return null;
}
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelFactory.java
new file mode 100644
index 0000000..bbfd1ad
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelFactory.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.channel;
+
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface ChannelFactory extends NamedFactory<Channel> {
+ // required because of generics issues
+ Transformer<ChannelFactory,NamedFactory<Channel>> FAC2NAMED=new Transformer<ChannelFactory,NamedFactory<Channel>>() {
+ @Override
+ public NamedFactory<Channel> transform(ChannelFactory input) {
+ return input;
+ }
+ };
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelRequestHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelRequestHandler.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelRequestHandler.java
new file mode 100644
index 0000000..1871068
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelRequestHandler.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.channel;
+
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface ChannelRequestHandler extends RequestHandler<Channel> {
+ // required because of generics issues
+ Transformer<ChannelRequestHandler,RequestHandler<Channel>> CHANN2HNDLR =
+ new Transformer<ChannelRequestHandler, RequestHandler<Channel>>() {
+ @Override
+ public RequestHandler<Channel> transform(ChannelRequestHandler input) {
+ return input;
+ }
+ };
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/cipher/Cipher.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/cipher/Cipher.java b/sshd-core/src/main/java/org/apache/sshd/common/cipher/Cipher.java
index e50ce14..b614fa3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/cipher/Cipher.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/cipher/Cipher.java
@@ -31,44 +31,39 @@ public interface Cipher {
}
/**
- * Retrieves the size of the initialization vector
- *
- * @return
+ * @return Size of the initialization vector (in bytes)
*/
int getIVSize();
/**
- * Retrieves the block size for this cipher
- *
- * @return
+ * @return The block size (in bytes) for this cipher
*/
int getBlockSize();
/**
* Initialize the cipher for encryption or decryption with
- * the given private key and initialization vector
- *
- * @param mode
- * @param key
- * @param iv
- * @throws Exception
+ * the given key and initialization vector
+ * @param mode Encrypt/Decrypt initialization
+ * @param key Key bytes
+ * @param iv Initialization vector bytes
+ * @throws Exception If failed to initialize
*/
void init(Mode mode, byte[] key, byte[] iv) throws Exception;
/**
* Performs in-place encryption or decryption on the given data.
* @param input The input/output bytes
- * @throws Exception
+ * @throws Exception If failed to execute
+ * @see #update(byte[], int, int)
*/
- void update(byte[] input) throws Exception;
+ void update(byte[] input) throws Exception; // TODO make this a default method in JDK-8
/**
* Performs in-place encryption or decryption on the given data.
- *
- * @param input
- * @param inputOffset
- * @param inputLen
- * @throws Exception
+ * @param input The input/output bytes
+ * @param inputOffset The offset of the data in the data buffer
+ * @param inputLen The number of bytes to update - starting at the given offset
+ * @throws Exception If failed to execute
*/
void update(byte[] input, int inputOffset, int inputLen) throws Exception;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java b/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
index 679aa95..bce8b3a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
@@ -32,7 +32,7 @@ import org.apache.sshd.common.util.GenericUtils;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public enum BuiltinDigests implements DigestInformation, NamedFactory<Digest> {
+public enum BuiltinDigests implements DigestInformation, DigestFactory {
md5(Constants.MD5, "MD5", 16),
sha1(Constants.SHA1, "SHA-1", 20),
sha256(Constants.SHA256, "SHA-256", 32),
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestFactory.java
new file mode 100644
index 0000000..0dd7d85
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestFactory.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.digest;
+
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface DigestFactory extends NamedFactory<Digest> {
+ // required because of generics issues
+ Transformer<DigestFactory,NamedFactory<Digest>> FAC2NAMED=new Transformer<DigestFactory,NamedFactory<Digest>>() {
+ @Override
+ public NamedFactory<Digest> transform(DigestFactory input) {
+ return input;
+ }
+ };
+
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
index 184c029..890297a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
@@ -37,6 +37,7 @@ import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.future.SshFutureListener;
import org.apache.sshd.common.io.IoAcceptor;
import org.apache.sshd.common.io.IoHandler;
+import org.apache.sshd.common.io.IoHandlerFactory;
import org.apache.sshd.common.io.IoServiceFactory;
import org.apache.sshd.common.io.IoSession;
import org.apache.sshd.common.session.ConnectionService;
@@ -57,7 +58,7 @@ import org.apache.sshd.server.forward.ForwardingFilter;
public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable implements TcpipForwarder {
private final ConnectionService service;
- private final Factory<IoHandler> socksProxyIoHandlerFactory = new Factory<IoHandler>() {
+ private final IoHandlerFactory socksProxyIoHandlerFactory = new IoHandlerFactory() {
@Override
public IoHandler create() {
return new SocksProxy(getConnectionService());
@@ -68,7 +69,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
private final Map<Integer, SshdSocketAddress> remoteToLocal = new HashMap<Integer, SshdSocketAddress>();
private final Map<Integer, SocksProxy> dynamicLocal = new HashMap<Integer, SocksProxy>();
private final Set<LocalForwardingEntry> localForwards = new HashSet<LocalForwardingEntry>();
- private final Factory<IoHandler> staticIoHandlerFactory = new Factory<IoHandler>() {
+ private final IoHandlerFactory staticIoHandlerFactory = new IoHandlerFactory() {
@Override
public IoHandler create() {
return new StaticIoHandler();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandlerFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandlerFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandlerFactory.java
new file mode 100644
index 0000000..168df15
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandlerFactory.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.io;
+
+import org.apache.sshd.common.Factory;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface IoHandlerFactory extends Factory<IoHandler> {
+ // may be required due to generics reasons
+ Transformer<IoHandlerFactory,Factory<IoHandler>> FAC2FAC =
+ new Transformer<IoHandlerFactory, Factory<IoHandler>>() {
+ @Override
+ public Factory<IoHandler> transform(IoHandlerFactory input) {
+ return input;
+ }
+ };
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/kex/KeyExchangeFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/kex/KeyExchangeFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/kex/KeyExchangeFactory.java
new file mode 100644
index 0000000..460ec60
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/kex/KeyExchangeFactory.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.kex;
+
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface KeyExchangeFactory extends NamedFactory<KeyExchange> {
+ // required because of generics issues
+ Transformer<KeyExchangeFactory,NamedFactory<KeyExchange>> FAC2NAMED=new Transformer<KeyExchangeFactory,NamedFactory<KeyExchange>>() {
+ @Override
+ public NamedFactory<KeyExchange> transform(KeyExchangeFactory input) {
+ return input;
+ }
+ };
+
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/session/ConnectionServiceRequestHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/ConnectionServiceRequestHandler.java b/sshd-core/src/main/java/org/apache/sshd/common/session/ConnectionServiceRequestHandler.java
new file mode 100644
index 0000000..fb09479
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/ConnectionServiceRequestHandler.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.session;
+
+import org.apache.sshd.common.channel.RequestHandler;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface ConnectionServiceRequestHandler extends RequestHandler<ConnectionService> {
+ // required because of generics issues
+ Transformer<ConnectionServiceRequestHandler,RequestHandler<ConnectionService>> SVC2HNDLR =
+ new Transformer<ConnectionServiceRequestHandler, RequestHandler<ConnectionService>>() {
+ @Override
+ public RequestHandler<ConnectionService> transform(ConnectionServiceRequestHandler input) {
+ return input;
+ }
+ };
+
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java b/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
index 2ca27d0..fd3cefb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
@@ -36,9 +36,23 @@ import java.util.TreeSet;
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public final class GenericUtils {
- public static final byte[] EMPTY_BYTE_ARRAY={ };
- public static final String[] EMPTY_STRING_ARRAY={ };
- public static final Object[] EMPTY_OBJECT_ARRAY={ };
+ public static final byte[] EMPTY_BYTE_ARRAY = { };
+ public static final String[] EMPTY_STRING_ARRAY = { };
+ public static final Object[] EMPTY_OBJECT_ARRAY = { };
+
+ /**
+ * The complement of {@link String#CASE_INSENSITIVE_ORDER}
+ */
+ public static final Comparator<String> CASE_SENSITIVE_ORDER = new Comparator<String>() {
+ @Override
+ public int compare(String s1, String s2) {
+ if (s1 == s2) {
+ return 0;
+ } else {
+ return s1.compareTo(s2);
+ }
+ }
+ };
private GenericUtils() {
throw new UnsupportedOperationException("No instance");
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java b/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java
index d8ea7b0..1bc8d1b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java
@@ -24,9 +24,12 @@ import java.util.List;
import org.apache.sshd.common.BaseBuilder;
import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.channel.Channel;
+import org.apache.sshd.common.channel.RequestHandler;
import org.apache.sshd.common.kex.BuiltinDHFactories;
import org.apache.sshd.common.kex.DHFactory;
import org.apache.sshd.common.kex.KeyExchange;
+import org.apache.sshd.common.session.ConnectionService;
import org.apache.sshd.common.util.Transformer;
import org.apache.sshd.server.channel.ChannelSession;
import org.apache.sshd.server.config.keys.DefaultAuthorizedKeysAuthenticator;
@@ -74,16 +77,16 @@ public class ServerBuilder extends BaseBuilder<SshServer, ServerBuilder> {
keyExchangeFactories = setUpDefaultKeyExchanges(false);
}
if (channelFactories == null) {
- channelFactories = Arrays.asList(
+ channelFactories = Arrays.<NamedFactory<Channel>>asList(
ChannelSession.ChannelSessionFactory.INSTANCE,
TcpipServerChannel.DirectTcpipFactory.INSTANCE);
}
if (globalRequestHandlers == null) {
- globalRequestHandlers = Arrays.asList(
- new KeepAliveHandler(),
- new NoMoreSessionsHandler(),
- new TcpipForwardHandler(),
- new CancelTcpipForwardHandler());
+ globalRequestHandlers = Arrays.<RequestHandler<ConnectionService>>asList(
+ KeepAliveHandler.INSTANCE,
+ NoMoreSessionsHandler.INSTANCE,
+ TcpipForwardHandler.INSTANCE,
+ CancelTcpipForwardHandler.INSTANCE);
}
if (factory == null) {
factory = SshServer.DEFAULT_SSH_SERVER_FACTORY;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java b/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java
index a86dce8..eef39e2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java
@@ -23,6 +23,7 @@ import java.util.List;
import org.apache.sshd.common.Factory;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.server.auth.UserAuth;
import org.apache.sshd.server.auth.gss.GSSAuthenticator;
/**
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
index 3cd5b04..340770d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
@@ -44,6 +44,7 @@ import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.OsUtils;
import org.apache.sshd.common.util.SecurityUtils;
import org.apache.sshd.common.util.ValidateUtils;
+import org.apache.sshd.server.auth.UserAuth;
import org.apache.sshd.server.auth.UserAuthKeyboardInteractive;
import org.apache.sshd.server.auth.UserAuthPassword;
import org.apache.sshd.server.auth.UserAuthPublicKey;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/UserAuth.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/UserAuth.java b/sshd-core/src/main/java/org/apache/sshd/server/UserAuth.java
deleted file mode 100644
index bb80288..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/server/UserAuth.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd.server;
-
-import org.apache.sshd.common.util.buffer.Buffer;
-import org.apache.sshd.server.session.ServerSession;
-
-/**
- * Server side authentication mechanism.
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public interface UserAuth {
-
- /**
- * Try to authenticate the user.
- * This methods should return a non null object which is the user identity if
- * the authentication succeeded. If the authentication failed, this method should
- * throw an exception. If the authentication is still ongoing, a null value should
- * be returned.
- *
- * @param session the current ssh session
- * @param username the user trying to log in
- * @param buffer the request buffer containing parameters specific to this request
- * @return <code>true</code> if the authentication succeeded, <code>false</code> if the authentication
- * failed and <code>null</code> if not finished yet
- * @throws Exception if the authentication fails
- */
- Boolean auth(ServerSession session, String username, String service, Buffer buffer) throws Exception;
-
- /**
- * Handle another step in the authentication process.
- *
- * @param buffer the request buffer containing parameters specific to this request
- * @return <code>true</code> if the authentication succeeded, <code>false</code> if the authentication
- * failed and <code>null</code> if not finished yet
- * @throws Exception if the authentication fails
- */
- Boolean next(Buffer buffer) throws Exception;
-
- /**
- * Get a user name which has been derived from the handshaking process, or the initial name if
- * nothing has been found.
- *
- * @return The user name
- * @throws Exception if the request fails
- */
- String getUserName() throws Exception;
-
- /**
- * Free any system resources used by the module.
- */
- void destroy();
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/AbstractUserAuth.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/AbstractUserAuth.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/AbstractUserAuth.java
index c766310..83569d6 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/AbstractUserAuth.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/AbstractUserAuth.java
@@ -20,7 +20,6 @@ package org.apache.sshd.server.auth;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.logging.AbstractLoggingBean;
-import org.apache.sshd.server.UserAuth;
import org.apache.sshd.server.session.ServerSession;
/**
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuth.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuth.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuth.java
new file mode 100644
index 0000000..1eeec16
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuth.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.server.auth;
+
+import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.server.session.ServerSession;
+
+/**
+ * Server side authentication mechanism.
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface UserAuth {
+
+ /**
+ * Try to authenticate the user.
+ * This methods should return a non null object which is the user identity if
+ * the authentication succeeded. If the authentication failed, this method should
+ * throw an exception. If the authentication is still ongoing, a null value should
+ * be returned.
+ *
+ * @param session the current ssh session
+ * @param username the user trying to log in
+ * @param buffer the request buffer containing parameters specific to this request
+ * @return <code>true</code> if the authentication succeeded, <code>false</code> if the authentication
+ * failed and <code>null</code> if not finished yet
+ * @throws Exception if the authentication fails
+ */
+ Boolean auth(ServerSession session, String username, String service, Buffer buffer) throws Exception;
+
+ /**
+ * Handle another step in the authentication process.
+ *
+ * @param buffer the request buffer containing parameters specific to this request
+ * @return <code>true</code> if the authentication succeeded, <code>false</code> if the authentication
+ * failed and <code>null</code> if not finished yet
+ * @throws Exception if the authentication fails
+ */
+ Boolean next(Buffer buffer) throws Exception;
+
+ /**
+ * Get a user name which has been derived from the handshaking process, or the initial name if
+ * nothing has been found.
+ *
+ * @return The user name
+ * @throws Exception if the request fails
+ */
+ String getUserName() throws Exception;
+
+ /**
+ * Free any system resources used by the module.
+ */
+ void destroy();
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthFactory.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthFactory.java
new file mode 100644
index 0000000..642c107
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthFactory.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.server.auth;
+
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface UserAuthFactory extends NamedFactory<UserAuth> {
+ // required because of generics issues
+ Transformer<UserAuthFactory,NamedFactory<UserAuth>> FAC2NAMED=new Transformer<UserAuthFactory,NamedFactory<UserAuth>>() {
+ @Override
+ public NamedFactory<UserAuth> transform(UserAuthFactory input) {
+ return input;
+ }
+ };
+
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java
index 867dda0..9740771 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java
@@ -19,7 +19,6 @@
package org.apache.sshd.server.auth;
import org.apache.sshd.common.FactoryManagerUtils;
-import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.SshException;
import org.apache.sshd.common.util.GenericUtils;
@@ -27,7 +26,6 @@ import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.server.PasswordAuthenticator;
import org.apache.sshd.server.ServerFactoryManager;
-import org.apache.sshd.server.UserAuth;
import org.apache.sshd.server.session.ServerSession;
/**
@@ -35,7 +33,7 @@ import org.apache.sshd.server.session.ServerSession;
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class UserAuthKeyboardInteractive extends AbstractUserAuth {
- public static class UserAuthKeyboardInteractiveFactory implements NamedFactory<UserAuth> {
+ public static class UserAuthKeyboardInteractiveFactory implements UserAuthFactory {
public static final UserAuthKeyboardInteractiveFactory INSTANCE = new UserAuthKeyboardInteractiveFactory();
public UserAuthKeyboardInteractiveFactory() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthNone.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthNone.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthNone.java
index f25fd52..254f5fd 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthNone.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthNone.java
@@ -18,9 +18,7 @@
*/
package org.apache.sshd.server.auth;
-import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.util.buffer.Buffer;
-import org.apache.sshd.server.UserAuth;
/**
* TODO Add javadoc
@@ -29,7 +27,7 @@ import org.apache.sshd.server.UserAuth;
*/
public class UserAuthNone extends AbstractUserAuth {
- public static class UserAuthNoneFactory implements NamedFactory<UserAuth> {
+ public static class UserAuthNoneFactory implements UserAuthFactory {
public static final UserAuthNoneFactory INSTANCE = new UserAuthNoneFactory();
public UserAuthNoneFactory() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPassword.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPassword.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPassword.java
index 9168b99..d0fa54e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPassword.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPassword.java
@@ -18,13 +18,11 @@
*/
package org.apache.sshd.server.auth;
-import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.server.PasswordAuthenticator;
import org.apache.sshd.server.ServerFactoryManager;
-import org.apache.sshd.server.UserAuth;
import org.apache.sshd.server.session.ServerSession;
/**
@@ -34,7 +32,7 @@ import org.apache.sshd.server.session.ServerSession;
*/
public class UserAuthPassword extends AbstractUserAuth {
- public static class UserAuthPasswordFactory implements NamedFactory<UserAuth> {
+ public static class UserAuthPasswordFactory implements UserAuthFactory {
public static final UserAuthPasswordFactory INSTANCE = new UserAuthPasswordFactory();
public UserAuthPasswordFactory() {