You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2010/04/28 20:49:37 UTC

svn commit: r939051 - /mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/SshServer.java

Author: gnodet
Date: Wed Apr 28 18:49:37 2010
New Revision: 939051

URL: http://svn.apache.org/viewvc?rev=939051&view=rev
Log:
SSHD-74: Even if I do setPublicKeyAuthenticator(null) (or setPasswordAuthenticator(null)) Apache SSHD still reports that it supports that kind of authentication

Modified:
    mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/SshServer.java

Modified: mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/SshServer.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/SshServer.java?rev=939051&r1=939050&r2=939051&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/SshServer.java (original)
+++ mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/SshServer.java Wed Apr 28 18:49:37 2010
@@ -249,7 +249,18 @@ public class SshServer extends AbstractF
             throw new IllegalArgumentException("KeyExchangeFactories not set");
         }
         if (getUserAuthFactories() == null) {
-            throw new IllegalArgumentException("UserAuthFactories not set");
+            List<NamedFactory<UserAuth>> factories = new ArrayList<NamedFactory<UserAuth>>();
+            if (getPasswordAuthenticator() != null) {
+                factories.add(new UserAuthPassword.Factory());
+            }
+            if (getPublickeyAuthenticator() != null) {
+                factories.add(new UserAuthPublicKey.Factory());
+            }
+            if (factories.size() > 0) {
+                setUserAuthFactories(factories);
+            } else {
+                throw new IllegalArgumentException("UserAuthFactories not set");
+            }
         }
         if (getCipherFactories() == null) {
             throw new IllegalArgumentException("CipherFactories not set");
@@ -376,9 +387,6 @@ public class SshServer extends AbstractF
                     new DHG1.Factory()));
             sshd.setRandomFactory(new SingletonRandomFactory(new JceRandom.Factory()));
         }
-        sshd.setUserAuthFactories(Arrays.<NamedFactory<UserAuth>>asList(
-                new UserAuthPassword.Factory(),
-                new UserAuthPublicKey.Factory()));
         setUpDefaultCiphers(sshd);
         // Compression is not enabled by default
         // sshd.setCompressionFactories(Arrays.<NamedFactory<Compression>>asList(