public class SftpFileSystemProvider extends FileSystemProvider
FileSystemProvider
that registers the "sftp://" scheme so that URLs with this protocol
are handled as remote SFTP Path
-s - e.g., "sftp://user:password@host/remote/file/path
"Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
log |
static Set<Class<? extends FileAttributeView>> |
UNIVERSAL_SUPPORTED_VIEWS |
static String |
VERSION_PARAM
URI parameter that can be used to specify a special version selection.
|
Constructor and Description |
---|
SftpFileSystemProvider() |
SftpFileSystemProvider(SftpVersionSelector selector) |
SftpFileSystemProvider(SshClient client) |
SftpFileSystemProvider(SshClient client,
SftpClientFactory factory,
SftpVersionSelector selector) |
SftpFileSystemProvider(SshClient client,
SftpClientFactory factory,
SftpVersionSelector selector,
SftpErrorDataHandler errorDataHandler) |
SftpFileSystemProvider(SshClient client,
SftpVersionSelector selector) |
SftpFileSystemProvider(SshClient client,
SftpVersionSelector selector,
SftpErrorDataHandler errorDataHandler) |
createLink, deleteIfExists, installedProviders, newAsynchronousFileChannel, newFileSystem
public static final String VERSION_PARAM
URI parameter that can be used to specify a special version selection. Options are:
max
- select maximum available version for the clientmin
- select minimum available version for the clientcurrent
- whatever version is reported by the servernnn
- select only the specified versiona,b,c
- select one of the specified versions (if available) in preference orderpublic static final Set<Class<? extends FileAttributeView>> UNIVERSAL_SUPPORTED_VIEWS
protected final org.slf4j.Logger log
public SftpFileSystemProvider()
public SftpFileSystemProvider(SftpVersionSelector selector)
public SftpFileSystemProvider(SshClient client)
public SftpFileSystemProvider(SshClient client, SftpVersionSelector selector)
public SftpFileSystemProvider(SshClient client, SftpVersionSelector selector, SftpErrorDataHandler errorDataHandler)
public SftpFileSystemProvider(SshClient client, SftpClientFactory factory, SftpVersionSelector selector)
public SftpFileSystemProvider(SshClient client, SftpClientFactory factory, SftpVersionSelector selector, SftpErrorDataHandler errorDataHandler)
client
- The SshClient
to use - if null
then a default one will be setup and
started. Otherwise, it is assumed that the client has already been startedfactory
- The SftpClientFactory
to use to generate SFTP client instancesselector
- The SftpVersionSelector
to use in order to negotiate the SFTP versionerrorDataHandler
- The SftpErrorDataHandler
to handle incoming data through the error stream - if
null
the data is silently ignoredSshClient.setUpDefaultClient()
public String getScheme()
getScheme
in class FileSystemProvider
public final SftpVersionSelector getSftpVersionSelector()
public SftpErrorDataHandler getSftpErrorDataHandler()
public final SshClient getClientInstance()
public SftpClientFactory getSftpClientFactory()
public SftpFileSystemClientSessionInitializer getSftpFileSystemClientSessionInitializer()
public void setSftpFileSystemClientSessionInitializer(SftpFileSystemClientSessionInitializer initializer)
public SftpFileSystem newFileSystem(URI uri, Map<String,?> env) throws IOException
newFileSystem
in class FileSystemProvider
IOException
protected SftpVersionSelector resolveSftpVersionSelector(URI uri, SftpVersionSelector defaultSelector, PropertyResolver resolver)
protected SftpErrorDataHandler resolveSftpErrorDataHandler(URI uri, SftpErrorDataHandler errorHandler, PropertyResolver resolver)
public static Map<String,Object> resolveFileSystemParameters(Map<String,?> env, Map<String,Object> uriParams)
public static MutableBasicCredentials parseCredentials(URI uri)
public static MutableBasicCredentials parseCredentials(String userInfo)
public SftpFileSystem newFileSystem(ClientSession session) throws IOException
IOException
public FileSystem getFileSystem(URI uri)
getFileSystem
in class FileSystemProvider
public SftpFileSystem removeFileSystem(String id)
id
- File system identifier - ignored if null
/emptySftpFileSystem
- null
if no matchpublic SftpFileSystem getFileSystem(String id)
id
- File system identifier - ignored if null
/emptySftpFileSystem
- null
if no matchpublic Path getPath(URI uri)
getPath
in class FileSystemProvider
public FileChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
newByteChannel
in class FileSystemProvider
IOException
public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
newFileChannel
in class FileSystemProvider
IOException
public InputStream newInputStream(Path path, OpenOption... options) throws IOException
newInputStream
in class FileSystemProvider
IOException
public OutputStream newOutputStream(Path path, OpenOption... options) throws IOException
newOutputStream
in class FileSystemProvider
IOException
public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException
newDirectoryStream
in class FileSystemProvider
IOException
public void createDirectory(Path dir, FileAttribute<?>... attrs) throws IOException
createDirectory
in class FileSystemProvider
IOException
public void delete(Path path) throws IOException
delete
in class FileSystemProvider
IOException
public void copy(Path source, Path target, CopyOption... options) throws IOException
copy
in class FileSystemProvider
IOException
public void move(Path source, Path target, CopyOption... options) throws IOException
move
in class FileSystemProvider
IOException
public boolean isSameFile(Path path1, Path path2) throws IOException
isSameFile
in class FileSystemProvider
IOException
public boolean isHidden(Path path) throws IOException
isHidden
in class FileSystemProvider
IOException
public FileStore getFileStore(Path path) throws IOException
getFileStore
in class FileSystemProvider
IOException
public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException
createSymbolicLink
in class FileSystemProvider
IOException
public Path readSymbolicLink(Path link) throws IOException
readSymbolicLink
in class FileSystemProvider
IOException
public void checkAccess(Path path, AccessMode... modes) throws IOException
checkAccess
in class FileSystemProvider
IOException
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options)
getFileAttributeView
in class FileSystemProvider
public boolean isSupportedFileAttributeView(Path path, Class<? extends FileAttributeView> type)
public boolean isSupportedFileAttributeView(SftpFileSystem fs, Class<? extends FileAttributeView> type)
public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException
readAttributes
in class FileSystemProvider
IOException
public Map<String,Object> readAttributes(Path path, String attributes, LinkOption... options) throws IOException
readAttributes
in class FileSystemProvider
IOException
public Map<String,Object> readAttributes(Path path, String view, String attrs, LinkOption... options) throws IOException
IOException
protected Map<String,Object> readCustomViewAttributes(SftpPath path, String view, String attrs, LinkOption... options) throws IOException
IOException
protected NavigableMap<String,Object> readAclViewAttributes(SftpPath path, String view, String attrs, LinkOption... options) throws IOException
IOException
public SftpClient.Attributes readRemoteAttributes(SftpPath path, LinkOption... options) throws IOException
IOException
protected SftpClient.Attributes resolveRemoteFileAttributes(SftpPath path, LinkOption... options) throws IOException
IOException
protected NavigableMap<String,Object> readPosixViewAttributes(SftpPath path, String view, String attrs, LinkOption... options) throws IOException
IOException
public void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException
setAttribute
in class FileSystemProvider
IOException
public void setAttribute(Path path, String view, String attr, Object value, LinkOption... options) throws IOException
IOException
protected int attributesToPermissions(Path path, Collection<PosixFilePermission> perms)
public static String getRWXPermissions(int perms)
public static String getOctalPermissions(int perms)
public static Set<PosixFilePermission> permissionsToAttributes(int perms)
public static String getOctalPermissions(Collection<PosixFilePermission> perms)
public static String getFileSystemIdentifier(URI uri)
uri
- The URI
- Note: not checked to make sure that the scheme is sftp://
getFileSystemIdentifier(String, int, String)
public static String getFileSystemIdentifier(ClientSession session)
session
- The ClientSession
getFileSystemIdentifier(String, int, String)
public static String getFileSystemIdentifier(String host, int port, String username)
public static URI createFileSystemURI(String host, int port, String username, String password)
public static URI createFileSystemURI(String host, int port, String username, String password, Map<String,?> params)
Copyright © 2008–2024 The Apache Software Foundation. All rights reserved.