use of nl.nn.adapterframework.util.CredentialFactory in project iaf by ibissource.
the class ShowSecurityItems method addAuthEntries.
private void addAuthEntries(XmlBuilder securityItems) {
XmlBuilder aes = new XmlBuilder("authEntries");
securityItems.addSubElement(aes);
List entries = new ArrayList();
try {
URL url = ClassUtils.getResourceURL(this, AUTHALIAS_XSLT);
if (url != null) {
for (Configuration configuration : ibisManager.getConfigurations()) {
Transformer t = XmlUtils.createTransformer(url, true);
String configString = configuration.getLoadedConfiguration();
String authEntries = XmlUtils.transformXml(t, configString);
log.debug("authentication aliases for configuration [" + configuration.getName() + "] found [" + authEntries.trim() + "]");
Collection<String> c = XmlUtils.evaluateXPathNodeSet(authEntries, "authEntries/entry/@alias");
if (c != null && c.size() > 0) {
for (Iterator<String> cit = c.iterator(); cit.hasNext(); ) {
String entry = cit.next();
if (!entries.contains(entry)) {
entries.add(entry);
}
}
}
}
}
} catch (Exception e) {
XmlBuilder ae = new XmlBuilder("entry");
aes.addSubElement(ae);
ae.addAttribute("alias", "*** ERROR ***");
}
if (entries != null) {
Collections.sort(entries);
Iterator iter = entries.iterator();
while (iter.hasNext()) {
String alias = (String) iter.next();
CredentialFactory cf = new CredentialFactory(alias, null, null);
XmlBuilder ae = new XmlBuilder("entry");
aes.addSubElement(ae);
ae.addAttribute("alias", alias);
String userName;
String passWord;
try {
userName = cf.getUsername();
passWord = StringUtils.repeat("*", cf.getPassword().length());
} catch (Exception e) {
userName = "*** ERROR ***";
passWord = "*** ERROR ***";
}
ae.addAttribute("userName", userName);
ae.addAttribute("passWord", passWord);
}
}
}
use of nl.nn.adapterframework.util.CredentialFactory in project iaf by ibissource.
the class MailSender method putOnTransport.
protected void putOnTransport(Message msg) throws SenderException {
// connect to the transport
Transport transport = null;
try {
CredentialFactory cf = new CredentialFactory(getSmtpAuthAlias(), getSmtpUserid(), getSmtpPassword());
transport = session.getTransport("smtp");
transport.connect(getSmtpHost(), cf.getUsername(), cf.getPassword());
if (log.isDebugEnabled()) {
log.debug("MailSender [" + getName() + "] connected transport to URL [" + transport.getURLName() + "]");
}
transport.sendMessage(msg, msg.getAllRecipients());
transport.close();
} catch (Exception e) {
throw new SenderException("MailSender [" + getName() + "] cannot connect send message to smtpHost [" + getSmtpHost() + "]", e);
} finally {
if (transport != null) {
try {
transport.close();
} catch (MessagingException e1) {
log.warn("MailSender [" + getName() + "] got exception closing connection", e1);
}
}
}
}
use of nl.nn.adapterframework.util.CredentialFactory in project iaf by ibissource.
the class XComSender method getCommand.
private String getCommand(IPipeLineSession session, File localFile, boolean inclPasswd) throws SenderException {
try {
StringBuffer sb = new StringBuffer();
sb.append(xcomtcp).append(" -c1");
if (StringUtils.isNotEmpty(configFile)) {
sb.append(" -f ").append(configFile);
}
if (StringUtils.isNotEmpty(remoteSystem)) {
sb.append(" REMOTE_SYSTEM=").append(remoteSystem);
}
if (localFile != null) {
sb.append(" LOCAL_FILE=").append(localFile.getAbsolutePath());
sb.append(" REMOTE_FILE=");
if (!StringUtils.isEmpty(remoteDirectory))
sb.append(remoteDirectory);
if (StringUtils.isEmpty(remoteFilePattern))
sb.append(localFile.getName());
else
sb.append(FileUtils.getFilename(paramList, session, localFile, remoteFilePattern));
}
CredentialFactory cf = new CredentialFactory(getAuthAlias(), getUserid(), password);
// optional parameters
if (StringUtils.isNotEmpty(fileOption))
sb.append(" FILE_OPTION=").append(fileOption);
if (queue != null)
sb.append(" QUEUE=").append(queue.booleanValue() ? "YES" : "NO");
if (tracelevel != null)
sb.append(" TRACE=").append(tracelevel.intValue());
if (truncation != null)
sb.append(" TRUNCATION=").append(truncation.booleanValue() ? "YES" : "NO");
if (!StringUtils.isEmpty(port))
sb.append(" PORT=" + port);
if (!StringUtils.isEmpty(logfile))
sb.append(" XLOGFILE=" + logfile);
if (!StringUtils.isEmpty(compress))
sb.append(" COMPRESS=").append(compress);
if (!StringUtils.isEmpty(codeflag))
sb.append(" CODE_FLAG=").append(codeflag);
if (!StringUtils.isEmpty(carriageflag))
sb.append(" CARRIAGE_FLAG=").append(carriageflag);
if (!StringUtils.isEmpty(cf.getUsername()))
sb.append(" USERID=").append(cf.getUsername());
if (inclPasswd && !StringUtils.isEmpty(cf.getPassword()))
sb.append(" PASSWORD=").append(cf.getPassword());
return sb.toString();
} catch (ParameterException e) {
throw new SenderException(e);
}
}
Aggregations