Skip to content

Commit

Permalink
enable root to tail (all) files via sftp
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Nüssgens committed Apr 20, 2022
1 parent 0bb71d1 commit 06b5216
Showing 1 changed file with 43 additions and 23 deletions.
66 changes: 43 additions & 23 deletions olv-vfs/src/main/java/pl/otros/vfs/browser/util/VFSUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,38 @@
*/
package pl.otros.vfs.browser.util;

import com.google.common.base.Joiner;
import com.google.common.base.Throwables;
import com.jcraft.jsch.JSchException;
import jcifs.smb.SmbAuthException;
import net.sf.vfsjfilechooser.utils.VFSURIParser;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.Icon;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.vfs2.*;
import org.apache.commons.vfs2.CacheStrategy;
import org.apache.commons.vfs2.FileContent;
import org.apache.commons.vfs2.FileName;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.FileSystemManager;
import org.apache.commons.vfs2.FileSystemOptions;
import org.apache.commons.vfs2.FileType;
import org.apache.commons.vfs2.UserAuthenticationData;
import org.apache.commons.vfs2.UserAuthenticationData.Type;
import org.apache.commons.vfs2.impl.DefaultFileSystemConfigBuilder;
import org.apache.commons.vfs2.impl.StandardFileSystemManager;
Expand All @@ -33,26 +56,22 @@
import org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Joiner;
import com.google.common.base.Throwables;
import com.jcraft.jsch.JSchException;
import jcifs.smb.SmbAuthException;
import net.sf.vfsjfilechooser.utils.VFSURIParser;
import pl.otros.vfs.browser.Icons;
import pl.otros.vfs.browser.LinkFileObject;
import pl.otros.vfs.browser.TaskContext;
import pl.otros.vfs.browser.auth.*;

import javax.swing.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import pl.otros.vfs.browser.auth.AuthStore;
import pl.otros.vfs.browser.auth.AuthStoreUtils;
import pl.otros.vfs.browser.auth.MemoryAuthStore;
import pl.otros.vfs.browser.auth.OtrosUserAuthenticator;
import pl.otros.vfs.browser.auth.StaticPasswordProvider;
import pl.otros.vfs.browser.auth.UserAuthenticationDataWrapper;
import pl.otros.vfs.browser.auth.UserAuthenticationInfo;
import pl.otros.vfs.browser.auth.UserAuthenticatorFactory;

/**
* A helper class to deal with commons-vfs file abstractions
Expand Down Expand Up @@ -336,6 +355,7 @@ public static FileObject resolveFileObject(String filePath, FileSystemOptions op
builder.setUserDirIsRoot(opts, false);
builder.setCompression(opts, "zlib,none");
builder.setSessionTimeout(opts, Duration.ofSeconds(5));
builder.setDisableDetectExecChannel(opts, true); // see https://issues.apache.org/jira/browse/VFS-818
}

DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, authenticator);
Expand Down

0 comments on commit 06b5216

Please sign in to comment.