Top Description Inners Fields Constructors Methods
org.apache.sshd.sftp.client.fs

public Class SftpFileSystemProvider

extends FileSystemProvider
Class Inheritance
Imports
java.io.FilterInputStream, .FilterOutputStream, .IOException, .InputStream, .OutputStream, java.net.InetSocketAddress, .SocketAddress, .URI, .URISyntaxException, java.nio.channels.FileChannel, java.nio.charset.Charset, java.nio.file.AccessDeniedException, .AccessMode, .CopyOption, .DirectoryStream, .FileAlreadyExistsException, .FileStore, .FileSystem, .FileSystemAlreadyExistsException, .FileSystemException, .FileSystemNotFoundException, .LinkOption, .NoSuchFileException, .OpenOption, .Path, .ProviderMismatchException, .StandardCopyOption, java.nio.file.attribute.AclEntry, .AclFileAttributeView, .BasicFileAttributeView, .BasicFileAttributes, .FileAttribute, .FileAttributeView, .FileOwnerAttributeView, .FileTime, .GroupPrincipal, .PosixFileAttributeView, .PosixFileAttributes, .PosixFilePermission, .UserPrincipal, java.nio.file.spi.FileSystemProvider, java.util.Arrays, .Collection, .Collections, .EnumSet, .List, .Map, .NavigableMap, .Objects, .Set, .TreeMap, java.util.concurrent.TimeUnit, java.util.concurrent.atomic.AtomicReference, org.apache.sshd.client.SshClient, org.apache.sshd.client.session.ClientSession, org.apache.sshd.common.PropertyResolver, .PropertyResolverUtils, .SshConstants, .SshException, org.apache.sshd.common.auth.BasicCredentialsImpl, .BasicCredentialsProvider, .MutableBasicCredentials, org.apache.sshd.common.io.IoSession, org.apache.sshd.common.session.Session, .SessionListener, org.apache.sshd.common.util.GenericUtils, .MapEntryUtils, .NumberUtils, .ValidateUtils, org.apache.sshd.common.util.io.IoUtils, org.apache.sshd.common.util.io.functors.IOFunction, org.apache.sshd.common.util.logging.LoggingUtils, org.apache.sshd.sftp.SftpModuleProperties, org.apache.sshd.sftp.client.SftpClient, .SftpClient.Attributes, .SftpClient.OpenMode, .SftpClientFactory, .SftpErrorDataHandler, .SftpVersionSelector, org.apache.sshd.sftp.client.extensions.CopyFileExtension, org.apache.sshd.sftp.client.impl.SftpRemotePathChannel, org.apache.sshd.sftp.common.SftpConstants, .SftpException, org.slf4j.Logger, .LoggerFactory

A registered 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"
Author
Apache MINA SSHD Project

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
SftpFileSystemProvider.SessionProvider

A session provider that automatically creates a new session if the current one is no longer open (or if there isn't one yet).

Field Summary

Modifier and TypeField and Description
private final SshClient
private final SftpErrorDataHandler
private final SftpClientFactory
private final NavigableMap<String, SftpFileSystem>
private SftpFileSystemClientSessionInitializer
protected final Logger
public static final Set<Class<? extends FileAttributeView>>
public static final String
VERSION_PARAM

URI parameter that can be used to specify a special version selection.

private final SftpVersionSelector

Constructor Summary

AccessConstructor and Description
public
public
public
public
public
public
public
SftpFileSystemProvider(SshClient
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 started
client
,
SftpClientFactory
The SftpClientFactory to use to generate SFTP client instances
factory
,
SftpVersionSelector
The SftpVersionSelector to use in order to negotiate the SFTP version
selector
,
SftpErrorDataHandler
The SftpErrorDataHandler to handle incoming data through the error stream - if null the data is silently ignored
errorDataHandler
)

Method Summary

Modifier and TypeMethod and Description
protected int
public void
checkAccess(Path
the path to the file to check
path
,
AccessMode...
The access modes to check; may have zero elements
modes
)

Implements abstract java.nio.file.spi.FileSystemProvider.checkAccess.

Checks the existence, and optionally the accessibility, of a file.

public void
copy(Path
the path to the file to copy
source
,
Path
the path to the target file
target
,
CopyOption...
options specifying how the copy should be done
options
)

Implements abstract java.nio.file.spi.FileSystemProvider.copy.

Copy a file to a target file.

public void
createDirectory(Path
the directory to create
dir
,
FileAttribute<?>...
an optional list of file attributes to set atomically when creating the directory
attrs
)

Implements abstract java.nio.file.spi.FileSystemProvider.createDirectory.

Creates a new directory.

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)

