You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ja...@apache.org on 2014/04/17 03:29:37 UTC

git commit: KARAF-2918 - Provide ability to set a banner prior to user login via ssh

Repository: karaf
Updated Branches:
  refs/heads/master 40ae90f9a -> ebbc1089c


KARAF-2918 - Provide ability to set a banner prior to user login via ssh


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

Branch: refs/heads/master
Commit: ebbc1089cec2ce9d8750af303e09d234f506a1df
Parents: 40ae90f
Author: Jonathan Anstey <ja...@gmail.com>
Authored: Wed Apr 16 22:59:19 2014 -0230
Committer: Jonathan Anstey <ja...@gmail.com>
Committed: Wed Apr 16 22:59:19 2014 -0230

----------------------------------------------------------------------
 .../resources/resources/etc/org.apache.karaf.shell.cfg    |  7 ++++++-
 .../instance/resources/etc/org.apache.karaf.shell.cfg     |  7 ++++++-
 .../main/java/org/apache/karaf/shell/ssh/Activator.java   |  7 +++++--
 .../java/org/apache/karaf/shell/ssh/SshServerAction.java  | 10 +++++++++-
 4 files changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/ebbc1089/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.shell.cfg
----------------------------------------------------------------------
diff --git a/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.shell.cfg b/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.shell.cfg
index 30aebb6..62d9072 100644
--- a/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.shell.cfg
+++ b/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.shell.cfg
@@ -62,6 +62,11 @@ hostKey = ${karaf.etc}/host.key
 # algorithm = DSA
 
 #
+# Specify an additional welcome banner to be displayed when a user logs into the server.
+#
+# welcomeBanner =
+
+#
 # Defines the completion mode on the Karaf shell console. The possible values are:
 # - GLOBAL: it's the same behavior as in previous Karaf releases. The completion displays all commands and all aliases
 #           ignoring if you are in a subshell or not.
@@ -72,4 +77,4 @@ hostKey = ${karaf.etc}/host.key
 # This property define the default value when you use the Karaf shell console.
 # You can change the completion mode directly in the shell console, using shell:completion command.
 #
-completionMode = GLOBAL
\ No newline at end of file
+completionMode = GLOBAL

http://git-wip-us.apache.org/repos/asf/karaf/blob/ebbc1089/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg
----------------------------------------------------------------------
diff --git a/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg b/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg
index 077f5da..b00ffc7 100644
--- a/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg
+++ b/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg
@@ -62,6 +62,11 @@ hostKey = ${karaf.etc}/host.key
 # algorithm = DSA
 
 #
+# Specify an additional welcome banner to be displayed when a user logs into the server.
+#
+# welcomeBanner =
+
+#
 # Defines the completion mode on the Karaf shell console. The possible values are:
 # - GLOBAL: it's the same behavior as in previous Karaf releases. The completion displays all commands and all aliases
 #           ignoring if you are in a subshell or not.
@@ -72,4 +77,4 @@ hostKey = ${karaf.etc}/host.key
 # This property define the default value when you use the Karaf shell console.
 # You can change the completion mode directly in the shell console, using shell:completion command.
 #
-completionMode = GLOBAL
\ No newline at end of file
+completionMode = GLOBAL

http://git-wip-us.apache.org/repos/asf/karaf/blob/ebbc1089/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
index 1e9626d..543ccf4 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
@@ -128,7 +128,8 @@ public class Activator extends BaseActivator implements ManagedService {
         String algorithm      = getString("algorithm", "DSA");
         String macs           = getString("macs", "hmac-sha1");
         String ciphers        = getString("ciphers", "aes256-ctr,aes192-ctr,aes128-ctr,arcfour256");
-
+        String welcomeBanner  = getString("welcomeBanner", null);
+        
         SimpleGeneratorHostKeyProvider keyPairProvider = new SimpleGeneratorHostKeyProvider();
         keyPairProvider.setPath(hostKey);
         keyPairProvider.setKeySize(keySize);
@@ -154,7 +155,9 @@ public class Activator extends BaseActivator implements ManagedService {
         server.setUserAuthFactories(authFactoriesFactory.getFactories());
         server.setAgentFactory(agentFactory);
         server.getProperties().put(SshServer.IDLE_TIMEOUT, Long.toString(sshIdleTimeout));
-
+        if (welcomeBanner != null) {
+            server.getProperties().put(SshServer.WELCOME_BANNER, welcomeBanner);
+        } 
         return server;
     }
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/ebbc1089/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
index 6b45a0a..af2dfc7 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
@@ -42,6 +42,9 @@ public class SshServerAction implements Action
     @Option(name = "-i", aliases = { "--idle-timeout" }, description = "The session idle timeout (Default: 1800000ms)", required = false, multiValued = false)
     private long idleTimeout = 1800000;
 
+    @Option(name = "-w", aliases = { "--welcome-banner" }, description = "The welcome banner to display when logging in", required = false, multiValued = false)
+    private String welcomeBanner;
+    
     @Reference
     private SshServer server;
 
@@ -57,7 +60,12 @@ public class SshServerAction implements Action
 
         // idle timeout
         server.getProperties().put(SshServer.IDLE_TIMEOUT, Long.toString(idleTimeout));
-
+        
+        // welcome banner
+        if (welcomeBanner != null) {
+            server.getProperties().put(SshServer.WELCOME_BANNER, welcomeBanner);
+        } 
+        
         // starting the SSHd server
         server.start();