You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2021/11/20 06:36:06 UTC

[mina-sshd] 04/05: [SSHD-1226] Removed ServerSession argument from SftpFileSystemAccessor invocations since it can be retrieved from the provided SftpSubsystemProxy instance

This is an automated email from the ASF dual-hosted git repository.

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git

commit 83a0684c59d45e46b7ad25973745d14a11adcaf9
Author: Lyor Goldstein <lg...@apache.org>
AuthorDate: Fri Nov 19 08:04:21 2021 +0200

    [SSHD-1226] Removed ServerSession argument from SftpFileSystemAccessor invocations since it can be retrieved from the provided SftpSubsystemProxy instance
---
 CHANGES.md                                         |   2 +
 .../sftp/server/AbstractSftpSubsystemHelper.java   | 128 +++++++++------------
 .../apache/sshd/sftp/server/DirectoryHandle.java   |   8 +-
 .../org/apache/sshd/sftp/server/FileHandle.java    |  12 +-
 .../sshd/sftp/server/SftpFileSystemAccessor.java   | 115 +++++++-----------
 .../org/apache/sshd/sftp/server/SftpSubsystem.java |  19 ++-
 .../java/org/apache/sshd/sftp/client/SftpTest.java |   9 +-
 7 files changed, 115 insertions(+), 178 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index de364fb..7cdd68d 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -18,6 +18,8 @@
 
 ## Potential compatibility issues
 
+* Removed `ServerSession` argument from `SftpFileSystemAccessor` invocations since it can be retrieved from the provided `SftpSubsystemProxy` instance
+
 ## Minor code helpers
 
 * [SSHD-1193](https://issues.apache.org/jira/browse/SSHD-1193) Provide a more user-friendly text in case disconnecting due to timeout(s).
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpSubsystemHelper.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpSubsystemHelper.java
index f219524..6687c12 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpSubsystemHelper.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpSubsystemHelper.java
@@ -320,16 +320,16 @@ public abstract class AbstractSftpSubsystemHelper
      * @throws IOException if anything wrong happens
      */
     protected void process(Buffer buffer) throws IOException {
+        ServerSession session = getServerSession();
         int length = buffer.getInt();
         int type = buffer.getUByte();
         int id = buffer.getInt();
         if (log.isDebugEnabled()) {
             log.debug("process({})[length={}, type={}, id={}] processing",
-                    getServerSession(), length, SftpConstants.getCommandMessageName(type), id);
+                    session, length, SftpConstants.getCommandMessageName(type), id);
         }
         try {
             SftpEventListener listener = getSftpEventListenerProxy();
-            ServerSession session = getServerSession();
             listener.received(session, type, id);
         } catch (IOException | RuntimeException e) {
             if (type == SftpConstants.SSH_FXP_INIT) {
@@ -631,10 +631,9 @@ public abstract class AbstractSftpSubsystemHelper
 
     protected Map<String, Object> doLStat(int id, String path, int flags) throws IOException {
         Path p = resolveFile(path);
-        ServerSession session = getServerSession();
         if (log.isDebugEnabled()) {
             log.debug("doLStat({})[id={}] SSH_FXP_LSTAT (path={}[{}], flags=0x{})",
-                    session, id, path, p, Integer.toHexString(flags));
+                    getServerSession(), id, path, p, Integer.toHexString(flags));
         }
 
         /*
@@ -643,7 +642,7 @@ public abstract class AbstractSftpSubsystemHelper
          */
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
         LinkOption[] options = accessor.resolveFileAccessLinkOptions(
-                session, this, p, SftpConstants.SSH_FXP_LSTAT, "", false);
+                this, p, SftpConstants.SSH_FXP_LSTAT, "", false);
         return resolveFileAttributes(p, flags, options);
     }
 
@@ -666,9 +665,8 @@ public abstract class AbstractSftpSubsystemHelper
             int id, String path, int cmd, String extension, Map<String, ?> attrs, Boolean followLinks)
             throws IOException {
         if (log.isDebugEnabled()) {
-            ServerSession session = getServerSession();
             log.debug("doSetStat({})[id={}, cmd={}, extension={}]  (path={}, attrs={}, followLinks={})",
-                    session, id, cmd, extension, path, attrs, followLinks);
+                    getServerSession(), id, cmd, extension, path, attrs, followLinks);
         }
 
         Path p = resolveFile(path);
@@ -940,7 +938,7 @@ public abstract class AbstractSftpSubsystemHelper
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
         ServerSession session = getServerSession();
         try (SeekableByteChannel channel = accessor.openFile(
-                session, this, null, file, null, Collections.emptySet())) {
+                this, null, file, null, Collections.emptySet())) {
             channel.position(startOffset);
 
             Digest digest = factory.create();
@@ -999,7 +997,7 @@ public abstract class AbstractSftpSubsystemHelper
                 }
             }
 
-            accessor.closeFile(session, this, null, file, null, channel, Collections.emptySet());
+            accessor.closeFile(this, null, file, null, channel, Collections.emptySet());
         }
     }
 
