Minor improvements to the SshClient/SshServer toString() implementations

Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/ba54b636
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/ba54b636
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/ba54b636

Branch: refs/heads/master
Commit: ba54b636837d142341abab03dfd158cd0d56c593
Parents: 25e4591
Author: Lyor Goldstein <[email protected]>
Authored: Wed Oct 3 21:21:42 2018 +0300
Committer: Goldstein Lyor <[email protected]>
Committed: Thu Oct 4 08:50:08 2018 +0300

----------------------------------------------------------------------
 .../java/org/apache/sshd/client/SshClient.java  | 27 ++++++++++----------
 .../java/org/apache/sshd/server/SshServer.java  | 21 ++++++++++-----
 2 files changed, 28 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ba54b636/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 f4c2d8c..cf160d5 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
@@ -141,16 +141,16 @@ public class SshClient extends AbstractFactoryManager 
implements ClientFactoryMa
      * @see <A HREF="http://linux.die.net/man/5/ssh_config";>ssh_config(5) - 
PreferredAuthentications</A>
      */
     public static final List<NamedFactory<UserAuth>> 
DEFAULT_USER_AUTH_FACTORIES =
-            Collections.unmodifiableList(Arrays.<NamedFactory<UserAuth>>asList(
-                    UserAuthPublicKeyFactory.INSTANCE,
-                    UserAuthKeyboardInteractiveFactory.INSTANCE,
-                    UserAuthPasswordFactory.INSTANCE
-            ));
+        Collections.unmodifiableList(Arrays.<NamedFactory<UserAuth>>asList(
+                UserAuthPublicKeyFactory.INSTANCE,
+                UserAuthKeyboardInteractiveFactory.INSTANCE,
+                UserAuthPasswordFactory.INSTANCE
+        ));
     public static final List<ServiceFactory> DEFAULT_SERVICE_FACTORIES =
-            Collections.unmodifiableList(Arrays.asList(
-                    ClientUserAuthServiceFactory.INSTANCE,
-                    ClientConnectionServiceFactory.INSTANCE
-            ));
+        Collections.unmodifiableList(Arrays.asList(
+                ClientUserAuthServiceFactory.INSTANCE,
+                ClientConnectionServiceFactory.INSTANCE
+        ));
 
     protected IoConnector connector;
     protected SessionFactory sessionFactory;
@@ -702,7 +702,7 @@ public class SshClient extends AbstractFactoryManager 
implements ClientFactoryMa
 
     @Override
     public String toString() {
-        return "SshClient[" + Integer.toHexString(hashCode()) + "]";
+        return getClass().getSimpleName() + "[" + 
Integer.toHexString(hashCode()) + "]";
     }
 
     /**
@@ -767,10 +767,11 @@ public class SshClient extends AbstractFactoryManager 
implements ClientFactoryMa
     /**
      * Setup a default client.  The client does not require any additional 
setup.
      *
-     * @return a newly create SSH client
+     * @return a newly create {@link SshClient} with default configurations
      */
     public static SshClient setUpDefaultClient() {
-        return ClientBuilder.builder().build();
+        ClientBuilder builder = ClientBuilder.builder();
+        return builder.build();
     }
 
     /**
@@ -820,7 +821,7 @@ public class SshClient extends AbstractFactoryManager 
implements ClientFactoryMa
      */
     public static <C extends SshClient> C setKeyPairProvider(
             C client, Path dir, boolean strict, boolean supportedOnly, 
FilePasswordProvider provider, LinkOption... options)
-            throws IOException, GeneralSecurityException {
+                throws IOException, GeneralSecurityException {
         KeyPairProvider kpp =
             ClientIdentity.loadDefaultKeyPairProvider(dir, strict, 
supportedOnly, provider, options);
         if (kpp != null) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ba54b636/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 e2c0c2f..60e5a4d 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
@@ -84,14 +84,13 @@ import org.apache.sshd.server.session.SessionFactory;
  * @see org.apache.sshd.common.FactoryManager
  */
 public class SshServer extends AbstractFactoryManager implements 
ServerFactoryManager, Closeable {
-
     public static final Factory<SshServer> DEFAULT_SSH_SERVER_FACTORY = 
SshServer::new;
 
     public static final List<ServiceFactory> DEFAULT_SERVICE_FACTORIES =
-            Collections.unmodifiableList(Arrays.asList(
-                    ServerUserAuthServiceFactory.INSTANCE,
-                    ServerConnectionServiceFactory.INSTANCE
-            ));
+        Collections.unmodifiableList(Arrays.asList(
+                ServerUserAuthServiceFactory.INSTANCE,
+                ServerConnectionServiceFactory.INSTANCE
+        ));
 
 
     protected IoAcceptor acceptor;
@@ -397,10 +396,18 @@ public class SshServer extends AbstractFactoryManager 
implements ServerFactoryMa
 
     @Override
     public String toString() {
-        return "SshServer[" + Integer.toHexString(hashCode()) + "]";
+        return getClass().getSimpleName()
+            + "[" + Integer.toHexString(hashCode()) + "]"
+            + "(port=" + getPort() + ")";
     }
 
+    /**
+     * Setup a default server
+     *
+     * @return a newly create {@link SshServer} with default configurations
+     */
     public static SshServer setUpDefaultServer() {
-        return ServerBuilder.builder().build();
+        ServerBuilder builder = ServerBuilder.builder();
+        return builder.build();
     }
 }

Reply via email to