public final class SftpHelper
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
APPEND_END_OF_LIST_INDICATOR
Used to control whether to append the end-of-list indicator for SSH_FXP_NAME responses via
indicateEndOfNamesList(Buffer, int, PropertyResolver, boolean) call, as indicated by
SFTP v6 - section 9.4 |
static boolean |
DEFAULT_APPEND_END_OF_LIST_INDICATOR
Default value for
APPEND_END_OF_LIST_INDICATOR if none configured |
static java.util.Map<java.lang.Integer,java.lang.String> |
DEFAULT_SUBSTATUS_MESSAGE |
| Modifier | Constructor and Description |
|---|---|
private |
SftpHelper() |
| Modifier and Type | Method and Description |
|---|---|
static int |
attributesToPermissions(boolean isReg,
boolean isDir,
boolean isLnk,
java.util.Collection<java.nio.file.attribute.PosixFilePermission> perms)
Converts a file / folder's attributes into a mask
|
static java.nio.file.attribute.AclEntry |
buildAclEntry(int aclType,
int aclFlag,
int aclMask,
java.lang.String aclWho) |
static java.nio.file.attribute.AclEntryType |
decodeAclEntryType(int aclType) |
static java.util.Set<java.nio.file.attribute.AclEntryFlag> |
decodeAclFlags(int aclFlag) |
static java.util.Set<java.nio.file.attribute.AclEntryPermission> |
decodeAclMask(int aclMask) |
static java.util.List<java.nio.file.attribute.AclEntry> |
decodeACLs(Buffer buffer,
int version) |
static int |
encodeAclEntryType(java.nio.file.attribute.AclEntryType type)
Returns the equivalent SFTP value for the ACL type
|
static long |
encodeAclFlags(java.util.Collection<java.nio.file.attribute.AclEntryFlag> flags) |
static long |
encodeAclMask(java.util.Collection<java.nio.file.attribute.AclEntryPermission> mask) |
static <B extends Buffer> |
encodeACLs(B buffer,
int version,
java.util.Collection<? extends java.nio.file.attribute.AclEntry> acl) |
static int |
fileTypeToPermission(int type)
Converts a file type into a POSIX permission mask value
|
static boolean |
getBool(java.lang.Boolean bool) |
static java.lang.Boolean |
getEndOfFileIndicatorValue(Buffer buffer,
int version)
Retrieves the end-of-file indicator for
SSH_FXP_DATA responses, provided the version is at least 6, and
the buffer has enough available data |
static java.lang.Boolean |
getEndOfListIndicatorValue(Buffer buffer,
int version)
Retrieves the end-of-list indicator for
SSH_FXP_NAME responses, provided the version is at least 6, and
the buffer has enough available data |
static java.lang.String |
getLongName(java.lang.String shortName,
java.util.Map<java.lang.String,?> attributes)
Creates an "ls -l" compatible long name string
|
static java.lang.Boolean |
indicateEndOfNamesList(Buffer buffer,
int version,
PropertyResolver resolver)
Appends the end-of-list=
TRUE indicator for SSH_FXP_NAME responses, provided the version is at
least 6 and the feature is enabled |
static java.lang.Boolean |
indicateEndOfNamesList(Buffer buffer,
int version,
PropertyResolver resolver,
boolean indicatorValue)
Appends the end-of-list indicator for
SSH_FXP_NAME responses, provided the version is at least 6, the
feature is enabled and the indicator value is not null |
static java.util.Set<java.nio.file.attribute.PosixFilePermission> |
permissionsToAttributes(int perms)
Translates a mask of permissions into its enumeration values equivalents
|
static int |
permissionsToFileType(int perms)
Converts a POSIX permissions mask to a file type value
|
static java.util.List<java.nio.file.attribute.AclEntry> |
readACLs(Buffer buffer,
int version) |
static java.util.NavigableMap<java.lang.String,java.lang.Object> |
readAttrs(Buffer buffer,
int version) |
static java.util.NavigableMap<java.lang.String,byte[]> |
readExtensions(Buffer buffer) |
static java.nio.file.attribute.FileTime |
readTime(Buffer buffer,
int version,
int flags)
Decodes a
FileTime value from a buffer |
static java.lang.String |
resolveStatusMessage(int subStatus) |
static int |
resolveSubstatus(java.lang.Throwable t)
Returns the most adequate sub-status for the provided exception
|
static java.util.NavigableMap<java.lang.String,byte[]> |
toBinaryExtensions(java.util.Map<java.lang.String,java.lang.String> extensions) |
static java.util.NavigableMap<java.lang.String,java.lang.String> |
toStringExtensions(java.util.Map<java.lang.String,?> extensions) |
static <B extends Buffer> |
writeAclEntry(B buffer,
java.nio.file.attribute.AclEntry acl) |
static <B extends Buffer> |
writeACLs(B buffer,
int version,
java.util.Collection<? extends java.nio.file.attribute.AclEntry> acl) |
static <B extends Buffer> |
writeAttrs(B buffer,
int version,
java.util.Map<java.lang.String,?> attributes)
Writes a file / folder's attributes to a buffer
|
static <B extends Buffer> |
writeAttrsV3(B buffer,
int version,
java.util.Map<java.lang.String,?> attributes)
Writes the retrieved file / directory attributes in V3 format
|
static <B extends Buffer> |
writeAttrsV4(B buffer,
int version,
java.util.Map<java.lang.String,?> attributes)
Writes the retrieved file / directory attributes in V4+ format
|
static <B extends Buffer> |
writeExtensions(B buffer,
java.util.Map<?,?> extensions) |
static <B extends Buffer> |
writeTime(B buffer,
int version,
int flags,
java.nio.file.attribute.FileTime time)
Encodes a
FileTime value into a buffer |
public static final java.lang.String APPEND_END_OF_LIST_INDICATOR
indicateEndOfNamesList(Buffer, int, PropertyResolver, boolean) call, as indicated by
SFTP v6 - section 9.4public static final boolean DEFAULT_APPEND_END_OF_LIST_INDICATOR
APPEND_END_OF_LIST_INDICATOR if none configuredpublic static final java.util.Map<java.lang.Integer,java.lang.String> DEFAULT_SUBSTATUS_MESSAGE
public static java.lang.Boolean getEndOfFileIndicatorValue(Buffer buffer, int version)
SSH_FXP_DATA responses, provided the version is at least 6, and
the buffer has enough available databuffer - The Buffer to retrieve the data fromversion - The SFTP version being usednull if none retrievedpublic static java.lang.Boolean getEndOfListIndicatorValue(Buffer buffer, int version)
SSH_FXP_NAME responses, provided the version is at least 6, and
the buffer has enough available databuffer - The Buffer to retrieve the data fromversion - The SFTP version being usednull if none retrievedindicateEndOfNamesList(Buffer, int, PropertyResolver, boolean)public static java.lang.Boolean indicateEndOfNamesList(Buffer buffer, int version, PropertyResolver resolver)
TRUE indicator for SSH_FXP_NAME responses, provided the version is at
least 6 and the feature is enabledbuffer - The Buffer to append the indicatorversion - The SFTP version being usedresolver - The PropertyResolver to query whether to enable the featurenull if none appendedindicateEndOfNamesList(Buffer, int, PropertyResolver, boolean)public static java.lang.Boolean indicateEndOfNamesList(Buffer buffer, int version, PropertyResolver resolver, boolean indicatorValue)
SSH_FXP_NAME responses, provided the version is at least 6, the
feature is enabled and the indicator value is not nullbuffer - The Buffer to append the indicatorversion - The SFTP version being usedresolver - The PropertyResolver to query whether to enable the featureindicatorValue - The indicator value - null means don't append the indicatornull if none appendedAPPEND_END_OF_LIST_INDICATOR,
DEFAULT_APPEND_END_OF_LIST_INDICATORpublic static <B extends Buffer> B writeAttrs(B buffer, int version, java.util.Map<java.lang.String,?> attributes)
B - Type of Buffer being updatedbuffer - The target buffer instanceversion - The output encoding versionattributes - The Map of attributeswriteAttrsV3(Buffer, int, Map),
writeAttrsV4(Buffer, int, Map)public static <B extends Buffer> B writeAttrsV3(B buffer, int version, java.util.Map<java.lang.String,?> attributes)
B - Type of Buffer being updatedbuffer - The target buffer instanceversion - The actual version - must be SftpConstants.SFTP_V3attributes - The Map of attributespublic static <B extends Buffer> B writeAttrsV4(B buffer, int version, java.util.Map<java.lang.String,?> attributes)
B - Type of Buffer being updatedbuffer - The target buffer instanceversion - The actual version - must be at least SftpConstants.SFTP_V4attributes - The Map of attributespublic static boolean getBool(java.lang.Boolean bool)
bool - The Boolean valuetrue it the argument is non-null and its Boolean.booleanValue() is
truepublic static int attributesToPermissions(boolean isReg,
boolean isDir,
boolean isLnk,
java.util.Collection<java.nio.file.attribute.PosixFilePermission> perms)
isReg - true if this is a normal fileisDir - true if this is a directoryisLnk - true if this is a symbolic linkperms - The file / folder's access PosixFilePermissionspublic static int permissionsToFileType(int perms)
perms - The POSIX permissions maskSSH_FILEXFER_TYPE_xxx valuespublic static int fileTypeToPermission(int type)
type - File type - see SSH_FILEXFER_TYPE_xxx valuespublic static java.util.Set<java.nio.file.attribute.PosixFilePermission> permissionsToAttributes(int perms)
perms - The permissions maskSet of the equivalent PosixFilePermissionspublic static int resolveSubstatus(java.lang.Throwable t)
t - The thrown Throwablepublic static java.lang.String resolveStatusMessage(int subStatus)
public static java.util.NavigableMap<java.lang.String,java.lang.Object> readAttrs(Buffer buffer, int version)
public static java.util.NavigableMap<java.lang.String,byte[]> readExtensions(Buffer buffer)
public static <B extends Buffer> B writeExtensions(B buffer, java.util.Map<?,?> extensions)
public static java.util.NavigableMap<java.lang.String,java.lang.String> toStringExtensions(java.util.Map<java.lang.String,?> extensions)
public static java.util.NavigableMap<java.lang.String,byte[]> toBinaryExtensions(java.util.Map<java.lang.String,java.lang.String> extensions)
public static java.util.List<java.nio.file.attribute.AclEntry> readACLs(Buffer buffer, int version)
public static java.util.List<java.nio.file.attribute.AclEntry> decodeACLs(Buffer buffer, int version)
public static java.nio.file.attribute.AclEntry buildAclEntry(int aclType,
int aclFlag,
int aclMask,
java.lang.String aclWho)
public static java.nio.file.attribute.AclEntryType decodeAclEntryType(int aclType)
aclType - The ACE4_ACCESS_xxx_ACE_TYPE valueAclEntryType or null if unknown valuepublic static java.util.Set<java.nio.file.attribute.AclEntryFlag> decodeAclFlags(int aclFlag)
public static java.util.Set<java.nio.file.attribute.AclEntryPermission> decodeAclMask(int aclMask)
public static <B extends Buffer> B writeACLs(B buffer, int version, java.util.Collection<? extends java.nio.file.attribute.AclEntry> acl)
public static <B extends Buffer> B encodeACLs(B buffer, int version, java.util.Collection<? extends java.nio.file.attribute.AclEntry> acl)
public static <B extends Buffer> B writeAclEntry(B buffer, java.nio.file.attribute.AclEntry acl)
public static int encodeAclEntryType(java.nio.file.attribute.AclEntryType type)
type - The AclEntryTypeACE_SYSTEM_xxx_TYPE or negative if null or unknown typepublic static long encodeAclFlags(java.util.Collection<java.nio.file.attribute.AclEntryFlag> flags)
public static long encodeAclMask(java.util.Collection<java.nio.file.attribute.AclEntryPermission> mask)
public static <B extends Buffer> B writeTime(B buffer, int version, int flags, java.nio.file.attribute.FileTime time)
FileTime value into a bufferB - Type of Buffer being updatedbuffer - The target buffer instanceversion - The encoding versionflags - The encoding flagstime - The value to encodepublic static java.nio.file.attribute.FileTime readTime(Buffer buffer, int version, int flags)
FileTime value from a bufferbuffer - The source Bufferversion - The encoding versionflags - The encoding flagspublic static java.lang.String getLongName(java.lang.String shortName,
java.util.Map<java.lang.String,?> attributes)
shortName - The short file name - can also be "." or ".."attributes - The file's attributes - e.g., size, owner, permissions, etc.String representing the "long" file name as per
SFTP version 3 - section
7