public void
delete(Path
the path to the file to delete
path
)

Implements abstract java.nio.file.spi.FileSystemProvider.delete.

Deletes a file.

public static String
encodeCredentials(String username, String password)

public final SshClient
public <V extends FileAttributeView> V
getFileAttributeView(Path
the path to the file
path
,
Class<V>
the Class object corresponding to the file attribute view
type
,
final LinkOption...
options indicating how symbolic links are handled
options
)

Implements abstract java.nio.file.spi.FileSystemProvider.getFileAttributeView.

Returns a file attribute view of a given type.

public FileStore
getFileStore(Path
the path to the file
path
)

Implements abstract java.nio.file.spi.FileSystemProvider.getFileStore.

Returns the FileStore representing the file store where a file is located.

public FileSystem
getFileSystem(URI
URI reference
uri
)

Implements abstract java.nio.file.spi.FileSystemProvider.getFileSystem.

Returns an existing FileSystem created by this provider.

public SftpFileSystem

Returns:

The cached SftpFileSystem - null if no match
getFileSystem
(String
File system identifier - ignored if null/empty
id
)

public static String

Returns:

The unique identifier
getFileSystemIdentifier
(URI
The URI - Note: not checked to make sure that the scheme is sftp://
uri
)

Uses the host, port and username to create a unique identifier

public static String

Returns:

The unique identifier
getFileSystemIdentifier
(ClientSession session)

Uses the remote host address, port and current username to create a unique identifier

public static String
getFileSystemIdentifier(String host, int port, String username)

public static String
public static String
public Path
getPath(URI
The URI to convert
uri
)

Implements abstract java.nio.file.spi.FileSystemProvider.getPath.

Return a Path object by converting the given URI.

public static String
getRWXPermissions(int perms)

public String
getScheme()

Implements abstract java.nio.file.spi.FileSystemProvider.getScheme.

Returns the URI scheme that identifies this provider.

public SftpClientFactory
public SftpErrorDataHandler
public SftpFileSystemClientSessionInitializer
public final SftpVersionSelector
public boolean
isHidden(Path
the path to the file to test
path
)

Implements abstract java.nio.file.spi.FileSystemProvider.isHidden.

Tells whether or not a file is considered hidden.

public boolean
isSameFile(Path
one path to the file
path1
,
Path
the other path
path2
)

Implements abstract java.nio.file.spi.FileSystemProvider.isSameFile.

Tests if two paths locate the same file.

public boolean
public boolean
public void
move(Path
the path to the file to move
source
,
Path
the path to the target file
target
,
CopyOption...
options specifying how the move should be done
options
)

Implements abstract java.nio.file.spi.FileSystemProvider.move.

Move or rename a file to a target file.

public FileChannel
newByteChannel(Path
the path to the file to open or create
path
,
Set<? extends OpenOption>
options specifying how the file is opened
options
,
FileAttribute<?>...
an optional list of file attributes to set atomically when creating the file
attrs
)

Implements abstract java.nio.file.spi.FileSystemProvider.newByteChannel.

Opens or creates a file, returning a seekable byte channel to access the file.

