}
private DataConnectionConfiguration parseDataConnection(
final Element element,
final SslConfiguration listenerSslConfiguration) {
DefaultDataConnectionConfiguration dc = new DefaultDataConnectionConfiguration();
if (element != null) {
// data con config element available
SslConfiguration ssl = parseSsl(element);
if (ssl != null) {
LOG.debug("SSL configuration found for the data connection");
dc.setSslConfiguration(ssl);
} else {
// go look for the parent element SSL config
// find the listener element
if (listenerSslConfiguration != null) {
LOG
.debug("SSL configuration found for the listener, falling back for that for the data connection");
dc.setSslConfiguration(listenerSslConfiguration);
}
}
Element activeElm = SpringUtil.getChildElement(element,
FtpServerNamespaceHandler.FTPSERVER_NS, "active");
if (activeElm != null) {
Active active = new Active();
active.setEnable(SpringUtil.parseBoolean(activeElm, "enabled",
true));
active.setIpCheck(SpringUtil.parseBoolean(activeElm,
"ip-check", false));
active.setLocalPort(SpringUtil.parseInt(activeElm,
"local-port", 0));
InetAddress localAddress = SpringUtil.parseInetAddress(
activeElm, "local-address");
if (localAddress != null) {
active.setLocalAddress(localAddress);
}
dc.setActive(active);
}
Element passiveElm = SpringUtil.getChildElement(element,
FtpServerNamespaceHandler.FTPSERVER_NS, "passive");
if (passiveElm != null) {
Passive passive = new Passive();
InetAddress address = SpringUtil.parseInetAddress(passiveElm,
"address");
if (address != null) {
passive.setAddress(address);
}
InetAddress externalAddress = SpringUtil.parseInetAddress(
passiveElm, "external-address");
if (externalAddress != null) {
passive.setExternalAddress(externalAddress);
}
String ports = SpringUtil.parseString(passiveElm, "ports");
if (ports != null) {
passive.setPorts(ports);
}
dc.setPassive(passive);
}
} 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;