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 15:34:18 UTC
[2/3] mina-sshd git commit: [SSHD-510] Expose default singleton
factories used to configure client/server
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/auth/password/AcceptAllPasswordAuthenticator.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/password/AcceptAllPasswordAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/password/AcceptAllPasswordAuthenticator.java
new file mode 100644
index 0000000..14f1073
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/password/AcceptAllPasswordAuthenticator.java
@@ -0,0 +1,30 @@
+/*
+ * 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.password;
+
+/**
+ * Accepts all authentication attempts
+ */
+public final class AcceptAllPasswordAuthenticator extends StaticPasswordAuthenticator {
+ public static final AcceptAllPasswordAuthenticator INSTANCE = new AcceptAllPasswordAuthenticator();
+
+ private AcceptAllPasswordAuthenticator() {
+ super(true);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/auth/password/PasswordAuthenticator.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/password/PasswordAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/password/PasswordAuthenticator.java
new file mode 100644
index 0000000..8139bef
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/password/PasswordAuthenticator.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.server.auth.password;
+
+import org.apache.sshd.server.session.ServerSession;
+
+/**
+ * Used to authenticate users based on a password.
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface PasswordAuthenticator {
+ /**
+ * Check the validity of a password.
+ * @param username The username credential
+ * @param password The provided password
+ * @param session The {@link ServerSession} attemtpting the authentication
+ * @return {@code true} indicating if authentication succeeded
+ */
+ boolean authenticate(String username, String password, ServerSession session);
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/auth/password/RejectAllPasswordAuthenticator.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/password/RejectAllPasswordAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/password/RejectAllPasswordAuthenticator.java
new file mode 100644
index 0000000..5d55463
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/password/RejectAllPasswordAuthenticator.java
@@ -0,0 +1,30 @@
+/*
+ * 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.password;
+
+/**
+ * Rejects all authentication attempts
+ */
+public final class RejectAllPasswordAuthenticator extends StaticPasswordAuthenticator {
+ public static final RejectAllPasswordAuthenticator INSTANCE = new RejectAllPasswordAuthenticator();
+
+ private RejectAllPasswordAuthenticator() {
+ super(false);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/auth/password/StaticPasswordAuthenticator.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/password/StaticPasswordAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/password/StaticPasswordAuthenticator.java
new file mode 100644
index 0000000..3d94108
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/password/StaticPasswordAuthenticator.java
@@ -0,0 +1,47 @@
+/*
+ * 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.password;
+
+import org.apache.sshd.common.util.logging.AbstractLoggingBean;
+import org.apache.sshd.server.session.ServerSession;
+
+/**
+ * Returns the same constant result {@code true/false} regardless
+ */
+public class StaticPasswordAuthenticator extends AbstractLoggingBean implements PasswordAuthenticator {
+ private final boolean acceptance;
+
+ public StaticPasswordAuthenticator(boolean acceptance) {
+ this.acceptance = acceptance;
+ }
+
+ public final boolean isAccepted() {
+ return acceptance;
+ }
+
+ @Override
+ public final boolean authenticate(String username, String password, ServerSession session) {
+ boolean accepted = isAccepted();
+ if (log.isDebugEnabled()) {
+ log.debug("authenticate({}[{}]: {}", username, session, Boolean.valueOf(accepted));
+ }
+
+ return accepted;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/AcceptAllPublickeyAuthenticator.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/AcceptAllPublickeyAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/AcceptAllPublickeyAuthenticator.java
new file mode 100644
index 0000000..3d764fd
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/AcceptAllPublickeyAuthenticator.java
@@ -0,0 +1,30 @@
+/*
+ * 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.pubkey;
+
+/**
+ * Accepts all authentication attempts
+ */
+public final class AcceptAllPublickeyAuthenticator extends StaticPublickeyAuthenticator {
+ public static final AcceptAllPublickeyAuthenticator INSTANCE = new AcceptAllPublickeyAuthenticator();
+
+ private AcceptAllPublickeyAuthenticator() {
+ super(true);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/KeySetPublickeyAuthenticator.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/KeySetPublickeyAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/KeySetPublickeyAuthenticator.java
new file mode 100644
index 0000000..d818978
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/KeySetPublickeyAuthenticator.java
@@ -0,0 +1,65 @@
+/*
+ * 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.pubkey;
+
+import java.security.PublicKey;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.apache.sshd.common.config.keys.KeyUtils;
+import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.logging.AbstractLoggingBean;
+import org.apache.sshd.server.session.ServerSession;
+
+/**
+ * Checks against a {@link Collection} of {@link PublicKey}s
+ */
+public class KeySetPublickeyAuthenticator extends AbstractLoggingBean implements PublickeyAuthenticator {
+ private final Collection<? extends PublicKey> keySet;
+
+ public KeySetPublickeyAuthenticator(Collection<? extends PublicKey> keySet) {
+ this.keySet = (keySet == null) ? Collections.<PublicKey>emptyList() : keySet;
+ }
+
+ public final Collection<? extends PublicKey> getKeySet() {
+ return keySet;
+ }
+
+ @Override
+ public boolean authenticate(String username, PublicKey key, ServerSession session) {
+ return authenticate(username, key, session, getKeySet());
+ }
+
+ public boolean authenticate(String username, PublicKey key, ServerSession session, Collection<? extends PublicKey> keys) {
+ if (GenericUtils.isEmpty(keys)) {
+ if (log.isDebugEnabled()) {
+ log.debug("authenticate(" + username + ")[" + session + "] no keys");
+ }
+
+ return false;
+ }
+
+ PublicKey matchKey = KeyUtils.findMatchingKey(key, keys);
+ boolean matchFound = (matchKey != null);
+ if (log.isDebugEnabled()) {
+ log.debug("authenticate(" + username + ")[" + session + "] match found=" + matchFound);
+ }
+ return matchFound;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/PublickeyAuthenticator.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/PublickeyAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/PublickeyAuthenticator.java
new file mode 100644
index 0000000..739f1a8
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/PublickeyAuthenticator.java
@@ -0,0 +1,41 @@
+/*
+ * 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.pubkey;
+
+import java.security.PublicKey;
+
+import org.apache.sshd.server.session.ServerSession;
+
+/**
+ * The <code>PublickeyAuthenticator</code> is used on the server side
+ * to authenticate user public keys.
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface PublickeyAuthenticator {
+
+ /**
+ * Check the validity of a public key.
+ * @param username the username
+ * @param key the key
+ * @param session the server session
+ * @return a boolean indicating if authentication succeeded or not
+ */
+ boolean authenticate(String username, PublicKey key, ServerSession session);
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/RejectAllPublickeyAuthenticator.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/RejectAllPublickeyAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/RejectAllPublickeyAuthenticator.java
new file mode 100644
index 0000000..84559ae
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/RejectAllPublickeyAuthenticator.java
@@ -0,0 +1,30 @@
+/*
+ * 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.pubkey;
+
+/**
+ * Rejects all authentication attempts
+ */
+public final class RejectAllPublickeyAuthenticator extends StaticPublickeyAuthenticator {
+ public static final RejectAllPublickeyAuthenticator INSTANCE = new RejectAllPublickeyAuthenticator();
+
+ private RejectAllPublickeyAuthenticator() {
+ super(false);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/StaticPublickeyAuthenticator.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/StaticPublickeyAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/StaticPublickeyAuthenticator.java
new file mode 100644
index 0000000..041bdea
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/StaticPublickeyAuthenticator.java
@@ -0,0 +1,51 @@
+/*
+ * 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.pubkey;
+
+import java.security.PublicKey;
+
+import org.apache.sshd.common.config.keys.KeyUtils;
+import org.apache.sshd.common.util.logging.AbstractLoggingBean;
+import org.apache.sshd.server.session.ServerSession;
+
+/**
+ * Returns the same constant result {@code true/false} regardless
+ */
+public abstract class StaticPublickeyAuthenticator extends AbstractLoggingBean implements PublickeyAuthenticator {
+ private final boolean acceptance;
+
+ protected StaticPublickeyAuthenticator(boolean acceptance) {
+ this.acceptance = acceptance;
+ }
+
+ public final boolean isAccepted() {
+ return acceptance;
+ }
+
+ @Override
+ public final boolean authenticate(String username, PublicKey key, ServerSession session) {
+ boolean accepted = isAccepted();
+ if (log.isDebugEnabled()) {
+ log.debug("authenticate({}[{}][{}][{}]: {}",
+ username, session, key.getAlgorithm(), KeyUtils.getFingerPrint(key), Boolean.valueOf(accepted));
+ }
+
+ return accepted;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
index e106c84..04de401 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
@@ -41,7 +41,6 @@ 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.ChannelAsyncOutputStream;
-import org.apache.sshd.common.channel.ChannelFactory;
import org.apache.sshd.common.channel.ChannelOutputStream;
import org.apache.sshd.common.channel.ChannelRequestHandler;
import org.apache.sshd.common.channel.PtyMode;
@@ -80,24 +79,6 @@ public class ChannelSession extends AbstractServerChannel {
public static final long DEFAULT_COMMAND_EXIT_TIMEOUT = 5000;
- public static class ChannelSessionFactory implements ChannelFactory {
- public static final ChannelSessionFactory INSTANCE = new ChannelSessionFactory();
-
- public ChannelSessionFactory() {
- super();
- }
-
- @Override
- public String getName() {
- return "session";
- }
-
- @Override
- public Channel create() {
- return new ChannelSession();
- }
- }
-
protected static class StandardEnvironment implements Environment {
private final Map<Signal, Set<SignalListener>> listeners;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSessionFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSessionFactory.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSessionFactory.java
new file mode 100644
index 0000000..c1edd49
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSessionFactory.java
@@ -0,0 +1,43 @@
+/*
+ * 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.channel;
+
+import org.apache.sshd.common.channel.Channel;
+import org.apache.sshd.common.channel.ChannelFactory;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class ChannelSessionFactory implements ChannelFactory {
+ public static final ChannelSessionFactory INSTANCE = new ChannelSessionFactory();
+
+ public ChannelSessionFactory() {
+ super();
+ }
+
+ @Override
+ public String getName() {
+ return "session";
+ }
+
+ @Override
+ public Channel create() {
+ return new ChannelSession();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/config/keys/AuthorizedKeyEntry.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/config/keys/AuthorizedKeyEntry.java b/sshd-core/src/main/java/org/apache/sshd/server/config/keys/AuthorizedKeyEntry.java
index 54b5a45..b5359f4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/config/keys/AuthorizedKeyEntry.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/config/keys/AuthorizedKeyEntry.java
@@ -48,7 +48,9 @@ import org.apache.sshd.common.config.keys.PublicKeyEntryDecoder;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.io.NoCloseInputStream;
import org.apache.sshd.common.util.io.NoCloseReader;
-import org.apache.sshd.server.PublickeyAuthenticator;
+import org.apache.sshd.server.auth.pubkey.KeySetPublickeyAuthenticator;
+import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
+import org.apache.sshd.server.auth.pubkey.RejectAllPublickeyAuthenticator;
/**
* Represents an entry in the user's {@code authorized_keys} file according
@@ -133,9 +135,9 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
public static final PublickeyAuthenticator fromAuthorizedEntries(Collection<? extends AuthorizedKeyEntry> entries) throws IOException, GeneralSecurityException {
Collection<PublicKey> keys = resolveAuthorizedKeys(entries);
if (GenericUtils.isEmpty(keys)) {
- return PublickeyAuthenticator.RejectAllPublickeyAuthenticator.INSTANCE;
+ return RejectAllPublickeyAuthenticator.INSTANCE;
} else {
- return new PublickeyAuthenticator.KeySetPublickeyAuthenticator(keys);
+ return new KeySetPublickeyAuthenticator(keys);
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/config/keys/AuthorizedKeysAuthenticator.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/config/keys/AuthorizedKeysAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/config/keys/AuthorizedKeysAuthenticator.java
index 6125a63..e4781ce 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/config/keys/AuthorizedKeysAuthenticator.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/config/keys/AuthorizedKeysAuthenticator.java
@@ -32,7 +32,8 @@ import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.io.IoUtils;
import org.apache.sshd.common.util.io.ModifiableFileWatcher;
-import org.apache.sshd.server.PublickeyAuthenticator;
+import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
+import org.apache.sshd.server.auth.pubkey.RejectAllPublickeyAuthenticator;
import org.apache.sshd.server.session.ServerSession;
/**
@@ -45,7 +46,7 @@ import org.apache.sshd.server.session.ServerSession;
*/
public class AuthorizedKeysAuthenticator extends ModifiableFileWatcher implements PublickeyAuthenticator {
private final AtomicReference<PublickeyAuthenticator> delegateHolder = // assumes initially reject-all
- new AtomicReference<PublickeyAuthenticator>(PublickeyAuthenticator.RejectAllPublickeyAuthenticator.INSTANCE);
+ new AtomicReference<PublickeyAuthenticator>(RejectAllPublickeyAuthenticator.INSTANCE);
public AuthorizedKeysAuthenticator(File file) {
this(ValidateUtils.checkNotNull(file, "No file to watch", GenericUtils.EMPTY_OBJECT_ARRAY).toPath());
@@ -102,7 +103,7 @@ public class AuthorizedKeysAuthenticator extends ModifiableFileWatcher implement
/* Start fresh - NOTE: if there is any error then we want to reject all attempts
* since we don't want to remain with the previous data - safer that way
*/
- delegateHolder.set(PublickeyAuthenticator.RejectAllPublickeyAuthenticator.INSTANCE);
+ delegateHolder.set(RejectAllPublickeyAuthenticator.INSTANCE);
Path path = getPath();
if (exists()) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/forward/AcceptAllForwardingFilter.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/AcceptAllForwardingFilter.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/AcceptAllForwardingFilter.java
new file mode 100644
index 0000000..ffb57dd
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/AcceptAllForwardingFilter.java
@@ -0,0 +1,30 @@
+/*
+ * 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.forward;
+
+/**
+ * A {@link ForwardingFilter} that accepts all requests
+ */
+public class AcceptAllForwardingFilter extends StaticDecisionForwardingFilter {
+ public static final AcceptAllForwardingFilter INSTANCE = new AcceptAllForwardingFilter();
+
+ public AcceptAllForwardingFilter() {
+ super(true);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/forward/DirectTcpipFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/DirectTcpipFactory.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/DirectTcpipFactory.java
new file mode 100644
index 0000000..1d88231
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/DirectTcpipFactory.java
@@ -0,0 +1,32 @@
+/*
+ * 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.forward;
+
+import org.apache.sshd.server.forward.TcpipServerChannel.TcpipFactory;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class DirectTcpipFactory extends TcpipFactory {
+ public static final DirectTcpipFactory INSTANCE = new DirectTcpipFactory();
+
+ public DirectTcpipFactory() {
+ super(ForwardingFilter.Type.Direct);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardedTcpipFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardedTcpipFactory.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardedTcpipFactory.java
new file mode 100644
index 0000000..efc0744
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardedTcpipFactory.java
@@ -0,0 +1,32 @@
+/*
+ * 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.forward;
+
+import org.apache.sshd.server.forward.TcpipServerChannel.TcpipFactory;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class ForwardedTcpipFactory extends TcpipFactory {
+ public static final ForwardedTcpipFactory INSTANCE = new ForwardedTcpipFactory();
+
+ public ForwardedTcpipFactory() {
+ super(ForwardingFilter.Type.Forwarded);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardingFilter.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardingFilter.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardingFilter.java
index 23ada9d..4570bdb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardingFilter.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardingFilter.java
@@ -27,7 +27,6 @@ import org.apache.sshd.common.NamedResource;
import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.common.util.logging.AbstractLoggingBean;
/**
* Determines if a forwarding request will be permitted.
@@ -161,80 +160,4 @@ public interface ForwardingFilter {
* @return true if the socket is permitted; false if it must be denied.
*/
boolean canConnect(Type type, SshdSocketAddress address, Session session);
-
- /**
- * A {@link ForwardingFilter} implementation that returns the same "static"
- * result for <U>all</U> the queries.
- */
- public static class StaticDecisionForwardingFilter extends AbstractLoggingBean implements ForwardingFilter {
- private final boolean acceptance;
-
- /**
- * @param acceptance The acceptance status for <U>all</U> the queries
- */
- public StaticDecisionForwardingFilter(boolean acceptance) {
- this.acceptance = acceptance;
- }
-
- public final boolean isAccepted() {
- return acceptance;
- }
-
- @Override
- public boolean canForwardAgent(Session session) {
- return checkAcceptance("auth-agent-req@openssh.com", session, SshdSocketAddress.LOCALHOST_ADDRESS);
- }
-
- @Override
- public boolean canForwardX11(Session session) {
- return checkAcceptance("x11-req", session, SshdSocketAddress.LOCALHOST_ADDRESS);
- }
-
- @Override
- public boolean canListen(SshdSocketAddress address, Session session) {
- return checkAcceptance("tcpip-forward", session, address);
- }
-
- @Override
- public boolean canConnect(Type type, SshdSocketAddress address, Session session) {
- return checkAcceptance(type.getName(), session, address);
- }
-
- /**
- * @param request The SSH request that ultimately led to this filter being consulted
- * @param session The requesting {@link Session}
- * @param target The request target - may be {@link SshdSocketAddress#LOCALHOST_ADDRESS}
- * if no real target
- * @return The (static) {@link #isAccepted()} flag
- */
- protected boolean checkAcceptance(String request, Session session, SshdSocketAddress target) {
- boolean accepted = isAccepted();
- if (log.isDebugEnabled()) {
- log.debug("checkAcceptance(" + request + ")[" + session + "] acceptance for target=" + target + " is " + accepted);
- }
- return accepted;
- }
- }
-
- /**
- * A {@link ForwardingFilter} that accepts all requests
- */
- public static class AcceptAllForwardingFilter extends StaticDecisionForwardingFilter {
- public static final AcceptAllForwardingFilter INSTANCE = new AcceptAllForwardingFilter();
-
- public AcceptAllForwardingFilter() {
- super(true);
- }
- }
-
- /**
- * A {@link ForwardingFilter} that rejects all requests
- */
- public static class RejectAllForwardingFilter extends StaticDecisionForwardingFilter {
- public static final RejectAllForwardingFilter INSTANCE = new RejectAllForwardingFilter();
-
- public RejectAllForwardingFilter() {
- super(false);
- }
- }
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/forward/RejectAllForwardingFilter.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/RejectAllForwardingFilter.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/RejectAllForwardingFilter.java
new file mode 100644
index 0000000..dbd7d80
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/RejectAllForwardingFilter.java
@@ -0,0 +1,30 @@
+/*
+ * 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.forward;
+
+/**
+ * A {@link ForwardingFilter} that rejects all requests
+ */
+public class RejectAllForwardingFilter extends StaticDecisionForwardingFilter {
+ public static final RejectAllForwardingFilter INSTANCE = new RejectAllForwardingFilter();
+
+ public RejectAllForwardingFilter() {
+ super(false);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/forward/StaticDecisionForwardingFilter.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/StaticDecisionForwardingFilter.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/StaticDecisionForwardingFilter.java
new file mode 100644
index 0000000..67b77ce
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/StaticDecisionForwardingFilter.java
@@ -0,0 +1,77 @@
+/*
+ * 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.forward;
+
+import org.apache.sshd.common.SshdSocketAddress;
+import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.util.logging.AbstractLoggingBean;
+
+/**
+ * A {@link ForwardingFilter} implementation that returns the same "static"
+ * result for <U>all</U> the queries.
+ */
+public class StaticDecisionForwardingFilter extends AbstractLoggingBean implements ForwardingFilter {
+ private final boolean acceptance;
+
+ /**
+ * @param acceptance The acceptance status for <U>all</U> the queries
+ */
+ public StaticDecisionForwardingFilter(boolean acceptance) {
+ this.acceptance = acceptance;
+ }
+
+ public final boolean isAccepted() {
+ return acceptance;
+ }
+
+ @Override
+ public boolean canForwardAgent(Session session) {
+ return checkAcceptance("auth-agent-req@openssh.com", session, SshdSocketAddress.LOCALHOST_ADDRESS);
+ }
+
+ @Override
+ public boolean canForwardX11(Session session) {
+ return checkAcceptance("x11-req", session, SshdSocketAddress.LOCALHOST_ADDRESS);
+ }
+
+ @Override
+ public boolean canListen(SshdSocketAddress address, Session session) {
+ return checkAcceptance("tcpip-forward", session, address);
+ }
+
+ @Override
+ public boolean canConnect(Type type, SshdSocketAddress address, Session session) {
+ return checkAcceptance(type.getName(), session, address);
+ }
+
+ /**
+ * @param request The SSH request that ultimately led to this filter being consulted
+ * @param session The requesting {@link Session}
+ * @param target The request target - may be {@link SshdSocketAddress#LOCALHOST_ADDRESS}
+ * if no real target
+ * @return The (static) {@link #isAccepted()} flag
+ */
+ protected boolean checkAcceptance(String request, Session session, SshdSocketAddress target) {
+ boolean accepted = isAccepted();
+ if (log.isDebugEnabled()) {
+ log.debug("checkAcceptance(" + request + ")[" + session + "] acceptance for target=" + target + " is " + accepted);
+ }
+ return accepted;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
index de8e36b..bca3f0d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
@@ -89,22 +89,6 @@ public class TcpipServerChannel extends AbstractServerChannel {
}
}
- public static class DirectTcpipFactory extends TcpipFactory {
- public static final DirectTcpipFactory INSTANCE = new DirectTcpipFactory();
-
- public DirectTcpipFactory() {
- super(ForwardingFilter.Type.Direct);
- }
- }
-
- public static class ForwardedTcpipFactory extends TcpipFactory {
- public static final ForwardedTcpipFactory INSTANCE = new ForwardedTcpipFactory();
-
- public ForwardedTcpipFactory() {
- super(ForwardingFilter.Type.Forwarded);
- }
- }
-
private final ForwardingFilter.Type type;
private IoConnector connector;
private IoSession ioSession;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/jaas/JaasPasswordAuthenticator.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/jaas/JaasPasswordAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/jaas/JaasPasswordAuthenticator.java
index 266801c..afcee62 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/jaas/JaasPasswordAuthenticator.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/jaas/JaasPasswordAuthenticator.java
@@ -29,7 +29,7 @@ import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.auth.login.LoginContext;
import org.apache.sshd.common.util.logging.AbstractLoggingBean;
-import org.apache.sshd.server.PasswordAuthenticator;
+import org.apache.sshd.server.auth.password.PasswordAuthenticator;
import org.apache.sshd.server.session.ServerSession;
/**
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/session/ServerConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerConnectionService.java
index 8051eca..51587c9 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerConnectionService.java
@@ -20,8 +20,6 @@ package org.apache.sshd.server.session;
import java.io.IOException;
-import org.apache.sshd.common.Service;
-import org.apache.sshd.common.ServiceFactory;
import org.apache.sshd.common.SshException;
import org.apache.sshd.common.session.AbstractConnectionService;
import org.apache.sshd.common.session.Session;
@@ -35,20 +33,6 @@ import org.apache.sshd.common.util.ValidateUtils;
*/
public class ServerConnectionService extends AbstractConnectionService {
- public static class Factory implements ServiceFactory {
-
- @Override
- public String getName() {
- return "ssh-connection";
- }
-
- @Override
- public Service create(Session session) throws IOException {
- return new ServerConnectionService(session);
- }
- }
-
-
protected ServerConnectionService(Session s) throws SshException {
super(s);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/session/ServerConnectionServiceFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerConnectionServiceFactory.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerConnectionServiceFactory.java
new file mode 100644
index 0000000..d7ac3d2
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerConnectionServiceFactory.java
@@ -0,0 +1,46 @@
+/*
+ * 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.session;
+
+import java.io.IOException;
+
+import org.apache.sshd.common.Service;
+import org.apache.sshd.common.ServiceFactory;
+import org.apache.sshd.common.session.Session;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class ServerConnectionServiceFactory implements ServiceFactory {
+ public static final ServerConnectionServiceFactory INSTANCE = new ServerConnectionServiceFactory();
+
+ public ServerConnectionServiceFactory() {
+ super();
+ }
+
+ @Override
+ public String getName() {
+ return "ssh-connection";
+ }
+
+ @Override
+ public Service create(Session session) throws IOException {
+ return new ServerConnectionService(session);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
index 6866e0b..0421c61 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
@@ -18,7 +18,6 @@
*/
package org.apache.sshd.server.session;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -29,7 +28,6 @@ import org.apache.sshd.common.FactoryManagerUtils;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.NamedResource;
import org.apache.sshd.common.Service;
-import org.apache.sshd.common.ServiceFactory;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.SshException;
import org.apache.sshd.common.session.Session;
@@ -45,19 +43,6 @@ import org.apache.sshd.server.auth.UserAuth;
*/
public class ServerUserAuthService extends CloseableUtils.AbstractCloseable implements Service {
- public static class Factory implements ServiceFactory {
-
- @Override
- public String getName() {
- return "ssh-userauth";
- }
-
- @Override
- public Service create(Session session) throws IOException {
- return new ServerUserAuthService(session);
- }
- }
-
public static final int DEFAULT_MAX_AUTH_REQUESTS = 20;
private final ServerSession session;
private List<NamedFactory<UserAuth>> userAuthFactories;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthServiceFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthServiceFactory.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthServiceFactory.java
new file mode 100644
index 0000000..f04532e
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthServiceFactory.java
@@ -0,0 +1,46 @@
+/*
+ * 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.session;
+
+import java.io.IOException;
+
+import org.apache.sshd.common.Service;
+import org.apache.sshd.common.ServiceFactory;
+import org.apache.sshd.common.session.Session;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class ServerUserAuthServiceFactory implements ServiceFactory {
+ public static final ServerUserAuthServiceFactory INSTANCE = new ServerUserAuthServiceFactory();
+
+ public ServerUserAuthServiceFactory() {
+ super();
+ }
+
+ @Override
+ public String getName() {
+ return "ssh-userauth";
+ }
+
+ @Override
+ public Service create(Session session) throws IOException {
+ return new ServerUserAuthService(session);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/shell/InteractiveProcessShellFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/InteractiveProcessShellFactory.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/InteractiveProcessShellFactory.java
new file mode 100644
index 0000000..e46a005
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/InteractiveProcessShellFactory.java
@@ -0,0 +1,64 @@
+/*
+ * 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.shell;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Set;
+
+import org.apache.sshd.common.util.OsUtils;
+
+/**
+ * A simplistic interactive shell factory
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class InteractiveProcessShellFactory extends ProcessShellFactory {
+ // must come first due to class loading issues
+ private static final String[] LINUX_COMMAND = { "/bin/sh", "-i", "-l" };
+ private static final String[] WINDOWS_COMMAND = { "cmd.exe" };
+
+ public static String[] resolveInteractiveCommand(boolean isWin32) {
+ // return clone(s) to avoid inadvertent modification
+ if (isWin32) {
+ return WINDOWS_COMMAND.clone();
+ } else {
+ return LINUX_COMMAND.clone();
+ }
+ }
+
+ public static final Set<TtyOptions> LINUX_OPTIONS =
+ Collections.unmodifiableSet(EnumSet.of(TtyOptions.ONlCr));
+ public static final Set<TtyOptions> WINDOWS_OPTIONS =
+ Collections.unmodifiableSet(EnumSet.of(TtyOptions.Echo, TtyOptions.ICrNl, TtyOptions.ONlCr));
+
+ public static Set<TtyOptions> resolveTtyOptions(boolean isWin32) {
+ if (isWin32) {
+ return WINDOWS_OPTIONS;
+ } else {
+ return LINUX_OPTIONS;
+ }
+ }
+
+ public static final InteractiveProcessShellFactory INSTANCE = new InteractiveProcessShellFactory();
+
+ public InteractiveProcessShellFactory() {
+ super(resolveInteractiveCommand(OsUtils.isWin32()), resolveTtyOptions(OsUtils.isWin32()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShellFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShellFactory.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShellFactory.java
index 9e5161a..033f476 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShellFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShellFactory.java
@@ -23,10 +23,14 @@ import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Collections;
import java.util.EnumSet;
import java.util.Map;
+import java.util.Set;
import org.apache.sshd.common.Factory;
+import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
import org.apache.sshd.common.util.logging.AbstractLoggingBean;
@@ -49,18 +53,19 @@ public class ProcessShellFactory extends AbstractLoggingBean implements Factory<
}
private String[] command;
- private EnumSet<TtyOptions> ttyOptions;
+ private final Set<TtyOptions> ttyOptions;
public ProcessShellFactory() {
+ this(GenericUtils.EMPTY_STRING_ARRAY);
}
public ProcessShellFactory(String[] command) {
this(command, EnumSet.noneOf(TtyOptions.class));
}
- public ProcessShellFactory(String[] command, EnumSet<TtyOptions> ttyOptions) {
+ public ProcessShellFactory(String[] command, Collection<TtyOptions> ttyOptions) {
this.command = command;
- this.ttyOptions = ttyOptions;
+ this.ttyOptions = GenericUtils.isEmpty(ttyOptions) ? Collections.<TtyOptions>emptySet() : GenericUtils.of(ttyOptions);
}
public String[] getCommand() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java b/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
index b861b7c..ffc219c 100644
--- a/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
@@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.future.AuthFuture;
-import org.apache.sshd.client.session.ClientConnectionService;
+import org.apache.sshd.client.session.ClientConnectionServiceFactory;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManagerUtils;
import org.apache.sshd.common.io.IoSession;
@@ -36,9 +36,9 @@ import org.apache.sshd.deprecated.ClientUserAuthServiceOld;
import org.apache.sshd.deprecated.UserAuthKeyboardInteractive;
import org.apache.sshd.deprecated.UserAuthPassword;
import org.apache.sshd.deprecated.UserAuthPublicKey;
-import org.apache.sshd.server.PublickeyAuthenticator.AcceptAllPublickeyAuthenticator;
import org.apache.sshd.server.ServerFactoryManager;
import org.apache.sshd.server.SshServer;
+import org.apache.sshd.server.auth.pubkey.AcceptAllPublickeyAuthenticator;
import org.apache.sshd.server.session.ServerSessionImpl;
import org.apache.sshd.server.session.SessionFactory;
import org.apache.sshd.util.BaseTestSupport;
@@ -104,7 +104,7 @@ public class AuthenticationTest extends BaseTestSupport {
try(SshClient client = SshClient.setUpDefaultClient()) {
client.setServiceFactories(Arrays.asList(
new ClientUserAuthServiceOld.Factory(),
- ClientConnectionService.ClientConnectionServiceFactory.INSTANCE
+ ClientConnectionServiceFactory.INSTANCE
));
client.start();
@@ -129,7 +129,7 @@ public class AuthenticationTest extends BaseTestSupport {
try(SshClient client = SshClient.setUpDefaultClient()) {
client.setServiceFactories(Arrays.asList(
new ClientUserAuthServiceOld.Factory(),
- ClientConnectionService.ClientConnectionServiceFactory.INSTANCE
+ ClientConnectionServiceFactory.INSTANCE
));
client.start();
@@ -150,7 +150,7 @@ public class AuthenticationTest extends BaseTestSupport {
try(SshClient client = SshClient.setUpDefaultClient()) {
client.setServiceFactories(Arrays.asList(
new ClientUserAuthServiceOld.Factory(),
- ClientConnectionService.ClientConnectionServiceFactory.INSTANCE
+ ClientConnectionServiceFactory.INSTANCE
));
client.start();
@@ -172,7 +172,7 @@ public class AuthenticationTest extends BaseTestSupport {
try(SshClient client = SshClient.setUpDefaultClient()) {
client.setServiceFactories(Arrays.asList(
new ClientUserAuthServiceOld.Factory(),
- ClientConnectionService.ClientConnectionServiceFactory.INSTANCE
+ ClientConnectionServiceFactory.INSTANCE
));
client.start();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/test/java/org/apache/sshd/KeepAliveTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/KeepAliveTest.java b/sshd-core/src/test/java/org/apache/sshd/KeepAliveTest.java
index 0e5abc9..5954ec3 100644
--- a/sshd-core/src/test/java/org/apache/sshd/KeepAliveTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/KeepAliveTest.java
@@ -29,8 +29,8 @@ import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.FactoryManagerUtils;
import org.apache.sshd.server.Command;
-import org.apache.sshd.server.PublickeyAuthenticator.AcceptAllPublickeyAuthenticator;
import org.apache.sshd.server.SshServer;
+import org.apache.sshd.server.auth.pubkey.AcceptAllPublickeyAuthenticator;
import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/test/java/org/apache/sshd/PortForwardingLoadTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/PortForwardingLoadTest.java b/sshd-core/src/test/java/org/apache/sshd/PortForwardingLoadTest.java
index e93da02..fd13b65 100644
--- a/sshd-core/src/test/java/org/apache/sshd/PortForwardingLoadTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/PortForwardingLoadTest.java
@@ -47,7 +47,7 @@ import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
import org.apache.sshd.server.SshServer;
-import org.apache.sshd.server.forward.ForwardingFilter;
+import org.apache.sshd.server.forward.AcceptAllForwardingFilter;
import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
@@ -87,7 +87,7 @@ public class PortForwardingLoadTest extends BaseTestSupport {
sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
sshd.setShellFactory(new EchoShellFactory());
sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
- sshd.setTcpipForwardingFilter(ForwardingFilter.AcceptAllForwardingFilter.INSTANCE);
+ sshd.setTcpipForwardingFilter(AcceptAllForwardingFilter.INSTANCE);
sshd.start();
sshPort = sshd.getPort();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java b/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
index 7acd3f9..f054647 100644
--- a/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
@@ -55,7 +55,7 @@ import org.apache.sshd.common.session.ConnectionService;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.server.SshServer;
-import org.apache.sshd.server.forward.ForwardingFilter;
+import org.apache.sshd.server.forward.AcceptAllForwardingFilter;
import org.apache.sshd.server.global.CancelTcpipForwardHandler;
import org.apache.sshd.server.global.TcpipForwardHandler;
import org.apache.sshd.util.BaseTestSupport;
@@ -99,7 +99,7 @@ public class PortForwardingTest extends BaseTestSupport {
sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
sshd.setShellFactory(new EchoShellFactory());
sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
- sshd.setTcpipForwardingFilter(ForwardingFilter.AcceptAllForwardingFilter.INSTANCE);
+ sshd.setTcpipForwardingFilter(AcceptAllForwardingFilter.INSTANCE);
sshd.start();
if (!requestsQ.isEmpty()) {
@@ -603,7 +603,7 @@ public class PortForwardingTest extends BaseTestSupport {
client = SshClient.setUpDefaultClient();
FactoryManagerUtils.updateProperty(client, FactoryManager.WINDOW_SIZE, 2048);
FactoryManagerUtils.updateProperty(client, FactoryManager.MAX_PACKET_SIZE, 256);
- client.setTcpipForwardingFilter(ForwardingFilter.AcceptAllForwardingFilter.INSTANCE);
+ client.setTcpipForwardingFilter(AcceptAllForwardingFilter.INSTANCE);
client.start();
ClientSession session = client.connect(getCurrentTestName(), "localhost", sshPort).verify(7L, TimeUnit.SECONDS).getSession();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java b/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java
index a050b80..4fd4b13 100644
--- a/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java
@@ -37,7 +37,7 @@ import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.FactoryManagerUtils;
import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.server.SshServer;
-import org.apache.sshd.server.forward.ForwardingFilter;
+import org.apache.sshd.server.forward.AcceptAllForwardingFilter;
import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
@@ -67,7 +67,7 @@ public class ProxyTest extends BaseTestSupport {
sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
sshd.setShellFactory(new EchoShellFactory());
sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
- sshd.setTcpipForwardingFilter(ForwardingFilter.AcceptAllForwardingFilter.INSTANCE);
+ sshd.setTcpipForwardingFilter(AcceptAllForwardingFilter.INSTANCE);
sshd.start();
sshPort = sshd.getPort();
@@ -147,7 +147,7 @@ public class ProxyTest extends BaseTestSupport {
client = SshClient.setUpDefaultClient();
FactoryManagerUtils.updateProperty(client, FactoryManager.WINDOW_SIZE, 2048);
FactoryManagerUtils.updateProperty(client, FactoryManager.MAX_PACKET_SIZE, 256);
- client.setTcpipForwardingFilter(ForwardingFilter.AcceptAllForwardingFilter.INSTANCE);
+ client.setTcpipForwardingFilter(AcceptAllForwardingFilter.INSTANCE);
client.start();
ClientSession session = client.connect("sshd", "localhost", sshPort).verify(7L, TimeUnit.SECONDS).getSession();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java b/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java
index 11e97be..8119c74 100644
--- a/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java
@@ -32,11 +32,11 @@ import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.keyprovider.KeyPairProvider;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.CommandFactory;
-import org.apache.sshd.server.PublickeyAuthenticator;
import org.apache.sshd.server.ServerFactoryManager;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.auth.CachingPublicKeyAuthenticator;
-import org.apache.sshd.server.auth.UserAuthPublicKey.UserAuthPublicKeyFactory;
+import org.apache.sshd.server.auth.UserAuthPublicKeyFactory;
+import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
import org.apache.sshd.server.command.UnknownCommand;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.session.ServerSession;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/test/java/org/apache/sshd/SpringConfigTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/SpringConfigTest.java b/sshd-core/src/test/java/org/apache/sshd/SpringConfigTest.java
deleted file mode 100644
index f45f1e1..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/SpringConfigTest.java
+++ /dev/null
@@ -1,88 +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;
-
-import java.io.OutputStream;
-
-import org.apache.sshd.server.SshServer;
-import org.apache.sshd.util.BaseTestSupport;
-import org.apache.sshd.util.JSchLogger;
-import org.apache.sshd.util.SimpleUserInfo;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.JSch;
-
-/**
- * Test for spring based configuration.
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class SpringConfigTest extends BaseTestSupport {
-
- private ClassPathXmlApplicationContext context;
-
- public SpringConfigTest() {
- super();
- }
-
- @Before
- public void setUp() throws Exception {
- context = new ClassPathXmlApplicationContext("classpath:spring.xml");
- }
-
- @After
- public void tearDown() throws Exception {
- if (context != null) {
- context.destroy();
- }
- }
-
- @Test
- public void testSpringConfig() throws Exception {
- int port = ((SshServer) context.getBean("sshServer")).getPort();
-
- JSchLogger.init();
- JSch sch = new JSch();
- com.jcraft.jsch.Session s = sch.getSession(getCurrentTestName(), "localhost", port);
- s.setUserInfo(new SimpleUserInfo(getCurrentTestName()));
- s.connect();
-
- try {
- Channel c = s.openChannel("shell");
- c.connect();
-
- try(OutputStream os = c.getOutputStream()) {
- os.write("this is my command".getBytes());
- os.flush();
- Thread.sleep(100);
- } finally {
- c.disconnect();
- }
- } finally {
- s.disconnect();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java b/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java
index de1192a..8a93b6b 100644
--- a/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java
@@ -25,9 +25,9 @@ import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.auth.UserInteraction;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManagerUtils;
-import org.apache.sshd.server.PublickeyAuthenticator.AcceptAllPublickeyAuthenticator;
import org.apache.sshd.server.ServerFactoryManager;
import org.apache.sshd.server.SshServer;
+import org.apache.sshd.server.auth.pubkey.AcceptAllPublickeyAuthenticator;
import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.Utils;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/test/java/org/apache/sshd/WindowTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/WindowTest.java b/sshd-core/src/test/java/org/apache/sshd/WindowTest.java
index a4233d9..a97c8a0 100644
--- a/sshd-core/src/test/java/org/apache/sshd/WindowTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/WindowTest.java
@@ -47,13 +47,16 @@ import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.CommandFactory;
-import org.apache.sshd.server.PublickeyAuthenticator.AcceptAllPublickeyAuthenticator;
import org.apache.sshd.server.SshServer;
+import org.apache.sshd.server.auth.pubkey.AcceptAllPublickeyAuthenticator;
import org.apache.sshd.server.channel.ChannelSession;
+import org.apache.sshd.server.channel.ChannelSessionFactory;
import org.apache.sshd.server.command.UnknownCommand;
-import org.apache.sshd.server.forward.TcpipServerChannel;
+import org.apache.sshd.server.forward.DirectTcpipFactory;
import org.apache.sshd.server.session.ServerConnectionService;
+import org.apache.sshd.server.session.ServerConnectionServiceFactory;
import org.apache.sshd.server.session.ServerUserAuthService;
+import org.apache.sshd.server.session.ServerUserAuthServiceFactory;
import org.apache.sshd.util.AsyncEchoShellFactory;
import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
@@ -96,23 +99,23 @@ public class WindowTest extends BaseTestSupport {
sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
sshd.setPublickeyAuthenticator(AcceptAllPublickeyAuthenticator.INSTANCE);
sshd.setServiceFactories(Arrays.asList(
- new ServerUserAuthService.Factory() {
- @Override
- public Service create(Session session) throws IOException {
- return new ServerUserAuthService(session) {
- @SuppressWarnings("synthetic-access")
- @Override
- public void process(byte cmd, Buffer buffer) throws Exception {
- authLatch.await();
- super.process(cmd, buffer);
- }
- };
- }
- },
- new ServerConnectionService.Factory()
- ));
+ new ServerUserAuthServiceFactory() {
+ @Override
+ public Service create(Session session) throws IOException {
+ return new ServerUserAuthService(session) {
+ @SuppressWarnings("synthetic-access")
+ @Override
+ public void process(byte cmd, Buffer buffer) throws Exception {
+ authLatch.await();
+ super.process(cmd, buffer);
+ }
+ };
+ }
+ },
+ ServerConnectionServiceFactory.INSTANCE
+ ));
sshd.setChannelFactories(Arrays.<NamedFactory<Channel>>asList(
- new ChannelSession.ChannelSessionFactory() {
+ new ChannelSessionFactory() {
@Override
public Channel create() {
return new ChannelSession() {
@@ -134,7 +137,7 @@ public class WindowTest extends BaseTestSupport {
};
}
},
- TcpipServerChannel.DirectTcpipFactory.INSTANCE));
+ DirectTcpipFactory.INSTANCE));
sshd.start();
port = sshd.getPort();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/82791d41/sshd-core/src/test/java/org/apache/sshd/agent/AgentTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/agent/AgentTest.java b/sshd-core/src/test/java/org/apache/sshd/agent/AgentTest.java
index 74610a7..5bd086b 100644
--- a/sshd-core/src/test/java/org/apache/sshd/agent/AgentTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/agent/AgentTest.java
@@ -40,9 +40,9 @@ import org.apache.sshd.common.util.Pair;
import org.apache.sshd.common.util.SecurityUtils;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.Environment;
-import org.apache.sshd.server.PublickeyAuthenticator.AcceptAllPublickeyAuthenticator;
import org.apache.sshd.server.SshServer;
-import org.apache.sshd.server.forward.ForwardingFilter;
+import org.apache.sshd.server.auth.pubkey.AcceptAllPublickeyAuthenticator;
+import org.apache.sshd.server.forward.AcceptAllForwardingFilter;
import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
@@ -112,7 +112,7 @@ public class AgentTest extends BaseTestSupport {
sshd1.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
sshd1.setPublickeyAuthenticator(AcceptAllPublickeyAuthenticator.INSTANCE);
sshd1.setAgentFactory(agentFactory);
- sshd1.setTcpipForwardingFilter(ForwardingFilter.AcceptAllForwardingFilter.INSTANCE);
+ sshd1.setTcpipForwardingFilter(AcceptAllForwardingFilter.INSTANCE);
sshd1.start();
final int port1 = sshd1.getPort();
@@ -121,7 +121,7 @@ public class AgentTest extends BaseTestSupport {
sshd2.setShellFactory(new TestEchoShellFactory());
sshd2.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
sshd2.setPublickeyAuthenticator(AcceptAllPublickeyAuthenticator.INSTANCE);
- sshd1.setTcpipForwardingFilter(ForwardingFilter.AcceptAllForwardingFilter.INSTANCE);
+ sshd1.setTcpipForwardingFilter(AcceptAllForwardingFilter.INSTANCE);
sshd2.setAgentFactory(new ProxyAgentFactory());
sshd2.start();