karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject [2/2] git commit: [KARAF-2789] Upgrade to SSHD 0.11.0
Date Fri, 20 Jun 2014 19:52:21 GMT
[KARAF-2789] Upgrade to SSHD 0.11.0

Conflicts:
	pom.xml


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

Branch: refs/heads/karaf-3.0.x
Commit: fbdc3b37670d476406047e957db87891eca47aeb
Parents: 18c92d7
Author: Guillaume Nodet <gnodet@gmail.com>
Authored: Tue Apr 22 09:35:49 2014 +0200
Committer: Jonathan Anstey <janstey@gmail.com>
Committed: Fri Jun 20 17:14:50 2014 -0230

----------------------------------------------------------------------
 pom.xml                                         |  2 +-
 .../karaf/shell/ssh/KarafFileSystemFactory.java | 10 ++-
 .../karaf/shell/ssh/KarafFileSystemView.java    | 66 --------------------
 3 files changed, 10 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/fbdc3b37/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2a2dc6d..4dd8e30 100644
--- a/pom.xml
+++ b/pom.xml
@@ -243,7 +243,7 @@
         <spring.security31.version>3.1.4.RELEASE</spring.security31.version>
 
         <directory-version>2.0.0-M16</directory-version>
-        <sshd.version>0.10.1</sshd.version>
+        <sshd.version>0.11.0</sshd.version>
         <struts.bundle.version>1.3.10_1</struts.bundle.version>
         <xbean.version>3.16</xbean.version>
         <xerces.version>2.11.0</xerces.version>

http://git-wip-us.apache.org/repos/asf/karaf/blob/fbdc3b37/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java
index ba3b741..8d69af3 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java
@@ -18,9 +18,14 @@
  */
 package org.apache.karaf.shell.ssh;
 
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.sshd.common.Session;
 import org.apache.sshd.common.file.FileSystemFactory;
 import org.apache.sshd.common.file.FileSystemView;
+import org.apache.sshd.common.file.nativefs.NativeFileSystemView;
 
 /**
  * SSHd file system factory to reduce the visibility to the KARAF_BASE.
@@ -28,7 +33,10 @@ import org.apache.sshd.common.file.FileSystemView;
 public class KarafFileSystemFactory implements FileSystemFactory {
 
     public FileSystemView createFileSystemView(Session session) {
-        return new KarafFileSystemView(session.getUsername());
+        Map<String, String> roots = new HashMap<String, String>();
+        String dir = new File(System.getProperty("karaf.base")).getAbsolutePath();
+        roots.put("/", dir);
+        return new NativeFileSystemView(session.getUsername(), roots, "/");
     }
 
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/fbdc3b37/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemView.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemView.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemView.java
deleted file mode 100644
index 6724e4f..0000000
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemView.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.karaf.shell.ssh;
-
-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 extends NativeFileSystemView {
-
-    private String username;
-    private String location;
-
-    public KarafFileSystemView(String username) {
-        super(username);
-        this.username = username;
-    }
-
-    @Override
-    public String getVirtualUserDir() {
-        return "/";
-    }
-
-    @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 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");
-        }
-        File fileObj = new File(physicalName);
-        // strip the root directory and return
-        String karafFileName = physicalName.substring(location.length());
-        return createNativeSshFile(karafFileName, fileObj, username);
-    }
-
-}


Mime
View raw message