Custom Plugin SFTP with certificate

Objective: I have a requirement to exchange files with a host via SFTP. The certificate that I must use for the SFTP session will vary depending upon the partner for which I am exchanging files. I cannot find a way to specify what certificate (or even what certificate store) should be used for an SFTP source or target. What do I do?

 

Solution: The attached custom plugin code will help to connect SFTP code using certificate. You can use this custom plugin in process flow to connect to SFTP. Custom plugin code calls attached custom classes methods to connect SFTP and perform desired operations. Please refer custom class details below for available methods.

 

Attachments:

CP_SFTPConnect.txt : use the code of this file in your process flow

LinuxUtil.class: Place the file in \\AdeptiaServer\ServerKernel\customClasses\com

LinuxUtil$MyUserInfo.class: Place the file in \\AdeptiaServer\ServerKernel\customClasses\com

 

Custom plugin primary Inputs:

String HOST = "<<provide host IP>>";

String USER = "<<provide user name>>";

int port = <<provide SFTP port>>;

String command = << provide desired SFTP command you would like to execute>>

String privatekeyPath = "<<Adeptia relative path>>";

 

Custom Class Details :-  The custom class contains below methods that  creates session after connecting SFTP server, executed desired command, check if directory exists and retrieves log files. getInputStreamAsString converts InputStream to String.

 

Methods Available :-

Session getRemoteSessionObject(String host, String user, boolean isAuthenticateByKey, String privatekeyPath, int port)

InputStream executeCommand(Session session, String command)

boolean isDirectoryExist(Session session, String directory)

ArrayList getLogFiles(String command, Session session)

getInputStreamAsString(InputStream in)

Have more questions? Submit a request

0 Comments

Article is closed for comments.