public DirectoryStream<Path>
newDirectoryStream(Path
the path to the directory
dir
,
DirectoryStream.Filter<? super Path>
the directory stream filter
filter
)

Implements abstract java.nio.file.spi.FileSystemProvider.newDirectoryStream.

Opens a directory, returning a DirectoryStream to iterate over the entries in the directory.

public FileChannel
newFileChannel(Path
the path of the file to open or create
path
,
Set<? extends OpenOption>
options specifying how the file is opened
options
,
FileAttribute<?>...
an optional list of file attributes to set atomically when creating the file
attrs
)

Overrides java.nio.file.spi.FileSystemProvider.newFileChannel.

Opens or creates a file for reading and/or writing, returning a file channel to access the file.

public SftpFileSystem
newFileSystem(URI
URI reference
uri
,
Map<String, ?>
A map of provider specific properties to configure the file system; may be empty
env
)

Implements abstract java.nio.file.spi.FileSystemProvider.newFileSystem.

Constructs a new FileSystem object identified by a URI.

public SftpFileSystem
public InputStream
newInputStream(Path
the path to the file to open
path
,
OpenOption...
options specifying how the file is opened
options
)

Overrides java.nio.file.spi.FileSystemProvider.newInputStream.

Opens a file, returning an input stream to read from the file.

public OutputStream
newOutputStream(Path
the path to the file to open or create
path
,
OpenOption...
options specifying how the file is opened
options
)

Overrides java.nio.file.spi.FileSystemProvider.newOutputStream.

Opens or creates a file, returning an output stream that may be used to write bytes to the file.

public static MutableBasicCredentials

Returns:

The parsed credentials - null if none available
parseCredentials
(URI
The URI value - ignored if null or does not contain any user info.
uri
)

Attempts to parse the user information from the URI

public static MutableBasicCredentials
public static Map<String, Object>
public static Map<String, Object>
public static Set<PosixFilePermission>
protected NavigableMap<String, Object>
readAclViewAttributes(SftpPath path, String view, String attrs, LinkOption... options)

public <A extends BasicFileAttributes> A
readAttributes(Path
the path to the file
path
,
Class<A>
the Class of the file attributes required to read
type
,
LinkOption...
options indicating how symbolic links are handled
options
)

Implements abstract java.nio.file.spi.FileSystemProvider.readAttributes.

Reads a file's attributes as a bulk operation.

public Map<String, Object>
readAttributes(Path
the path to the file
path
,
String
the attributes to read
attributes
,
LinkOption...
options indicating how symbolic links are handled
options
)

Implements abstract java.nio.file.spi.FileSystemProvider.readAttributes.

Reads a set of file attributes as a bulk operation.

public Map<String, Object>
readAttributes(Path path, String view, String attrs, LinkOption... options)

protected Map<String, Object>
readCustomViewAttributes(SftpPath path, String view, String attrs, LinkOption... options)

protected NavigableMap<String, Object>
readPosixViewAttributes(SftpPath path, String view, String attrs, LinkOption... options)

public SftpClient.Attributes
public SftpFileSystem

Returns:

The removed SftpFileSystem - null if no match
removeFileSystem
(String
File system identifier - ignored if null/empty
id
)

public static Map<String, Object>
protected SftpClient.Attributes
protected SftpErrorDataHandler
protected SftpVersionSelector
public void
setAttribute(Path
the path to the file
path
,
String
the attribute to set
attribute
,
Object
the attribute value
value
,
LinkOption...
options indicating how symbolic links are handled
options
)

Implements abstract java.nio.file.spi.FileSystemProvider.setAttribute.

Sets the value of a file attribute.

public void
setAttribute(Path path, String view, String attr, Object value, LinkOption... options)

public void
public SftpPath
Inherited from java.nio.file.spi.FileSystemProvider:
createLinkdeleteIfExistsexistsinstalledProvidersnewAsynchronousFileChannelnewFileSystemreadAttributesIfExists