[KARAF-2789] Upgrade to SSHD 0.11.0
Conflicts:
pom.xml
shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemView.java
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/994d3cce
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/994d3cce
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/994d3cce
Branch: refs/heads/karaf-2.x
Commit: 994d3cce3d01595e9d941058b5bdaf250b4b953b
Parents: 531def5
Author: Guillaume Nodet <[email protected]>
Authored: Tue Apr 22 09:35:49 2014 +0200
Committer: Jonathan Anstey <[email protected]>
Committed: Fri Jun 20 16:54:40 2014 -0230
----------------------------------------------------------------------
pom.xml | 2 +-
.../karaf/shell/ssh/KarafFileSystemFactory.java | 10 ++-
.../karaf/shell/ssh/KarafFileSystemView.java | 67 --------------------
3 files changed, 10 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/994d3cce/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ed48a26..c3af7dc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -222,7 +222,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/994d3cce/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/994d3cce/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 3f37e6d..0000000
---
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemView.java
+++ /dev/null
@@ -1,67 +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 org.apache.sshd.common.file.SshFile;
-import org.apache.sshd.common.file.nativefs.NativeFileSystemView;
-import org.apache.sshd.common.file.nativefs.NativeSshFile;
-
-import java.io.File;
-
-/**
- * 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;
- }
-
- @Override
- 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);
- }
-
-}