}
private DataConnectionConfiguration parseDataConnection(
final Element element,
final SslConfiguration listenerSslConfiguration) {
DataConnectionConfigurationFactory dc = new DataConnectionConfigurationFactory();
if (element != null) {
dc.setImplicitSsl(SpringUtil.parseBoolean(element, "implicit-ssl", false));
// data con config element available
SslConfiguration ssl = parseSsl(element);
if (ssl != null) {
LOG.debug("SSL configuration found for the data connection");
dc.setSslConfiguration(ssl);
}
dc.setIdleTime(SpringUtil.parseInt(element, "idle-timeout", dc.getIdleTime()));
Element activeElm = SpringUtil.getChildElement(element,
FtpServerNamespaceHandler.FTPSERVER_NS, "active");
if (activeElm != null) {
dc.setActiveEnabled(SpringUtil.parseBoolean(activeElm, "enabled",
true));
dc.setActiveIpCheck(SpringUtil.parseBoolean(activeElm,
"ip-check", false));
dc.setActiveLocalPort(SpringUtil.parseInt(activeElm,
"local-port", 0));
String localAddress = SpringUtil.parseStringFromInetAddress(
activeElm, "local-address");
if (localAddress != null) {
dc.setActiveLocalAddress(localAddress);
}
}
Element passiveElm = SpringUtil.getChildElement(element,
FtpServerNamespaceHandler.FTPSERVER_NS, "passive");
if (passiveElm != null) {
String address = SpringUtil.parseStringFromInetAddress(passiveElm,
"address");
if (address != null) {
dc.setPassiveAddress(address);
}
String externalAddress = SpringUtil.parseStringFromInetAddress(
passiveElm, "external-address");
if (externalAddress != null) {
dc.setPassiveExternalAddress(externalAddress);
}
String ports = SpringUtil.parseString(passiveElm, "ports");
if (ports != null) {
dc.setPassivePorts(ports);
}
}
} else {
// no data conn config element, do we still have SSL config from the
// parent?
if (listenerSslConfiguration != null) {
LOG
.debug("SSL configuration found for the listener, falling back for that for the data connection");
dc.setSslConfiguration(listenerSslConfiguration);
}
}
return dc.createDataConnectionConfiguration();
}