2

So I have a working ftp connection and I can upload files and whatnot. However currently I'm storing the pw/user as hardcoded values (which I know isn't good) and want to see if I can hide/encrypt them somehow. I would also like to encrypt the actual ftp connection if possible as well. Any information/pointers would be great!

private int ftpProcess(String serverName, String userName, String password) {
    FTPClient ftp = new FTPClient();
    int statusCode = 0;
    try {
        ftp.connect(serverName);
        // was required to add this passive mode in TC8 to connect to the mainframe
        ftp.enterLocalPassiveMode();

        ftp.login(userName, password);

        ftp.site("filetype=jes");

        submitJcl(ftp, "submitTest.txt", serverName);

        ftp.quit();
    } catch (Exception e) {
        logger.error(e);
        statusCode = 3;
    }
    return statusCode;
}
Maze
  • 368
  • 3
  • 15

2 Answers2

1

You can encrypt values in your application.properties with Jasypt.

See the following link for a details description: https://stackoverflow.com/a/37424296/13454816

omido
  • 76
  • 5
0

If you are already using Spring, you could can add org.springframework.boot:spring-boot-starter-security dependency and use BCryptPasswordEncoder to encode the values:

BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
String enc = encoder.encode(value);

Documentation is here:

And this is a very helpful tutorial:

Thomas Portwood
  • 1,031
  • 8
  • 13