public final class SftpHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
static Map<Integer,String> |
DEFAULT_SUBSTATUS_MESSAGE |
| Modifier and Type | Method and Description |
|---|---|
static int |
attributesToPermissions(boolean isReg,
boolean isDir,
boolean isLnk,
Collection<PosixFilePermission> perms)
Converts a file / folder's attributes into a mask
|
static AclEntry |
buildAclEntry(int aclType,
int aclFlag,
int aclMask,
String aclWho) |
static AclEntryType |
decodeAclEntryType(int aclType) |
static Set<AclEntryFlag> |
decodeAclFlags(int aclFlag) |
static Set<AclEntryPermission> |
decodeAclMask(int aclMask) |
static List<AclEntry> |
decodeACLs(org.apache.sshd.common.util.buffer.Buffer buffer,
int version) |
static int |
encodeAclEntryType(AclEntryType type)
Returns the equivalent SFTP value for the ACL type
|
static long |
encodeAclFlags(Collection<AclEntryFlag> flags) |
static long |
encodeAclMask(Collection<AclEntryPermission> mask) |
static <B extends org.apache.sshd.common.util.buffer.Buffer> |
encodeACLs(B buffer,
int version,
Collection<? extends AclEntry> acl) |
static int |
fileTypeToPermission(int type)
Converts a file type into a POSIX permission mask value
|
static boolean |
getBool(Boolean bool) |
static Boolean |
getEndOfFileIndicatorValue(org.apache.sshd.common.util.buffer.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 Boolean |
getEndOfListIndicatorValue(org.apache.sshd.common.util.buffer.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 String |
getLongName(String shortName,
Map<String,?> attributes)
Creates an "ls -l" compatible long name string
|
static Boolean |
indicateEndOfNamesList(org.apache.sshd.common.util.buffer.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 Boolean |
indicateEndOfNamesList(org.apache.sshd.common.util.buffer.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 Set<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 List<AclEntry> |
readACLs(org.apache.sshd.common.util.buffer.Buffer buffer,
int version) |
static NavigableMap<String,Object> |
readAttrs(org.apache.sshd.common.util.buffer.Buffer buffer,
int version) |
static NavigableMap<String,byte[]> |
readExtensions(org.apache.sshd.common.util.buffer.Buffer buffer) |
static FileTime |
readTime(org.apache.sshd.common.util.buffer.Buffer buffer,
int version,
int flags)
Decodes a
FileTime value from a buffer |
static String |
resolveStatusMessage(int subStatus) |
static int |
resolveSubstatus(Throwable t)
Returns the most adequate sub-status for the provided exception
|
static NavigableMap<String,byte[]> |
toBinaryExtensions(Map<String,String> extensions) |
static NavigableMap<String,String> |
toStringExtensions(Map<String,?> extensions) |
static <B extends org.apache.sshd.common.util.buffer.Buffer> |
writeAclEntry(B buffer,
AclEntry acl) |
static <B extends org.apache.sshd.common.util.buffer.Buffer> |
writeACLs(B buffer,
int version,
Collection<? extends AclEntry> acl) |
static <B extends org.apache.sshd.common.util.buffer.Buffer> |
writeAttrs(B buffer,
int version,
Map<String,?> attributes)
Writes a file / folder's attributes to a buffer
|
static <B extends org.apache.sshd.common.util.buffer.Buffer> |
writeAttrsV3(B buffer,
int version,
Map<String,?> attributes)
Writes the retrieved file / directory attributes in V3 format
|
static <B extends org.apache.sshd.common.util.buffer.Buffer> |
writeAttrsV4(B buffer,
int version,
Map<String,?> attributes)
Writes the retrieved file / directory attributes in V4+ format
|
static <B extends org.apache.sshd.common.util.buffer.Buffer> |
writeExtensions(B buffer,
Map<?,?> extensions) |
static <B extends org.apache.sshd.common.util.buffer.Buffer> |
writeTime(B buffer,
int version,
int flags,
FileTime time)
Encodes a
FileTime value into a buffer |
public static Boolean getEndOfFileIndicatorValue(org.apache.sshd.common.util.buffer.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 Boolean getEndOfListIndicatorValue(org.apache.sshd.common.util.buffer.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 Boolean indicateEndOfNamesList(org.apache.sshd.common.util.buffer.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 Boolean indicateEndOfNamesList(org.apache.sshd.common.util.buffer.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 appendedSftpModuleProperties.APPEND_END_OF_LIST_INDICATORpublic static <B extends org.apache.sshd.common.util.buffer.Buffer> B writeAttrs(B buffer, int version, Map<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 org.apache.sshd.common.util.buffer.Buffer> B writeAttrsV3(B buffer, int version, Map<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 org.apache.sshd.common.util.buffer.Buffer> B writeAttrsV4(B buffer, int version, Map<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(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,
Collection<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 Set<PosixFilePermission> permissionsToAttributes(int perms)
perms - The permissions maskSet of the equivalent PosixFilePermissionspublic static int resolveSubstatus(Throwable t)
t - The thrown Throwablepublic static String resolveStatusMessage(int subStatus)
public static NavigableMap<String,Object> readAttrs(org.apache.sshd.common.util.buffer.Buffer buffer, int version)
public static NavigableMap<String,byte[]> readExtensions(org.apache.sshd.common.util.buffer.Buffer buffer)
public static <B extends org.apache.sshd.common.util.buffer.Buffer> B writeExtensions(B buffer, Map<?,?> extensions)
public static NavigableMap<String,String> toStringExtensions(Map<String,?> extensions)
public static NavigableMap<String,byte[]> toBinaryExtensions(Map<String,String> extensions)
public static List<AclEntry> readACLs(org.apache.sshd.common.util.buffer.Buffer buffer, int version)
public static List<AclEntry> decodeACLs(org.apache.sshd.common.util.buffer.Buffer buffer, int version)
public static AclEntry buildAclEntry(int aclType, int aclFlag, int aclMask, String aclWho)
public static AclEntryType decodeAclEntryType(int aclType)
aclType - The ACE4_ACCESS_xxx_ACE_TYPE valueAclEntryType or null if unknown valuepublic static Set<AclEntryFlag> decodeAclFlags(int aclFlag)
public static Set<AclEntryPermission> decodeAclMask(int aclMask)
public static <B extends org.apache.sshd.common.util.buffer.Buffer> B writeACLs(B buffer, int version, Collection<? extends AclEntry> acl)
public static <B extends org.apache.sshd.common.util.buffer.Buffer> B encodeACLs(B buffer, int version, Collection<? extends AclEntry> acl)
public static <B extends org.apache.sshd.common.util.buffer.Buffer> B writeAclEntry(B buffer, AclEntry acl)
public static int encodeAclEntryType(AclEntryType type)
type - The AclEntryTypeACE_SYSTEM_xxx_TYPE or negative if null or unknown typepublic static long encodeAclFlags(Collection<AclEntryFlag> flags)
public static long encodeAclMask(Collection<AclEntryPermission> mask)
public static <B extends org.apache.sshd.common.util.buffer.Buffer> B writeTime(B buffer, int version, int flags, 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 FileTime readTime(org.apache.sshd.common.util.buffer.Buffer buffer, int version, int flags)
FileTime value from a bufferbuffer - The source Bufferversion - The encoding versionflags - The encoding flagspublic static String getLongName(String shortName, Map<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
7Copyright © 2018–2021 The Apache Software Foundation. All rights reserved.