Class SFTPTransfer

java.lang.Object
org.apache.nifi.processors.standard.util.SFTPTransfer
All Implemented Interfaces:
Closeable, AutoCloseable, FileTransfer

public class SFTPTransfer extends Object implements FileTransfer
  • Field Details

    • CLIENT_PROVIDER

      private static final SshClientProvider CLIENT_PROVIDER
    • DOT_PREFIX

      private static final String DOT_PREFIX
      See Also:
    • RELATIVE_CURRENT_DIRECTORY

      private static final String RELATIVE_CURRENT_DIRECTORY
      See Also:
    • RELATIVE_PARENT_DIRECTORY

      private static final String RELATIVE_PARENT_DIRECTORY
      See Also:
    • DEFAULT_KEY_ALGORITHM_NAMES

      private static final Set<String> DEFAULT_KEY_ALGORITHM_NAMES
    • DEFAULT_CIPHER_NAMES

      private static final Set<String> DEFAULT_CIPHER_NAMES
    • DEFAULT_MESSAGE_AUTHENTICATION_CODE_NAMES

      private static final Set<String> DEFAULT_MESSAGE_AUTHENTICATION_CODE_NAMES
    • DEFAULT_KEY_EXCHANGE_ALGORITHM_NAMES

      private static final Set<String> DEFAULT_KEY_EXCHANGE_ALGORITHM_NAMES
    • PRIVATE_KEY_PATH

      public static final org.apache.nifi.components.PropertyDescriptor PRIVATE_KEY_PATH
    • PRIVATE_KEY_PASSPHRASE

      public static final org.apache.nifi.components.PropertyDescriptor PRIVATE_KEY_PASSPHRASE
    • HOST_KEY_FILE

      public static final org.apache.nifi.components.PropertyDescriptor HOST_KEY_FILE
    • STRICT_HOST_KEY_CHECKING

      public static final org.apache.nifi.components.PropertyDescriptor STRICT_HOST_KEY_CHECKING
    • PORT

      public static final org.apache.nifi.components.PropertyDescriptor PORT
    • USE_KEEPALIVE_ON_TIMEOUT

      public static final org.apache.nifi.components.PropertyDescriptor USE_KEEPALIVE_ON_TIMEOUT
    • ALGORITHM_CONFIGURATION

      public static final org.apache.nifi.components.PropertyDescriptor ALGORITHM_CONFIGURATION
    • KEY_ALGORITHMS_ALLOWED

      public static final org.apache.nifi.components.PropertyDescriptor KEY_ALGORITHMS_ALLOWED
    • CIPHERS_ALLOWED

      public static final org.apache.nifi.components.PropertyDescriptor CIPHERS_ALLOWED
    • MESSAGE_AUTHENTICATION_CODES_ALLOWED

      public static final org.apache.nifi.components.PropertyDescriptor MESSAGE_AUTHENTICATION_CODES_ALLOWED
    • KEY_EXCHANGE_ALGORITHMS_ALLOWED

      public static final org.apache.nifi.components.PropertyDescriptor KEY_EXCHANGE_ALGORITHMS_ALLOWED
    • DISABLE_DIRECTORY_LISTING

      public static final org.apache.nifi.components.PropertyDescriptor DISABLE_DIRECTORY_LISTING
      Property which is used to decide if the ensureDirectoryExists(FlowFile, File) method should perform a list before calling mkdir. In most cases, the code should call ls before mkdir, but some weird permission setups (chmod 100) on a directory would cause the 'ls' to throw a permission exception.
    • PROXY_SPECS

      private static final ProxySpec[] PROXY_SPECS
    • PROXY_CONFIGURATION_SERVICE

      public static final org.apache.nifi.components.PropertyDescriptor PROXY_CONFIGURATION_SERVICE
    • logger

      private final org.apache.nifi.logging.ComponentLog logger
    • ctx

      private final org.apache.nifi.context.PropertyContext ctx
    • clientSession

      private org.apache.sshd.client.session.ClientSession clientSession
    • sftpClient

      private org.apache.sshd.sftp.client.SftpClient sftpClient
    • closed

      private volatile boolean closed
    • homeDir

      private String homeDir
    • activeHostname

      private String activeHostname
    • activePort

      private String activePort
    • activeUsername

      private String activeUsername
    • activePassword

      private String activePassword
    • activePrivateKeyPath

      private String activePrivateKeyPath
    • activePrivateKeyPassphrase

      private String activePrivateKeyPassphrase
    • disableDirectoryListing

      private final boolean disableDirectoryListing
  • Constructor Details

    • SFTPTransfer

      public SFTPTransfer(org.apache.nifi.context.PropertyContext propertyContext, org.apache.nifi.logging.ComponentLog logger)
  • Method Details

    • convertFactorySetToString

      private static String convertFactorySetToString(Set<String> factorySetNames)
      Converts a set of names into an alphabetically ordered comma separated value list.
      Parameters:
      factorySetNames - The set of names
      Returns:
      An alphabetically ordered comma separated value list of names
    • buildFullPath

      private static String buildFullPath(String path, String filename)
    • migrateAlgorithmProperties

      public static void migrateAlgorithmProperties(PropertyConfiguration propertyConfiguration)
    • validateProxySpec

      public static void validateProxySpec(org.apache.nifi.components.ValidationContext context, Collection<org.apache.nifi.components.ValidationResult> results)
    • getProtocolName

      public String getProtocolName()
      Specified by:
      getProtocolName in interface FileTransfer
    • getListing

      public List<FileInfo> getListing(boolean applyFilters) throws IOException
      Specified by:
      getListing in interface FileTransfer
      Throws:
      IOException
    • getListing

      protected void getListing(String path, int depth, int maxResults, List<FileInfo> listing, boolean applyFilters) throws IOException
      Throws:
      IOException
    • isIncludedFile

      private boolean isIncludedFile(org.apache.sshd.sftp.client.SftpClient.DirEntry dirEntry, boolean symlinksEnabled)
      Include remote resources when regular file found or when symbolic links are enabled and the resource is a link
      Parameters:
      dirEntry - Remote Directory Entry
      symlinksEnabled - Follow symbolic links enabled
      Returns:
      Included file status
    • isIncludedDirectory

      private boolean isIncludedDirectory(org.apache.sshd.sftp.client.SftpClient.DirEntry dirEntry, boolean recursionEnabled, boolean symlinksEnabled)
      Include remote resources when recursion is enabled or when symbolic links are enabled and the resource is a directory link
      Parameters:
      dirEntry - Remote Directory Entry
      recursionEnabled - Recursion enabled status
      symlinksEnabled - Follow symbolic links enabled
      Returns:
      Included directory status
    • newFileInfo

      private FileInfo newFileInfo(String path, String filename, org.apache.sshd.sftp.client.SftpClient.Attributes attributes)
    • appendPermission

      private void appendPermission(StringBuilder builder, Set<PosixFilePermission> permissions, PosixFilePermission filePermission, String permString)
    • getRemoteFile

      public org.apache.nifi.flowfile.FlowFile getRemoteFile(String remoteFileName, org.apache.nifi.flowfile.FlowFile origFlowFile, org.apache.nifi.processor.ProcessSession session) throws org.apache.nifi.processor.exception.ProcessException, IOException
      Specified by:
      getRemoteFile in interface FileTransfer
      Throws:
      org.apache.nifi.processor.exception.ProcessException
      IOException
    • deleteFile

      public void deleteFile(org.apache.nifi.flowfile.FlowFile flowFile, String path, String remoteFileName) throws IOException
      Specified by:
      deleteFile in interface FileTransfer
      Throws:
      IOException
    • deleteDirectory

      public void deleteDirectory(org.apache.nifi.flowfile.FlowFile flowFile, String remoteDirectoryName) throws IOException
      Specified by:
      deleteDirectory in interface FileTransfer
      Throws:
      IOException
    • ensureDirectoryExists

      public void ensureDirectoryExists(org.apache.nifi.flowfile.FlowFile flowFile, File directoryName) throws IOException
      Specified by:
      ensureDirectoryExists in interface FileTransfer
      Throws:
      IOException
    • getSFTPClient

      protected org.apache.sshd.sftp.client.SftpClient getSFTPClient(org.apache.nifi.flowfile.FlowFile flowFile) throws IOException
      Throws:
      IOException
    • getHomeDirectory

      public String getHomeDirectory(org.apache.nifi.flowfile.FlowFile flowFile) throws IOException
      Specified by:
      getHomeDirectory in interface FileTransfer
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • isClosed

      public boolean isClosed()
      Specified by:
      isClosed in interface FileTransfer
    • getRemoteFileInfo

      public FileInfo getRemoteFileInfo(org.apache.nifi.flowfile.FlowFile flowFile, String path, String filename) throws IOException
      Specified by:
      getRemoteFileInfo in interface FileTransfer
      Throws:
      IOException
    • put

      public String put(org.apache.nifi.flowfile.FlowFile flowFile, String path, String filename, InputStream content) throws IOException
      Specified by:
      put in interface FileTransfer
      Throws:
      IOException
    • rename

      public void rename(org.apache.nifi.flowfile.FlowFile flowFile, String source, String target) throws IOException
      Specified by:
      rename in interface FileTransfer
      Throws:
      IOException
    • numberPermissions

      protected int numberPermissions(String perms)