private SslConfiguration parseSsl(final Element parent) {
Element sslElm = SpringUtil.getChildElement(parent,
FtpServerNamespaceHandler.FTPSERVER_NS, "ssl");
if (sslElm != null) {
DefaultSslConfiguration ssl = new DefaultSslConfiguration();
Element keyStoreElm = SpringUtil.getChildElement(sslElm,
FtpServerNamespaceHandler.FTPSERVER_NS, "keystore");
if (keyStoreElm != null) {
ssl.setKeystoreFile(SpringUtil.parseFile(keyStoreElm, "file"));
ssl.setKeystorePassword(SpringUtil.parseString(keyStoreElm,
"password"));
String type = SpringUtil.parseString(keyStoreElm, "type");
if (type != null) {
ssl.setKeystoreType(type);
}
String keyAlias = SpringUtil.parseString(keyStoreElm,
"key-alias");
if (keyAlias != null) {
ssl.setKeyAlias(keyAlias);
}
String keyPassword = SpringUtil.parseString(keyStoreElm,
"key-password");
if (keyPassword != null) {
ssl.setKeyPassword(keyPassword);
}
String algorithm = SpringUtil.parseString(keyStoreElm,
"algorithm");
if (algorithm != null) {
ssl.setKeystoreAlgorithm(algorithm);
}
}
Element trustStoreElm = SpringUtil.getChildElement(sslElm,
FtpServerNamespaceHandler.FTPSERVER_NS, "truststore");
if (trustStoreElm != null) {
ssl.setTruststoreFile(SpringUtil.parseFile(trustStoreElm,
"file"));
ssl.setTruststorePassword(SpringUtil.parseString(trustStoreElm,
"password"));
String type = SpringUtil.parseString(trustStoreElm, "type");
if (type != null) {
ssl.setTruststoreType(type);
}
String algorithm = SpringUtil.parseString(trustStoreElm,
"algorithm");
if (algorithm != null) {
ssl.setTruststoreAlgorithm(algorithm);
}
}
String clientAuthStr = SpringUtil.parseString(sslElm,
"client-authentication");
if (clientAuthStr != null) {
ssl.setClientAuthentication(clientAuthStr);
}
String enabledCiphersuites = SpringUtil.parseString(sslElm,
"enabled-ciphersuites");
if (enabledCiphersuites != null) {
ssl.setEnabledCipherSuites(enabledCiphersuites.split(" "));
}
String protocol = SpringUtil.parseString(sslElm, "protocol");
if (protocol != null) {
ssl.setSslProtocol(protocol);
}
return ssl;
} else {
return null;