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 16:45:23 UTC

[2/3] git commit: KARAF-2918 - Provide ability to set a banner prior to user login via ssh

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/69ed05bd
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/69ed05bd
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/69ed05bd

Branch: refs/heads/karaf-3.0.x
Commit: 69ed05bd81d8f3f16ce2bf0a8586d49f4a2bef03
Parents: 84198aa
Author: Jonathan Anstey <ja...@gmail.com>
Authored: Thu Apr 17 11:54:03 2014 -0230
Committer: Jonathan Anstey <ja...@gmail.com>
Committed: Thu Apr 17 11:54:03 2014 -0230

----------------------------------------------------------------------
 .../resources/resources/etc/org.apache.karaf.shell.cfg |  6 +++++-
 .../instance/resources/etc/org.apache.karaf.shell.cfg  |  6 +++++-
 .../org/apache/karaf/shell/ssh/SshServerAction.java    |  8 ++++++++
 .../org/apache/karaf/shell/ssh/SshServerFactory.java   | 13 +++++++++++++
 .../main/resources/OSGI-INF/blueprint/shell-ssh.xml    |  2 ++
 5 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/69ed05bd/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..5e33d01 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
@@ -61,6 +61,10 @@ 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
@@ -72,4 +76,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/69ed05bd/instance/core/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg
----------------------------------------------------------------------
diff --git a/instance/core/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg b/instance/core/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg
index 077f5da..2f9380d 100644
--- a/instance/core/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg
+++ b/instance/core/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg
@@ -61,6 +61,10 @@ 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
@@ -72,4 +76,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/69ed05bd/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 e92db70..02495f6 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
@@ -41,6 +41,9 @@ public class SshServerAction extends OsgiCommandSupport implements BlueprintCont
     @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;
+
     private BlueprintContainer container;
 
     private String sshServerId;
@@ -65,6 +68,11 @@ public class SshServerAction extends OsgiCommandSupport implements BlueprintCont
         // idle timeout
         server.getProperties().put(SshServer.IDLE_TIMEOUT, new Long(idleTimeout).toString());
 
+        // welcome banner
+        if (welcomeBanner != null) {
+            server.getProperties().put(SshServer.WELCOME_BANNER, welcomeBanner);
+        } 
+
         // starting the SSHd server
         server.start();
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/69ed05bd/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java
index 4789669..6d4233e 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java
@@ -31,6 +31,8 @@ public class SshServerFactory {
 
     private SshServer server;
 
+    private String welcomeBanner;
+
     public SshServerFactory(SshServer server) {
         this.server = server;
     }
@@ -51,10 +53,21 @@ public class SshServerFactory {
         this.idleTimeout = idleTimeout;
     }
 
+    public String getWelcomeBanner() {
+        return welcomeBanner;
+    }
+
+    public void setWelcomeBanner(String welcomeBanner) {
+        this.welcomeBanner = welcomeBanner;
+    }
+    
     public void start() {
         if (start) {
             try {
                 server.getProperties().put(SshServer.IDLE_TIMEOUT, new Long(idleTimeout).toString());
+                if (getWelcomeBanner() != null && !getWelcomeBanner().isEmpty()) {
+                    server.getProperties().put(SshServer.WELCOME_BANNER, getWelcomeBanner());
+                }
                 server.start();
             } catch (Exception e) {
                 LOGGER.info("Error updating SSH server", e);

http://git-wip-us.apache.org/repos/asf/karaf/blob/69ed05bd/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml b/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
index 4b16181..b8b64ec 100644
--- a/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
+++ b/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
@@ -51,6 +51,7 @@
             <cm:property name="algorithm" value="DSA"/>
             <cm:property name="macs" value="hmac-sha1" />
             <cm:property name="ciphers" value="aes256-ctr,aes192-ctr,aes128-ctr,arcfour256" />
+            <cm:property name="welcomeBanner" value="" />
         </cm:default-properties>
     </cm:property-placeholder>
 
@@ -146,6 +147,7 @@
         <argument ref="sshServer"/>
         <property name="start" value="$[karaf.startRemoteShell]"/>
         <property name="idleTimeout" value="${sshIdleTimeout}"/>
+        <property name="welcomeBanner" value="${welcomeBanner}"/>
     </bean>
 
     <reference id="commandProcessor" interface="org.apache.felix.service.command.CommandProcessor">