use of org.talend.core.model.properties.FTPConnectionItem in project tdi-studio-se by Talend.
the class EncryptPassword4FTPItemFileMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
if (item instanceof FTPConnectionItem) {
FTPConnectionItem item1 = (FTPConnectionItem) item;
Connection connection = item1.getConnection();
if (connection instanceof FTPConnection) {
FTPConnection ftpConn = (FTPConnection) connection;
try {
if (encryptPassword(ftpConn)) {
factory.save(item, true);
}
} catch (Exception e1) {
ExceptionHandler.process(e1);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.core.model.properties.FTPConnectionItem in project tdi-studio-se by Talend.
the class UnifyPasswordEncryption4FtpConnectionMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org .talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
if (item instanceof FTPConnectionItem) {
Connection connection = ((FTPConnectionItem) item).getConnection();
if (connection instanceof FTPConnection) {
FTPConnection ftpConn = (FTPConnection) connection;
try {
if (!ftpConn.isContextMode()) {
boolean modified = false;
//
String password = reencryptIfNeed(ftpConn, ftpConn.getPassword());
if (password != null) {
// re-encrypted
ftpConn.setPassword(password);
modified = true;
}
//
String passphrase = reencryptIfNeed(ftpConn, ftpConn.getPassphrase());
if (passphrase != null) {
// re-encrypted
ftpConn.setPassphrase(passphrase);
modified = true;
}
//
String keystorePassword = reencryptIfNeed(ftpConn, ftpConn.getKeystorePassword());
if (keystorePassword != null) {
// re-encrypted
ftpConn.setKeystorePassword(keystorePassword);
modified = true;
}
//
String proxypassword = reencryptIfNeed(ftpConn, ftpConn.getProxypassword());
if (proxypassword != null) {
// re-encrypted
ftpConn.setProxypassword(proxypassword);
modified = true;
}
if (modified) {
factory.save(item, true);
return ExecutionResult.SUCCESS_NO_ALERT;
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
Aggregations