You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2013/11/20 13:14:29 UTC

svn commit: r1543797 - in /karaf/trunk: ./ assemblies/features/framework/ shell/ssh/ shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ shell/ssh/src/main/resources/OSGI-INF/blueprint/ tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/...

Author: jbonofre
Date: Wed Nov 20 12:14:29 2013
New Revision: 1543797

URL: http://svn.apache.org/r1543797
Log:
[KARAF-2464] Upgrade to sshd-core 0.9.0

Removed:
    karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafSshFile.java
Modified:
    karaf/trunk/assemblies/features/framework/pom.xml
    karaf/trunk/pom.xml
    karaf/trunk/shell/ssh/pom.xml
    karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java
    karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemView.java
    karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/UserAuthFactoriesFactory.java
    karaf/trunk/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
    karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java

Modified: karaf/trunk/assemblies/features/framework/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/assemblies/features/framework/pom.xml?rev=1543797&r1=1543796&r2=1543797&view=diff
==============================================================================
--- karaf/trunk/assemblies/features/framework/pom.xml (original)
+++ karaf/trunk/assemblies/features/framework/pom.xml Wed Nov 20 12:14:29 2013
@@ -408,6 +408,12 @@
                         <goals>
                             <goal>features-generate-descriptor</goal>
                         </goals>
+                        <configuration>
+                            <excludedArtifactIds>
+                                <excludedArtifactId>slf4j-api</excludedArtifactId>
+                                <excludedArtifactId>mina-core</excludedArtifactId>
+                            </excludedArtifactIds>
+                        </configuration>
                     </execution>
                     <execution>
                         <id>package</id>

Modified: karaf/trunk/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/pom.xml?rev=1543797&r1=1543796&r2=1543797&view=diff
==============================================================================
--- karaf/trunk/pom.xml (original)
+++ karaf/trunk/pom.xml Wed Nov 20 12:14:29 2013
@@ -219,7 +219,7 @@
         <spring.osgi.version>1.2.1</spring.osgi.version>
         <spring31.version>3.1.4.RELEASE</spring31.version>
         <spring32.version>3.2.4.RELEASE</spring32.version>
-        <sshd.version>0.8.0</sshd.version>
+        <sshd.version>0.9.0</sshd.version>
         <struts.bundle.version>1.3.10_1</struts.bundle.version>
         <xbean.version>3.16-SNAPSHOT</xbean.version>
         <xerces.version>2.11.0</xerces.version>

Modified: karaf/trunk/shell/ssh/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/ssh/pom.xml?rev=1543797&r1=1543796&r2=1543797&view=diff
==============================================================================
--- karaf/trunk/shell/ssh/pom.xml (original)
+++ karaf/trunk/shell/ssh/pom.xml Wed Nov 20 12:14:29 2013
@@ -113,8 +113,11 @@
                             org.apache.felix.service.command,
                             org.apache.karaf.shell.commands,
                             org.apache.karaf.shell.console,
+                            org.apache.mina.util,
                             org.apache.sshd.server.keyprovider,
                             org.apache.sshd.server.jaas,
+                            org.apache.sshd.server.sftp,
+                            !org.apache.sshd.server.sftp.SftpSubsystem,
                             *
                         </Import-Package>
                         <Private-Package>

Modified: karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java?rev=1543797&r1=1543796&r2=1543797&view=diff
==============================================================================
--- karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java (original)
+++ karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java Wed Nov 20 12:14:29 2013
@@ -19,8 +19,8 @@
 package org.apache.karaf.shell.ssh;
 
 import org.apache.sshd.common.Session;
-import org.apache.sshd.server.FileSystemFactory;
-import org.apache.sshd.server.FileSystemView;
+import org.apache.sshd.common.file.FileSystemFactory;
+import org.apache.sshd.common.file.FileSystemView;
 
 /**
  * SSHd file system factory to reduce the visibility to the KARAF_BASE.
@@ -28,7 +28,7 @@ import org.apache.sshd.server.FileSystem
 public class KarafFileSystemFactory implements FileSystemFactory {
 
     public FileSystemView createFileSystemView(Session session) {
-        return new KarafFileSystemView();
+        return new KarafFileSystemView(session.getUsername());
     }
 
 }

Modified: karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemView.java
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemView.java?rev=1543797&r1=1543796&r2=1543797&view=diff
==============================================================================
--- karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemView.java (original)
+++ karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemView.java Wed Nov 20 12:14:29 2013
@@ -18,44 +18,49 @@
  */
 package org.apache.karaf.shell.ssh;
 
-import org.apache.sshd.server.FileSystemView;
-import org.apache.sshd.server.SshFile;
-import org.apache.sshd.server.filesystem.NativeSshFile;
-
 import java.io.File;
 
+import org.apache.sshd.common.file.SshFile;
+import org.apache.sshd.common.file.nativefs.NativeFileSystemView;
+import org.apache.sshd.common.file.nativefs.NativeSshFile;
+
 /**
  * Karaf file system view reduced to the KARAF_BASE location
  */
