java - 如何在spring boot中加密用户/密码和ftp连接?
问题描述
所以我有一个有效的 ftp 连接,我可以上传文件等等。但是目前我将 pw/user 存储为硬编码值(我知道这不好),并想看看我是否可以以某种方式隐藏/加密它们。如果可能的话,我还想加密实际的 ftp 连接。任何信息/指针都会很棒!
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;
}
解决方案
您可以使用 Jasypt 加密 application.properties 中的值。
有关详细说明,请参见以下链接: https ://stackoverflow.com/a/37424296/13454816
推荐阅读
- c++ - 期望从 while 循环中输出四个打印输出,只得到一个
- python - How to allow user to progress linearly across a 2D game board?
- c# - Getting error when player collides with and object. Unity
- jestjs - Automated browser testing with puppeter and jest
- python - Python cassandra更新语句错误'输入不匹配're'期待K_WHERE'?
- python - 逐行读取带有算术表达式的文本文件,计算并在新的文本文件中写入结果
- javascript - Req,File.Path 仍未定义,由于文档模糊,我正在使用 multer,我无法完全理解它?
- javascript - 在 goup 中按类选择所有复选框
- linux - 如何从 linux shell 循环字符串以获取模式?
- sql-server - SQL Server 存储过程中的批量插入错误:无法打开文件