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 2013/01/07 17:07:08 UTC

svn commit: r1429867 - in /mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server: ServerFactoryManager.java session/ServerSession.java

Author: gnodet
Date: Mon Jan  7 16:07:07 2013
New Revision: 1429867

URL: http://svn.apache.org/viewvc?rev=1429867&view=rev
Log:
[SSHD-195] Display a Welcome Banner after a user connects

Modified:
    mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java
    mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java

Modified: mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java?rev=1429867&r1=1429866&r2=1429867&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java (original)
+++ mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java Mon Jan  7 16:07:07 2013
@@ -61,6 +61,11 @@ public interface ServerFactoryManager ex
      */
     public static final String IDLE_TIMEOUT = "idle-timeout";
 
+    /**
+     * Key used to retrieve the value of welcome banner that will be displayed
+     * when a user connects to the server.
+     */
+    public static final String WELCOME_BANNER = "welcome-banner";
 
     /**
      * Retrieve the list of named factories for <code>UserAuth<code> objects.

Modified: mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java?rev=1429867&r1=1429866&r2=1429867&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java (original)
+++ mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java Mon Jan  7 16:07:07 2013
@@ -70,6 +70,7 @@ public class ServerSession extends Abstr
     private final TcpipForwardSupport tcpipForward;
     private final AgentForwardSupport agentForward;
     private final X11ForwardSupport x11Forward;
+    private String welcomeBanner = null;
 
     private HandshakingUserAuth currentAuth;
 
@@ -87,6 +88,7 @@ public class ServerSession extends Abstr
         tcpipForward = new TcpipForwardSupport(this);
         agentForward = new AgentForwardSupport(this);
         x11Forward = new X11ForwardSupport(this);
+        welcomeBanner = factoryManager.getProperties().get(ServerFactoryManager.WELCOME_BANNER);
         log.info("Session created from {}", ioSession.getRemoteAddress());
         sendServerIdentification();
         sendKexInit();
@@ -413,6 +415,12 @@ public class ServerSession extends Abstr
                 
               } else {
                 log.debug("Unsupported authentication method '{}'", method);
+                if (welcomeBanner != null) {
+                    buffer = createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_BANNER, 0);
+                    buffer.putString(welcomeBanner);
+                    buffer.putString("\n");
+                    writePacket(buffer);
+                }
               }
             } else {
               try {