* indicates a programming error, bad XPath
*/
private void loadMail(ApplicationConfiguration appConfig, Document dom,
Node root) throws XPathExpressionException {
XPath xpath = XPathFactory.newInstance().newXPath();
MailConfiguration mcfg = appConfig.getMailConfiguration();
mcfg.put(
xpath.evaluate("mail/@smtpHost", root),
xpath.evaluate("mail/@smtpPort", root),
xpath.evaluate("mail/@siteEmailAddress", root),
xpath.evaluate("mail/@siteEmailAddress", root));
mcfg.setEmailAddressRegexp(xpath.evaluate("mail/@emailAddressRegexp", root));
Node ndAuth = (Node) xpath.evaluate("mail/smtpAuth", root, XPathConstants.NODE);
if (ndAuth != null) {
String sUser = Val.chkStr(xpath.evaluate("@username", ndAuth));
String sPwd = xpath.evaluate("@password", ndAuth);
boolean bEncrypted = Val.chkBool(xpath.evaluate("@encrypted", ndAuth), false);
if (bEncrypted) {
try {
String sDecrypted = PC1_Encryptor.decrypt(sPwd);
sPwd = sDecrypted;
} catch (Exception e) {
this.getLogger().log(Level.SEVERE, "The smptAuth password failed to decrypt.", e);
}
}
if ((sUser != null) && (sUser.length() > 0) && (sPwd != null) && (sPwd.length() > 0)) {
mcfg.setPasswordAuthentication(new javax.mail.PasswordAuthentication(sUser, sPwd));
}
}
}