@@ -1059,7 +1057,7 @@ public abstract class AbstractSftpSubsystemHelper
         boolean traceEnabled = log.isTraceEnabled();
         ServerSession session = getServerSession();
         try (SeekableByteChannel channel = accessor.openFile(
-                session, this, null, path, null, Collections.emptySet())) {
+                this, null, path, null, Collections.emptySet())) {
             channel.position(startOffset);
 
             /*
@@ -1130,7 +1128,7 @@ public abstract class AbstractSftpSubsystemHelper
                 hashValue = GenericUtils.EMPTY_BYTE_ARRAY;
             }
 
-            accessor.closeFile(session, this, null, path, null, channel, Collections.emptySet());
+            accessor.closeFile(this, null, path, null, channel, Collections.emptySet());
         }
 
         if (traceEnabled) {
@@ -1175,11 +1173,10 @@ public abstract class AbstractSftpSubsystemHelper
     protected SimpleImmutableEntry<Path, String> doReadLink(int id, String path) throws IOException {
         Path link = resolveFile(path);
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
-        ServerSession session = getServerSession();
-        String target = accessor.resolveLinkTarget(session, this, link);
+        String target = accessor.resolveLinkTarget(this, link);
         if (log.isDebugEnabled()) {
             log.debug("doReadLink({})[id={}] path={}[{}]: {}",
-                    session, id, path, link, target);
+                    getServerSession(), id, path, link, target);
         }
         return new SimpleImmutableEntry<>(link, target);
     }
@@ -1232,7 +1229,7 @@ public abstract class AbstractSftpSubsystemHelper
         listener.moving(session, o, n, opts);
         try {
             SftpFileSystemAccessor accessor = getFileSystemAccessor();
-            accessor.renameFile(session, this, o, n, opts);
+            accessor.renameFile(this, o, n, opts);
         } catch (IOException | RuntimeException | Error e) {
             listener.moved(session, o, n, opts, e);
             throw e;
@@ -1318,7 +1315,7 @@ public abstract class AbstractSftpSubsystemHelper
         Path src = resolveFile(srcFile);
         Path dst = resolveFile(dstFile);
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
-        accessor.copyFile(getServerSession(), this, src, dst, opts);
+        accessor.copyFile(this, src, dst, opts);
     }
 
     protected void doBlock(Buffer buffer, int id) throws IOException {
@@ -1381,10 +1378,9 @@ public abstract class AbstractSftpSubsystemHelper
     }
 
     protected Map<String, Object> doStat(int id, String path, int flags) throws IOException {
-        ServerSession session = getServerSession();
         if (log.isDebugEnabled()) {
             log.debug("doStat({})[id={}] SSH_FXP_STAT (path={}, flags=0x{})",
-                    session, id, path, Integer.toHexString(flags));
+                    getServerSession(), id, path, Integer.toHexString(flags));
         }
 
         /*
@@ -1394,7 +1390,7 @@ public abstract class AbstractSftpSubsystemHelper
         Path p = resolveFile(path);
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
         LinkOption[] options = accessor.resolveFileAccessLinkOptions(
-                session, this, p, SftpConstants.SSH_FXP_STAT, "", true);
+                this, p, SftpConstants.SSH_FXP_STAT, "", true);
         return resolveFileAttributes(p, flags, options);
     }
 
@@ -1562,14 +1558,13 @@ public abstract class AbstractSftpSubsystemHelper
 
     protected void doRemoveDirectory(int id, String path, boolean followLinks) throws IOException {
         Path p = resolveFile(path);
-        ServerSession session = getServerSession();
         if (log.isDebugEnabled()) {
-            log.debug("doRemoveDirectory({})[id={}] SSH_FXP_RMDIR (path={})[{}]", session, id, path, p);
+            log.debug("doRemoveDirectory({})[id={}] SSH_FXP_RMDIR (path={})[{}]", getServerSession(), id, path, p);
         }
 
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
         LinkOption[] options = accessor.resolveFileAccessLinkOptions(
-                session, this, p, SftpConstants.SSH_FXP_RMDIR, "", followLinks);
+                this, p, SftpConstants.SSH_FXP_RMDIR, "", followLinks);
         if (Files.isDirectory(p, options)) {
             doRemove(id, p, true);
         } else {
@@ -1593,7 +1588,7 @@ public abstract class AbstractSftpSubsystemHelper
         listener.removing(session, p, isDirectory);
         try {
             SftpFileSystemAccessor accessor = getFileSystemAccessor();
-            accessor.removeFile(session, this, p, isDirectory);
+            accessor.removeFile(this, p, isDirectory);
         } catch (IOException | RuntimeException | Error e) {
             listener.removed(session, p, isDirectory, e);
             throw e;
@@ -1627,7 +1622,7 @@ public abstract class AbstractSftpSubsystemHelper
 
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
         LinkOption[] options = accessor.resolveFileAccessLinkOptions(
-                session, this, resolvedPath, SftpConstants.SSH_FXP_MKDIR, "", followLinks);
+                this, resolvedPath, SftpConstants.SSH_FXP_MKDIR, "", followLinks);
         SftpPathImpl.withAttributeCache(resolvedPath, p -> {
             Boolean status = IoUtils.checkFileExists(p, options);
             if (status == null) {
@@ -1647,7 +1642,7 @@ public abstract class AbstractSftpSubsystemHelper
         SftpEventListener listener = getSftpEventListenerProxy();
         listener.creating(session, resolvedPath, attrs);
         try {
-            accessor.createDirectory(session, this, resolvedPath);
+            accessor.createDirectory(this, resolvedPath);
             followLinks = resolvePathResolutionFollowLinks(SftpConstants.SSH_FXP_MKDIR, "", resolvedPath);
             doSetAttributes(SftpConstants.SSH_FXP_MKDIR, "", resolvedPath, attrs, followLinks);
         } catch (IOException | RuntimeException | Error e) {
@@ -1674,14 +1669,13 @@ public abstract class AbstractSftpSubsystemHelper
 
     protected void doRemoveFile(int id, String path, boolean followLinks) throws IOException {
         Path resolvedPath = resolveFile(path);
-        ServerSession session = getServerSession();
         if (log.isDebugEnabled()) {
-            log.debug("doRemoveFile({})[id={}] SSH_FXP_REMOVE (path={}[{}])", session, id, path, resolvedPath);
+            log.debug("doRemoveFile({})[id={}] SSH_FXP_REMOVE (path={}[{}])", getServerSession(), id, path, resolvedPath);
         }
 
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
         LinkOption[] options = accessor.resolveFileAccessLinkOptions(
-                session, this, resolvedPath, SftpConstants.SSH_FXP_REMOVE, "", followLinks);
+                this, resolvedPath, SftpConstants.SSH_FXP_REMOVE, "", followLinks);
         SftpPathImpl.withAttributeCache(resolvedPath, p -> {
             Boolean status = IoUtils.checkFileExists(p, options);
             if (status == null) {
@@ -2124,15 +2118,14 @@ public abstract class AbstractSftpSubsystemHelper
     }
 
     protected void sendLink(Buffer buffer, int id, Path file, String link) throws IOException {
-        // in case we are running on Windows
-        String unixPath = link.replace(File.separatorChar, '/');
-        SftpFileSystemAccessor accessor = getFileSystemAccessor();
-        ServerSession session = getServerSession();
-
         buffer.putByte((byte) SftpConstants.SSH_FXP_NAME);
         buffer.putInt(id);
         buffer.putInt(1); // one response
-        accessor.putRemoteFileName(session, this, file, buffer, unixPath, true);
+
+        // in case we are running on Windows
+        String unixPath = link.replace(File.separatorChar, '/');
+        SftpFileSystemAccessor accessor = getFileSystemAccessor();
+        accessor.putRemoteFileName(this, file, buffer, unixPath, true);
 
         /*
          * As per the spec (https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-6.10):
@@ -2143,11 +2136,11 @@ public abstract class AbstractSftpSubsystemHelper
         int version = getVersion();
         if (version == SftpConstants.SFTP_V3) {
             String longName = SftpHelper.getLongName(unixPath, attrs);
-            accessor.putRemoteFileName(session, this, file, buffer, longName, false);
+            accessor.putRemoteFileName(this, file, buffer, longName, false);
         }
 
         writeAttrs(buffer, attrs);
-        SftpHelper.indicateEndOfNamesList(buffer, getVersion(), session);
+        SftpHelper.indicateEndOfNamesList(buffer, getVersion(), getServerSession());
         send(buffer);
     }
 
@@ -2162,17 +2155,16 @@ public abstract class AbstractSftpSubsystemHelper
         // in case we are running on Windows
         String unixPath = originalPath.replace(File.separatorChar, '/');
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
-        ServerSession session = getServerSession();
-        accessor.putRemoteFileName(session, this, f, buffer, unixPath, true);
+        accessor.putRemoteFileName(this, f, buffer, unixPath, true);
 
         int version = getVersion();
         if (version == SftpConstants.SFTP_V3) {
             String longName = getLongName(f, getShortName(f), attrs);
-            accessor.putRemoteFileName(session, this, f, buffer, longName, false);
+            accessor.putRemoteFileName(this, f, buffer, longName, false);
         }
 
         writeAttrs(buffer, attrs);
-        SftpHelper.indicateEndOfNamesList(buffer, getVersion(), session);
+        SftpHelper.indicateEndOfNamesList(buffer, getVersion(), getServerSession());
         send(buffer);
     }
 
@@ -2192,7 +2184,7 @@ public abstract class AbstractSftpSubsystemHelper
         ServerSession session = getServerSession();
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
         LinkOption[] options = accessor.resolveFileAccessLinkOptions(
-                session, this, dir.getFile(), SftpConstants.SSH_FXP_READDIR, "", followLinks);
+                this, dir.getFile(), SftpConstants.SSH_FXP_READDIR, "", followLinks);
         int nb = 0;
         Map<String, Path> entries = new TreeMap<>(Comparator.naturalOrder());
         while ((dir.isSendDot() || dir.isSendDotDot() || dir.hasNext()) && (buffer.wpos() < maxSize)) {
@@ -2236,11 +2228,11 @@ public abstract class AbstractSftpSubsystemHelper
         int version = getVersion();
 
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
-        accessor.putRemoteFileName(session, this, f, buffer, shortName, true);
+        accessor.putRemoteFileName(this, f, buffer, shortName, true);
 
         if (version == SftpConstants.SFTP_V3) {
             String longName = getLongName(f, shortName, attributes);
-            accessor.putRemoteFileName(session, this, f, buffer, longName, false);
+            accessor.putRemoteFileName(this, f, buffer, longName, false);
 
             if (log.isTraceEnabled()) {
                 log.trace("writeDirEntry({}) id={})[{}] - writing entry {} [{}]: {}", session, id, index, shortName, longName,
@@ -2276,12 +2268,12 @@ public abstract class AbstractSftpSubsystemHelper
 
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
         ServerSession session = getServerSession();
-        accessor.putRemoteFileName(session, this, f, buffer, shortName, true);
+        accessor.putRemoteFileName(this, f, buffer, shortName, true);
 
         int version = getVersion();
         if (version == SftpConstants.SFTP_V3) {
             String longName = getLongName(f, shortName, options);
-            accessor.putRemoteFileName(session, this, f, buffer, longName, false);
+            accessor.putRemoteFileName(this, f, buffer, longName, false);
 
             if (log.isTraceEnabled()) {
                 log.trace("writeDirEntry(" + session + ") id=" + id + ")[" + index + "] - "
@@ -2553,8 +2545,7 @@ public abstract class AbstractSftpSubsystemHelper
             throws IOException {
         try {
             SftpFileSystemAccessor accessor = getFileSystemAccessor();
-            Map<String, ?> attrs = accessor.readFileAttributes(
-                    getServerSession(), this, file, view, options);
+            Map<String, ?> attrs = accessor.readFileAttributes(this, file, view, options);
             if (MapEntryUtils.isEmpty(attrs)) {
                 return Collections.emptyNavigableMap();
             }
@@ -2602,7 +2593,7 @@ public abstract class AbstractSftpSubsystemHelper
         try {
             SftpFileSystemAccessor accessor = getFileSystemAccessor();
             LinkOption[] options = accessor.resolveFileAccessLinkOptions(
-                    session, this, file, cmd, extension, followLinks);
+                    this, file, cmd, extension, followLinks);
             setFileAttributes(file, attributes, options);
         } catch (IOException | RuntimeException | Error e) {
             listener.modifiedAttributes(session, file, attributes, e);
@@ -2614,12 +2605,11 @@ public abstract class AbstractSftpSubsystemHelper
     protected LinkOption[] getPathResolutionLinkOption(int cmd, String extension, Path path) throws IOException {
         boolean followLinks = resolvePathResolutionFollowLinks(cmd, extension, path);
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
-        return accessor.resolveFileAccessLinkOptions(getServerSession(), this, path, cmd, extension, followLinks);
+        return accessor.resolveFileAccessLinkOptions(this, path, cmd, extension, followLinks);
     }
 
     protected boolean resolvePathResolutionFollowLinks(int cmd, String extension, Path path) throws IOException {
-        ServerSession session = getServerSession();
-        return SftpModuleProperties.AUTO_FOLLOW_LINKS.getRequired(session);
+        return SftpModuleProperties.AUTO_FOLLOW_LINKS.getRequired(getServerSession());
     }
 
     protected void setFileAttributes(
@@ -2635,11 +2625,10 @@ public abstract class AbstractSftpSubsystemHelper
                 case IoUtils.SIZE_VIEW_ATTR: {
                     long newSize = ((Number) value).longValue();
                     SftpFileSystemAccessor accessor = getFileSystemAccessor();
-                    ServerSession session = getServerSession();
                     Set<StandardOpenOption> openOptions = EnumSet.of(StandardOpenOption.WRITE);
-                    try (SeekableByteChannel channel = accessor.openFile(session, this, null, file, null, openOptions)) {
+                    try (SeekableByteChannel channel = accessor.openFile(this, null, file, null, openOptions)) {
                         channel.truncate(newSize);
-                        accessor.closeFile(session, this, null, file, null, channel, openOptions);
+                        accessor.closeFile(this, null, file, null, channel, openOptions);
                     }
                     continue;
                 }
@@ -2762,16 +2751,14 @@ public abstract class AbstractSftpSubsystemHelper
             Path file, String view, String attribute, Object value, LinkOption... options)
             throws IOException {
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
-        accessor.setFileAttribute(
-                getServerSession(), this, file, view, attribute, value, options);
+        accessor.setFileAttribute(this, file, view, attribute, value, options);
     }
 
     protected void setFileOwnership(
             Path file, String attribute, Principal value, LinkOption... options)
             throws IOException {
-        ServerSession serverSession = getServerSession();
         if (log.isDebugEnabled()) {
-            log.debug("setFileOwnership({})[{}] {}={}", serverSession, file, attribute, value);
+            log.debug("setFileOwnership({})[{}] {}={}", getServerSession(), file, attribute, value);
         }
 
         /*
@@ -2782,9 +2769,9 @@ public abstract class AbstractSftpSubsystemHelper
          */
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
         if (IoUtils.OWNER_VIEW_ATTR.equalsIgnoreCase(attribute)) {
-            accessor.setFileOwner(serverSession, this, file, value, options);
+            accessor.setFileOwner(this, file, value, options);
         } else if (IoUtils.GROUP_VIEW_ATTR.equalsIgnoreCase(attribute)) {
-            accessor.setGroupOwner(serverSession, this, file, value, options);
+            accessor.setGroupOwner(this, file, value, options);
         } else {
             throw new UnsupportedOperationException("Unknown ownership attribute: " + attribute);
         }
@@ -2818,26 +2805,23 @@ public abstract class AbstractSftpSubsystemHelper
     protected void setFilePermissions(
             Path file, Set<PosixFilePermission> perms, LinkOption... options)
             throws IOException {
-        ServerSession serverSession = getServerSession();
         if (log.isTraceEnabled()) {
-            log.trace("setFilePermissions({})[{}] {}", serverSession, file, perms);
+            log.trace("setFilePermissions({})[{}] {}", getServerSession(), file, perms);
         }
 
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
-        accessor.setFilePermissions(
-                serverSession, this, file, perms, options);
+        accessor.setFilePermissions(this, file, perms, options);
     }
 
     protected void setFileAccessControl(
             Path file, List<AclEntry> acl, LinkOption... options)
             throws IOException {
-        ServerSession serverSession = getServerSession();
         if (log.isTraceEnabled()) {
-            log.trace("setFileAccessControl({})[{}] {}", serverSession, file, acl);
+            log.trace("setFileAccessControl({})[{}] {}", getServerSession(), file, acl);
         }
 
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
-        accessor.setFileAccessControl(serverSession, this, file, acl, options);
+        accessor.setFileAccessControl(this, file, acl, options);
     }
 
     protected void handleUnsupportedAttributes(Collection<String> attributes) {
@@ -2863,7 +2847,7 @@ public abstract class AbstractSftpSubsystemHelper
     protected GroupPrincipal toGroup(Path file, GroupPrincipal name) throws IOException {
         try {
             SftpFileSystemAccessor accessor = getFileSystemAccessor();
-            return accessor.resolveGroupOwner(getServerSession(), this, file, name);
+            return accessor.resolveGroupOwner(this, file, name);
         } catch (IOException e) {
             handleUserPrincipalLookupServiceException(GroupPrincipal.class, name.toString(), e);
             return null;
@@ -2873,7 +2857,7 @@ public abstract class AbstractSftpSubsystemHelper
     protected UserPrincipal toUser(Path file, UserPrincipal name) throws IOException {
         try {
             SftpFileSystemAccessor accessor = getFileSystemAccessor();
-            return accessor.resolveFileOwner(getServerSession(), this, file, name);
+            return accessor.resolveFileOwner(this, file, name);
         } catch (IOException e) {
             handleUserPrincipalLookupServiceException(UserPrincipal.class, name.toString(), e);
             return null;
@@ -3006,12 +2990,10 @@ public abstract class AbstractSftpSubsystemHelper
      */
     protected Path resolveFile(String remotePath)
             throws IOException, InvalidPathException {
-        ServerSession serverSession = getServerSession();
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
-        Path localPath = accessor.resolveLocalFilePath(
-                serverSession, this, getDefaultDirectory(), remotePath);
+        Path localPath = accessor.resolveLocalFilePath(this, getDefaultDirectory(), remotePath);
         if (log.isTraceEnabled()) {
-            log.trace("resolveFile({}) {} => {}", serverSession, remotePath, localPath);
+            log.trace("resolveFile({}) {} => {}", getServerSession(), remotePath, localPath);
         }
         return localPath;
     }
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/DirectoryHandle.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/DirectoryHandle.java
index 4a8dd9a..a6a55a6 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/DirectoryHandle.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/DirectoryHandle.java
@@ -23,8 +23,6 @@ import java.nio.file.DirectoryStream;
 import java.nio.file.Path;
 import java.util.Iterator;
 
-import org.apache.sshd.server.session.ServerSession;
-
 /**
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
@@ -40,9 +38,8 @@ public class DirectoryHandle extends Handle implements Iterator<Path> {
         super(subsystem, dir, handle);
 
         SftpFileSystemAccessor accessor = subsystem.getFileSystemAccessor();
-        ServerSession session = subsystem.getServerSession();
         signalHandleOpening();
-        ds = accessor.openDirectory(session, subsystem, this, dir, handle);
+        ds = accessor.openDirectory(subsystem, this, dir, handle);
 
         Path parent = dir.getParent();
         if (parent == null) {
@@ -104,8 +101,7 @@ public class DirectoryHandle extends Handle implements Iterator<Path> {
         try {
             SftpSubsystem subsystem = getSubsystem();
             SftpFileSystemAccessor accessor = subsystem.getFileSystemAccessor();
-            ServerSession session = subsystem.getServerSession();
-            accessor.closeDirectory(session, subsystem, this, getFile(), getFileHandle(), ds);
+            accessor.closeDirectory(subsystem, this, getFile(), getFileHandle(), ds);
         } finally {
             super.close();
             markDone(); // just making sure
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/FileHandle.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/FileHandle.java
index b583054..9458555 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/FileHandle.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/FileHandle.java
@@ -39,7 +39,6 @@ import java.util.concurrent.atomic.AtomicReference;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.MapEntryUtils;
 import org.apache.sshd.common.util.io.IoUtils;
-import org.apache.sshd.server.session.ServerSession;
 import org.apache.sshd.sftp.common.SftpConstants;
 import org.apache.sshd.sftp.common.SftpException;
 
@@ -79,14 +78,13 @@ public class FileHandle extends Handle {
                 : fileAttributes.toArray(new FileAttribute<?>[fileAttributes.size()]);
 
         SftpFileSystemAccessor accessor = subsystem.getFileSystemAccessor();
-        ServerSession session = subsystem.getServerSession();
         SeekableByteChannel channel;
         try {
             channel = accessor.openFile(
-                    session, subsystem, this, file, handle, openOptions, fileAttrs);
+                    subsystem, this, file, handle, openOptions, fileAttrs);
         } catch (UnsupportedOperationException e) {
             channel = accessor.openFile(
-                    session, subsystem, this, file, handle, openOptions, IoUtils.EMPTY_FILE_ATTRIBUTES);
+                    subsystem, this, file, handle, openOptions, IoUtils.EMPTY_FILE_ATTRIBUTES);
             subsystem.doSetAttributes(SftpConstants.SSH_FXP_OPEN, "", file, attrs, false);
         }
         this.fileChannel = channel;
@@ -163,8 +161,7 @@ public class FileHandle extends Handle {
 
         SftpSubsystem subsystem = getSubsystem();
         SftpFileSystemAccessor accessor = subsystem.getFileSystemAccessor();
-        ServerSession session = subsystem.getServerSession();
-        accessor.closeFile(session, subsystem, this, getFile(), getFileHandle(), getFileChannel(), getOpenOptions());
+        accessor.closeFile(subsystem, this, getFile(), getFileHandle(), getFileChannel(), getOpenOptions());
     }
 
     public void lock(long offset, long length, int mask) throws IOException {
@@ -172,9 +169,8 @@ public class FileHandle extends Handle {
         long size = (length == 0L) ? channel.size() - offset : length;
         SftpSubsystem subsystem = getSubsystem();
         SftpFileSystemAccessor accessor = subsystem.getFileSystemAccessor();
-        ServerSession session = subsystem.getServerSession();
         FileLock lock = accessor.tryLock(
-                session, subsystem, this, getFile(), getFileHandle(), channel, offset, size, false);
+                subsystem, this, getFile(), getFileHandle(), channel, offset, size, false);
         if (lock == null) {
             throw new SftpException(
                     SftpConstants.SSH_FX_BYTE_RANGE_LOCK_REFUSED,
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpFileSystemAccessor.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpFileSystemAccessor.java
index 369aa9c..8360312 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpFileSystemAccessor.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpFileSystemAccessor.java
@@ -59,7 +59,6 @@ import org.apache.sshd.common.util.SelectorUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.io.FileInfoExtractor;
 import org.apache.sshd.common.util.io.IoUtils;
-import org.apache.sshd.server.session.ServerSession;
 
 /**
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
@@ -98,7 +97,6 @@ public interface SftpFileSystemAccessor {
     /**
      * Invoked in order to resolve remote file paths reference by the client into ones accessible by the server
      *
-     * @param  session              The {@link ServerSession} through which the request was received
      * @param  subsystem            The SFTP subsystem instance that manages the session
      * @param  rootDir              The default root directory used to resolve relative paths - a.k.a. the
      *                              {@code chroot} location
@@ -110,7 +108,7 @@ public interface SftpFileSystemAccessor {
      *                              SftpSubsystemEnvironment#getDefaultDirectory()
      */
     default Path resolveLocalFilePath(
-            ServerSession session, SftpSubsystemProxy subsystem, Path rootDir, String remotePath)
+            SftpSubsystemProxy subsystem, Path rootDir, String remotePath)
             throws IOException, InvalidPathException {
         String path = SelectorUtils.translateToLocalFileSystemPath(
                 remotePath, '/', rootDir.getFileSystem());
@@ -120,7 +118,6 @@ public interface SftpFileSystemAccessor {
     /**
      * Invoked in order to determine the symbolic link follow options
      *
-     * @param  session     The {@link ServerSession} through which the request was received
      * @param  subsystem   The SFTP subsystem instance that manages the session
      * @param  file        The referenced file
      * @param  cmd         The SFTP command that triggered this access
@@ -131,8 +128,7 @@ public interface SftpFileSystemAccessor {
      * @see                <A HREF="https://issues.apache.org/jira/browse/SSHD-1137">SSHD-1137</A>
      */
     default LinkOption[] resolveFileAccessLinkOptions(
-            ServerSession session, SftpSubsystemProxy subsystem, Path file,
-            int cmd, String extension, boolean followLinks)
+            SftpSubsystemProxy subsystem, Path file, int cmd, String extension, boolean followLinks)
             throws IOException {
         return IoUtils.getLinkOptions(followLinks);
     }
@@ -140,7 +136,6 @@ public interface SftpFileSystemAccessor {
     /**
      * Invoked in order to encode the outgoing referenced file name/path
      *
-     * @param  session     The {@link ServerSession} through which the request was received
      * @param  subsystem   The SFTP subsystem instance that manages the session
      * @param  path        The associated file {@link Path} - <B>Note:</B> might be a symbolic link container
      * @param  buf         The target {@link Buffer} for the encoded string
@@ -151,7 +146,7 @@ public interface SftpFileSystemAccessor {
      * @see                <A HREF="https://issues.apache.org/jira/browse/SSHD-1132">SSHD-1132</A>
      */
     default void putRemoteFileName(
-            ServerSession session, SftpSubsystemProxy subsystem, Path path, Buffer buf, String name, boolean shortName)
+            SftpSubsystemProxy subsystem, Path path, Buffer buf, String name, boolean shortName)
             throws IOException {
         buf.putString(name);
     }
@@ -159,13 +154,11 @@ public interface SftpFileSystemAccessor {
     /**
      * Called whenever a new file is opened
      *
-     * @param  session     The {@link ServerSession} through which the request was received
      * @param  subsystem   The SFTP subsystem instance that manages the session
      * @param  fileHandle  The {@link FileHandle} representing the created channel - may be {@code null} if not invoked
      *                     within the context of such a handle (special cases)
      * @param  file        The requested <U>local</U> file {@link Path} - same one returned by
-     *                     {@link #resolveLocalFilePath(ServerSession, SftpSubsystemProxy, Path, String)
-     *                     resolveLocalFilePath}
+     *                     {@link #resolveLocalFilePath(SftpSubsystemProxy, Path, String) resolveLocalFilePath}
      * @param  handle      The assigned file handle through which the remote peer references this file. May be
      *                     {@code null}/empty if the request is due to some internal functionality instead of due to
      *                     peer requesting a handle to a file.
@@ -175,8 +168,8 @@ public interface SftpFileSystemAccessor {
      * @throws IOException If failed to open
      */
     default SeekableByteChannel openFile(
-            ServerSession session, SftpSubsystemProxy subsystem, FileHandle fileHandle,
-            Path file, String handle, Set<? extends OpenOption> options, FileAttribute<?>... attrs)
+            SftpSubsystemProxy subsystem, FileHandle fileHandle, Path file,
+            String handle, Set<? extends OpenOption> options, FileAttribute<?>... attrs)
             throws IOException {
         /*
          * According to https://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#page-33
@@ -193,15 +186,13 @@ public interface SftpFileSystemAccessor {
     /**
      * Called when locking a section of a file is requested
      *
-     * @param  session     The {@link ServerSession} through which the request was received
      * @param  subsystem   The SFTP subsystem instance that manages the session
      * @param  fileHandle  The {@link FileHandle} representing the created channel
      * @param  file        The requested <U>local</U> file {@link Path} - same one returned by
-     *                     {@link #resolveLocalFilePath(ServerSession, SftpSubsystemProxy, Path, String)
-     *                     resolveLocalFilePath}
+     *                     {@link #resolveLocalFilePath(SftpSubsystemProxy, Path, String) resolveLocalFilePath}
      * @param  handle      The assigned file handle through which the remote peer references this file
      * @param  channel     The original {@link Channel} that was returned by
-     *                     {@link #openFile(ServerSession, SftpSubsystemProxy, FileHandle, Path, String, Set, FileAttribute...)}
+     *                     {@link #openFile(SftpSubsystemProxy, FileHandle, Path, String, Set, FileAttribute...)}
      * @param  position    The position at which the locked region is to start - must be non-negative
      * @param  size        The size of the locked region; must be non-negative, and the sum
      *                     <tt>position</tt>&nbsp;+&nbsp;<tt>size</tt> must be non-negative
@@ -213,8 +204,8 @@ public interface SftpFileSystemAccessor {
      */
     @SuppressWarnings("checkstyle:ParameterNumber")
     default FileLock tryLock(
-            ServerSession session, SftpSubsystemProxy subsystem, FileHandle fileHandle,
-            Path file, String handle, Channel channel, long position, long size, boolean shared)
+            SftpSubsystemProxy subsystem, FileHandle fileHandle, Path file, String handle,
+            Channel channel, long position, long size, boolean shared)
             throws IOException {
         if (!(channel instanceof FileChannel)) {
             throw new StreamCorruptedException("Non file channel to lock: " + channel);
@@ -226,23 +217,20 @@ public interface SftpFileSystemAccessor {
     /**
      * Called when file meta-data re-synchronization is required
      *
-     * @param  session     The {@link ServerSession} through which the request was received
      * @param  subsystem   The SFTP subsystem instance that manages the session
      * @param  fileHandle  The {@link FileHandle} representing the created channel
      * @param  file        The requested <U>local</U> file {@link Path} - same one returned by
-     *                     {@link #resolveLocalFilePath(ServerSession, SftpSubsystemProxy, Path, String)
-     *                     resolveLocalFilePath}
+     *                     {@link #resolveLocalFilePath(SftpSubsystemProxy, Path, String) resolveLocalFilePath}
      * @param  handle      The assigned file handle through which the remote peer references this file
      * @param  channel     The original {@link Channel} that was returned by
-     *                     {@link #openFile(ServerSession, SftpSubsystemProxy, FileHandle, Path, String, Set, FileAttribute...)}
+     *                     {@link #openFile(SftpSubsystemProxy, FileHandle, Path, String, Set, FileAttribute...)}
      * @throws IOException If failed to execute the request
      * @see                FileChannel#force(boolean)
      * @see                <A HREF="https://github.com/openssh/openssh-portable/blob/master/PROTOCOL">OpenSSH - section
      *                     10</A>
      */
     default void syncFileData(
-            ServerSession session, SftpSubsystemProxy subsystem, FileHandle fileHandle, Path file, String handle,
-            Channel channel)
+            SftpSubsystemProxy subsystem, FileHandle fileHandle, Path file, String handle, Channel channel)
             throws IOException {
         if (!(channel instanceof FileChannel)) {
             throw new StreamCorruptedException("Non file channel to sync: " + channel);
@@ -254,22 +242,20 @@ public interface SftpFileSystemAccessor {
     /**
      * Called to inform the accessor that it should close the file
      *
-     * @param  session     The {@link ServerSession} through which the request was received
      * @param  subsystem   The SFTP subsystem instance that manages the session
      * @param  fileHandle  The {@link FileHandle} representing the created channel - may be {@code null} if not invoked
      *                     within the context of such a handle (special cases)
      * @param  file        The requested <U>local</U> file {@link Path} - same one returned by
-     *                     {@link #resolveLocalFilePath(ServerSession, SftpSubsystemProxy, Path, String)
-     *                     resolveLocalFilePath}
+     *                     {@link #resolveLocalFilePath(SftpSubsystemProxy, Path, String) resolveLocalFilePath}
      * @param  handle      The assigned file handle through which the remote peer references this file
      * @param  channel     The original {@link Channel} that was returned by
-     *                     {@link #openFile(ServerSession, SftpSubsystemProxy, FileHandle, Path, String, Set, FileAttribute...)}
+     *                     {@link #openFile(SftpSubsystemProxy, FileHandle, Path, String, Set, FileAttribute...)}
      * @param  options     The original options used to open the channel
      * @throws IOException If failed to execute the request
      */
     default void closeFile(
-            ServerSession session, SftpSubsystemProxy subsystem, FileHandle fileHandle,
-            Path file, String handle, Channel channel, Set<? extends OpenOption> options)
+            SftpSubsystemProxy subsystem, FileHandle fileHandle, Path file,
+            String handle, Channel channel, Set<? extends OpenOption> options)
             throws IOException {
         if ((channel == null) || (!channel.isOpen())) {
             return;
@@ -278,7 +264,7 @@ public interface SftpFileSystemAccessor {
         if ((channel instanceof FileChannel)
                 && GenericUtils.containsAny(options, IoUtils.WRITEABLE_OPEN_OPTIONS)
                 && PropertyResolverUtils.getBooleanProperty(
-                        session, PROP_AUTO_SYNC_FILE_ON_CLOSE, DEFAULT_AUTO_SYNC_FILE_ON_CLOSE)) {
+                        subsystem.getSession(), PROP_AUTO_SYNC_FILE_ON_CLOSE, DEFAULT_AUTO_SYNC_FILE_ON_CLOSE)) {
             ((FileChannel) channel).force(true);
         }
 
@@ -288,18 +274,16 @@ public interface SftpFileSystemAccessor {
     /**
      * Called when a new directory stream is requested
      *
-     * @param  session     The {@link ServerSession} through which the request was received
      * @param  subsystem   The SFTP subsystem instance that manages the session
      * @param  dirHandle   The {@link DirectoryHandle} representing the stream
      * @param  dir         The requested <U>local</U> directory {@link Path} - same one returned by
-     *                     {@link #resolveLocalFilePath(ServerSession, SftpSubsystemProxy, Path, String)
-     *                     resolveLocalFilePath}
+     *                     {@link #resolveLocalFilePath(SftpSubsystemProxy, Path, String) resolveLocalFilePath}
      * @param  handle      The assigned directory handle through which the remote peer references this directory
      * @return             The opened {@link DirectoryStream}
      * @throws IOException If failed to open
      */
     default DirectoryStream<Path> openDirectory(
-            ServerSession session, SftpSubsystemProxy subsystem, DirectoryHandle dirHandle, Path dir, String handle)
+            SftpSubsystemProxy subsystem, DirectoryHandle dirHandle, Path dir, String handle)
             throws IOException {
         return Files.newDirectoryStream(dir);
     }
@@ -307,19 +291,17 @@ public interface SftpFileSystemAccessor {
     /**
      * Called when a directory stream is no longer required
      *
-     * @param  session     The {@link ServerSession} through which the request was received
      * @param  subsystem   The SFTP subsystem instance that manages the session
      * @param  dirHandle   The {@link DirectoryHandle} representing the stream - may be {@code null} if not invoked
      *                     within the context of such a handle (special cases)
      * @param  dir         The requested <U>local</U> directory {@link Path} - same one returned by
-     *                     {@link #resolveLocalFilePath(ServerSession, SftpSubsystemProxy, Path, String)
-     *                     resolveLocalFilePath}
+     *                     {@link #resolveLocalFilePath(SftpSubsystemProxy, Path, String) resolveLocalFilePath}
      * @param  handle      The assigned directory handle through which the remote peer references this directory
      * @param  ds          The disposed {@link DirectoryStream}
      * @throws IOException If failed to open
      */
     default void closeDirectory(
-            ServerSession session, SftpSubsystemProxy subsystem, DirectoryHandle dirHandle,
+            SftpSubsystemProxy subsystem, DirectoryHandle dirHandle,
             Path dir, String handle, DirectoryStream<Path> ds)
             throws IOException {
         if (ds == null) {
@@ -332,11 +314,9 @@ public interface SftpFileSystemAccessor {
     /**
      * Invoked when required to retrieve file attributes for a specific file system view
      *
-     * @param  session     The {@link ServerSession} through which the request was received
      * @param  subsystem   The SFTP subsystem instance that manages the session
      * @param  file        The requested <U>local</U> file {@link Path} - same one returned by
-     *                     {@link #resolveLocalFilePath(ServerSession, SftpSubsystemProxy, Path, String)
-     *                     resolveLocalFilePath}
+     *                     {@link #resolveLocalFilePath(SftpSubsystemProxy, Path, String) resolveLocalFilePath}
      * @param  view        The required view name
      * @param  options     The access {@link LinkOption}-s
      * @return             A {@link Map} of all the attributes available for the file in the view
@@ -344,8 +324,7 @@ public interface SftpFileSystemAccessor {
      * @see                Files#readAttributes(Path, String, LinkOption...)
      */
     default Map<String, ?> readFileAttributes(
-            ServerSession session, SftpSubsystemProxy subsystem,
-            Path file, String view, LinkOption... options)
+            SftpSubsystemProxy subsystem, Path file, String view, LinkOption... options)
             throws IOException {
         return Files.readAttributes(file, view, options);
     }
@@ -353,11 +332,9 @@ public interface SftpFileSystemAccessor {
     /**
      * Sets a view attribute for a local file
      *
-     * @param  session     The {@link ServerSession} through which the request was received
      * @param  subsystem   The SFTP subsystem instance that manages the session
      * @param  file        The requested <U>local</U> file {@link Path} - same one returned by
-     *                     {@link #resolveLocalFilePath(ServerSession, SftpSubsystemProxy, Path, String)
-     *                     resolveLocalFilePath}
+     *                     {@link #resolveLocalFilePath(SftpSubsystemProxy, Path, String) resolveLocalFilePath}
      * @param  view        The required view name
      * @param  attribute   The attribute name
      * @param  value       The attribute value
@@ -365,8 +342,8 @@ public interface SftpFileSystemAccessor {
      * @throws IOException If failed to set the attribute
      */
     default void setFileAttribute(
-            ServerSession session, SftpSubsystemProxy subsystem, Path file,
-            String view, String attribute, Object value, LinkOption... options)
+            SftpSubsystemProxy subsystem, Path file, String view,
+            String attribute, Object value, LinkOption... options)
             throws IOException {
         if (value == null) {
             return;
@@ -376,7 +353,7 @@ public interface SftpFileSystemAccessor {
     }
 
     default UserPrincipal resolveFileOwner(
-            ServerSession session, SftpSubsystemProxy subsystem, Path file, UserPrincipal name)
+            SftpSubsystemProxy subsystem, Path file, UserPrincipal name)
             throws IOException {
         FileSystem fileSystem = file.getFileSystem();
         UserPrincipalLookupService lookupService = fileSystem.getUserPrincipalLookupService();
@@ -390,8 +367,7 @@ public interface SftpFileSystemAccessor {
     }
 
     default void setFileOwner(
-            ServerSession session, SftpSubsystemProxy subsystem, Path file,
-            Principal value, LinkOption... options)
+            SftpSubsystemProxy subsystem, Path file, Principal value, LinkOption... options)
             throws IOException {
         if (value == null) {
             return;
@@ -411,7 +387,7 @@ public interface SftpFileSystemAccessor {
     }
 
     default GroupPrincipal resolveGroupOwner(
-            ServerSession session, SftpSubsystemProxy subsystem, Path file, GroupPrincipal name)
+            SftpSubsystemProxy subsystem, Path file, GroupPrincipal name)
             throws IOException {
         FileSystem fileSystem = file.getFileSystem();
         UserPrincipalLookupService lookupService = fileSystem.getUserPrincipalLookupService();
@@ -424,8 +400,7 @@ public interface SftpFileSystemAccessor {
     }
 
     default void setGroupOwner(
-            ServerSession session, SftpSubsystemProxy subsystem,
-            Path file, Principal value, LinkOption... options)
+            SftpSubsystemProxy subsystem, Path file, Principal value, LinkOption... options)
             throws IOException {
         if (value == null) {
             return;
@@ -445,8 +420,7 @@ public interface SftpFileSystemAccessor {
     }
 
     default void setFilePermissions(
-            ServerSession session, SftpSubsystemProxy subsystem, Path file,
-            Set<PosixFilePermission> perms, LinkOption... options)
+            SftpSubsystemProxy subsystem, Path file, Set<PosixFilePermission> perms, LinkOption... options)
             throws IOException {
         if (OsUtils.isWin32()) {
             IoUtils.setPermissionsToFile(file.toFile(), perms);
@@ -462,8 +436,7 @@ public interface SftpFileSystemAccessor {
     }
 
     default void setFileAccessControl(
-            ServerSession session, SftpSubsystemProxy subsystem,
-            Path file, List<AclEntry> acl, LinkOption... options)
+            SftpSubsystemProxy subsystem, Path file, List<AclEntry> acl, LinkOption... options)
             throws IOException {
         AclFileAttributeView view = Files.getFileAttributeView(file, AclFileAttributeView.class, options);
         if (view == null) {
@@ -473,20 +446,16 @@ public interface SftpFileSystemAccessor {
         view.setAcl(acl);
     }
 
-    default void createDirectory(
-            ServerSession session, SftpSubsystemProxy subsystem, Path path)
-            throws IOException {
+    default void createDirectory(SftpSubsystemProxy subsystem, Path path) throws IOException {
         Files.createDirectory(path);
     }
 
     /**
      * Invoked in order to create a link to a path
      *
-     * @param  session     The {@link ServerSession} through which the request was received
      * @param  subsystem   The SFTP subsystem instance that manages the session
      * @param  link        The requested <U>link</U> {@link Path} - same one returned by
-     *                     {@link #resolveLocalFilePath(ServerSession, SftpSubsystemProxy, Path, String)
-     *                     resolveLocalFilePath}
+     *                     {@link #resolveLocalFilePath(SftpSubsystemProxy, Path, String) resolveLocalFilePath}
      * @param  existing    The <U>existing</U> {@link Path} that the link should reference
      * @param  symLink     {@code true} if this should be a symbolic link
      * @throws IOException If failed to create the link
@@ -494,7 +463,7 @@ public interface SftpFileSystemAccessor {
      * @see                Files#createSymbolicLink(Path, Path, FileAttribute...)
      */
     default void createLink(
-            ServerSession session, SftpSubsystemProxy subsystem, Path link, Path existing, boolean symLink)
+            SftpSubsystemProxy subsystem, Path link, Path existing, boolean symLink)
             throws IOException {
         if (symLink) {
             Files.createSymbolicLink(link, existing);
@@ -503,16 +472,13 @@ public interface SftpFileSystemAccessor {
         }
     }
 
-    default String resolveLinkTarget(
-            ServerSession session, SftpSubsystemProxy subsystem, Path link)
-            throws IOException {
+    default String resolveLinkTarget(SftpSubsystemProxy subsystem, Path link) throws IOException {
         Path target = Files.readSymbolicLink(link);
         return target.toString();
     }
 
     default void renameFile(
-            ServerSession session, SftpSubsystemProxy subsystem,
-            Path oldPath, Path newPath, Collection<CopyOption> opts)
+            SftpSubsystemProxy subsystem, Path oldPath, Path newPath, Collection<CopyOption> opts)
             throws IOException {
         Files.move(oldPath, newPath,
                 GenericUtils.isEmpty(opts)
@@ -521,8 +487,7 @@ public interface SftpFileSystemAccessor {
     }
 
     default void copyFile(
-            ServerSession session, SftpSubsystemProxy subsystem,
-            Path src, Path dst, Collection<CopyOption> opts)
+            SftpSubsystemProxy subsystem, Path src, Path dst, Collection<CopyOption> opts)
             throws IOException {
         Files.copy(src, dst,
                 GenericUtils.isEmpty(opts)
@@ -531,7 +496,7 @@ public interface SftpFileSystemAccessor {
     }
 
     default void removeFile(
-            ServerSession session, SftpSubsystemProxy subsystem, Path path, boolean isDirectory)
+            SftpSubsystemProxy subsystem, Path path, boolean isDirectory)
             throws IOException {
         Files.delete(path);
     }
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpSubsystem.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpSubsystem.java
index eac48fe..d985c5d 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpSubsystem.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpSubsystem.java
@@ -346,7 +346,7 @@ public class SftpSubsystem
         listener.linking(session, link, existing, symLink);
         try {
             SftpFileSystemAccessor accessor = getFileSystemAccessor();
-            accessor.createLink(session, this, link, existing, symLink);
+            accessor.createLink(this, link, existing, symLink);
         } catch (IOException | RuntimeException | Error e) {
             listener.linked(session, link, existing, symLink, e);
             throw e;
@@ -369,15 +369,14 @@ public class SftpSubsystem
     @Override
     protected void doOpenSSHFsync(int id, String handle) throws IOException {
         Handle h = handles.get(handle);
-        ServerSession session = getServerSession();
         if (log.isDebugEnabled()) {
-            log.debug("doOpenSSHFsync({})[id={}] {}[{}]", session, id, handle, h);
+            log.debug("doOpenSSHFsync({})[id={}] {}[{}]", getServerSession(), id, handle, h);
         }
 
         FileHandle fileHandle = validateHandle(handle, h, FileHandle.class);
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
         accessor.syncFileData(
-                session, this, fileHandle, fileHandle.getFile(),
+                this, fileHandle, fileHandle.getFile(),
                 fileHandle.getFileHandle(), fileHandle.getFileChannel());
     }
 
@@ -425,7 +424,7 @@ public class SftpSubsystem
 
             SftpFileSystemAccessor accessor = getFileSystemAccessor();
             LinkOption[] options = accessor.resolveFileAccessLinkOptions(
-                    getServerSession(), this, path, SftpConstants.SSH_FXP_EXTENDED, targetType, false);
+                    this, path, SftpConstants.SSH_FXP_EXTENDED, targetType, false);
             if (Files.isDirectory(path, options)) {
                 throw new NotDirectoryException(path.toString());
             }
@@ -449,10 +448,9 @@ public class SftpSubsystem
     protected byte[] doMD5Hash(
             int id, String targetType, String target, long startOffset, long length, byte[] quickCheckHash)
             throws Exception {
-        ServerSession session = getServerSession();
         if (log.isDebugEnabled()) {
             log.debug("doMD5Hash({})({})[{}] offset={}, length={}, quick-hash={}",
-                    session, targetType, target, startOffset, length,
+                    getServerSession(), targetType, target, startOffset, length,
                     BufferUtils.toHex(':', quickCheckHash));
         }
 
@@ -478,7 +476,7 @@ public class SftpSubsystem
 
             SftpFileSystemAccessor accessor = getFileSystemAccessor();
             LinkOption[] options = accessor.resolveFileAccessLinkOptions(
-                    session, this, path, SftpConstants.SSH_FXP_EXTENDED, targetType, true);
+                    this, path, SftpConstants.SSH_FXP_EXTENDED, targetType, true);
             if (Files.isDirectory(path, options)) {
                 throw new NotDirectoryException(path.toString());
             }
@@ -805,17 +803,16 @@ public class SftpSubsystem
     @Override
     protected Map<String, Object> doFStat(int id, String handle, int flags) throws IOException {
         Handle h = handles.get(handle);
-        ServerSession session = getServerSession();
         if (log.isDebugEnabled()) {
             log.debug("doFStat({})[id={}] SSH_FXP_FSTAT (handle={}[{}], flags=0x{})",
-                    session, id, handle, h, Integer.toHexString(flags));
+                    getServerSession(), id, handle, h, Integer.toHexString(flags));
         }
 
         Handle fileHandle = validateHandle(handle, h, Handle.class);
         SftpFileSystemAccessor accessor = getFileSystemAccessor();
         Path file = fileHandle.getFile();
         LinkOption[] options = accessor.resolveFileAccessLinkOptions(
-                session, this, file, SftpConstants.SSH_FXP_FSTAT, "", true);
+                this, file, SftpConstants.SSH_FXP_FSTAT, "", true);
         return resolveFileAttributes(file, flags, options);
     }
 
diff --git a/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/SftpTest.java b/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/SftpTest.java
index 4232dc6..35422f8 100644
--- a/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/SftpTest.java
+++ b/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/SftpTest.java
@@ -618,21 +618,20 @@ public class SftpTest extends AbstractSftpClientTestSupport {
             factory.setFileSystemAccessor(new SftpFileSystemAccessor() {
                 @Override
                 public SeekableByteChannel openFile(
-                        ServerSession session, SftpSubsystemProxy subsystem, FileHandle fileHandle, Path file,
+                        SftpSubsystemProxy subsystem, FileHandle fileHandle, Path file,
                         String handle, Set<? extends OpenOption> options, FileAttribute<?>... attrs)
                         throws IOException {
                     fileHolder.set(file);
                     return SftpFileSystemAccessor.super.openFile(
-                            session, subsystem, fileHandle, file, handle, options, attrs);
+                            subsystem, fileHandle, file, handle, options, attrs);
                 }
 
                 @Override
                 public DirectoryStream<Path> openDirectory(
-                        ServerSession session, SftpSubsystemProxy subsystem,
-                        DirectoryHandle dirHandle, Path dir, String handle)
+                        SftpSubsystemProxy subsystem, DirectoryHandle dirHandle, Path dir, String handle)
                         throws IOException {
                     dirHolder.set(dir);
-                    return SftpFileSystemAccessor.super.openDirectory(session, subsystem, dirHandle, dir, handle);
+                    return SftpFileSystemAccessor.super.openDirectory(subsystem, dirHandle, dir, handle);
                 }
 
                 @Override