-public class KarafFileSystemView implements FileSystemView {
+public class KarafFileSystemView extends NativeFileSystemView {
 
+    private String username;
     private String location;
 
-    public KarafFileSystemView() {
-        location = System.getProperty("karaf.base");
+    public KarafFileSystemView(String username) {
+        super(username);
+        this.username = username;
     }
 
-    public SshFile getFile(String file) {
-        return getFile(location, file);
+    @Override
+    public String getVirtualUserDir() {
+        return "/";
     }
 
-    public SshFile getFile(SshFile baseDir, String file) {
-        return getFile(baseDir.getAbsolutePath(), file);
+    @Override
+    public String getPhysicalUserDir() {
+        if (location == null) {
+            location = new File(System.getProperty("karaf.base")).getAbsolutePath();
+        }
+        return location;
     }
 
     protected SshFile getFile(String dir, String file) {
         // get actual file object
-        String physicalName = NativeSshFile.getPhysicalName("/", dir, file, false);
-
+        String location = getPhysicalUserDir();
+        String physicalName = NativeSshFile.getPhysicalName(location, dir, file, false);
         if (!physicalName.startsWith(location)) {
-            throw new IllegalArgumentException("The path is not relative to KARAF_BASE. For security reason, it's not allowed.");
+            throw new IllegalArgumentException("The path is not relative to KARAF_BASE. For security reason, it's not allowed");
         }
-
         File fileObj = new File(physicalName);
-
         // strip the root directory and return
-        String karafFileName = physicalName.substring("/".length() - 1);
-        return new KarafSshFile(karafFileName, fileObj);
+        String karafFileName = physicalName.substring(location.length());
+        return createNativeSshFile(karafFileName, fileObj, username);
     }
 
 }

Modified: karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/UserAuthFactoriesFactory.java
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/UserAuthFactoriesFactory.java?rev=1543797&r1=1543796&r2=1543797&view=diff
==============================================================================
--- karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/UserAuthFactoriesFactory.java (original)
+++ karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/UserAuthFactoriesFactory.java Wed Nov 20 12:14:29 2013
@@ -20,6 +20,7 @@ package org.apache.karaf.shell.ssh;
 
 import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.server.UserAuth;
+import org.apache.sshd.server.auth.UserAuthKeyboardInteractive;
 import org.apache.sshd.server.auth.UserAuthPassword;
 import org.apache.sshd.server.auth.UserAuthPublicKey;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
@@ -49,6 +50,7 @@ public class UserAuthFactoriesFactory {
 
     public static final String PASSWORD_METHOD = "password";
     public static final String PUBLICKEY_METHOD = "publickey";
+    public static final String KEYBOARD_INTERACTIVE_METHOD = "keyboard-interactive";
 
     private Set<String> methodSet;
     private List<NamedFactory<UserAuth>> factories;
@@ -87,6 +89,8 @@ public class UserAuthFactoriesFactory {
         for (String am : ams) {
             if (PASSWORD_METHOD.equals(am)) {
                 this.factories.add(new UserAuthPassword.Factory());
+            } else if (KEYBOARD_INTERACTIVE_METHOD.equals(am)) {
+                this.factories.add(new UserAuthKeyboardInteractive.Factory());
             } else if (PUBLICKEY_METHOD.equals(am)) {
                 this.factories.add(new UserAuthPublicKey.Factory());
             } else {
@@ -108,4 +112,8 @@ public class UserAuthFactoriesFactory {
         return this.methodSet.contains(PASSWORD_METHOD);
     }
 
+    public boolean isKeyboardInteractive() {
+        return this.methodSet.contains(KEYBOARD_INTERACTIVE_METHOD);
+    }
+
 }

Modified: karaf/trunk/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml?rev=1543797&r1=1543796&r2=1543797&view=diff
==============================================================================
--- karaf/trunk/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml (original)
+++ karaf/trunk/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml Wed Nov 20 12:14:29 2013
@@ -46,7 +46,7 @@
             <cm:property name="sshRealm" value="karaf"/>
             <cm:property name="hostKey" value="$[karaf.base]/etc/host.key"/>
             <cm:property name="authorizedKeys" value="$[karaf.base]/etc/authorized_keys"/>
-            <cm:property name="authMethods" value="password,publickey"/>
+            <cm:property name="authMethods" value="keyboard-interactive,password,publickey"/>
             <cm:property name="keySize" value="1024"/>
             <cm:property name="algorithm" value="DSA"/>
         </cm:default-properties>
@@ -94,6 +94,11 @@
                 </argument>
             </bean>
         </property>
+        <property name="subsystemFactories">
+            <list>
+                <bean class="org.apache.sshd.server.sftp.SftpSubsystem.Factory"/>
+            </list>
+        </property>
         <property name="keyPairProvider" ref="keyPairProvider"/>
         <property name="passwordAuthenticator" ref="authenticator"/>
         <property name="publickeyAuthenticator" ref="authenticator"/>

Modified: karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
URL: http://svn.apache.org/viewvc/karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java?rev=1543797&r1=1543796&r2=1543797&view=diff
==============================================================================
--- karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java (original)
+++ karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java Wed Nov 20 12:14:29 2013
@@ -18,12 +18,7 @@
 package org.apache.karaf.tooling.features;
 
 import java.io.*;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.jar.JarInputStream;
 import java.util.jar.Manifest;
 
@@ -105,6 +100,13 @@ public class GenerateDescriptorMojo exte
     private File outputFile;
 
     /**
+     * (wrapper) Exclude some artifacts from the generated feature.
+     *
+     * @parameter
+     */
+    private List<String> excludedArtifactIds = new ArrayList<String>();
+
+    /**
      * The resolver to use for the feature.  Normally null or "OBR" or "(OBR)"
      *
      * @parameter default-value="${resolver}"
@@ -328,6 +330,11 @@ public class GenerateDescriptorMojo exte
         }
         for (Map.Entry<Artifact, String> entry : localDependencies.entrySet()) {
             Artifact artifact = entry.getKey();
+
+            if (excludedArtifactIds.contains(artifact.getArtifactId())) {
+                continue;
+            }
+
             if (DependencyHelper.isFeature(artifact)) {
                 if (aggregateFeatures && FEATURE_CLASSIFIER.equals(artifact.getClassifier())) {
                     File featuresFile = resolve(artifact);