use of nl.nn.adapterframework.ldap.LdapSender in project iaf by ibissource.
the class GetTibcoQueues method retrieveLdapSender.
private LdapSender retrieveLdapSender(String ldapUrl, CredentialFactory cf) {
try {
LdapSender ldapSender = new LdapSender();
ldapSender.setProviderURL(ldapUrl);
ldapSender.setAttributesToReturn("cn,description");
if (StringUtils.isNotEmpty(cf.getAlias())) {
ldapSender.setJndiAuthAlias(cf.getAlias());
}
if (StringUtils.isNotEmpty(cf.getUsername())) {
ldapSender.setPrincipal(cf.getUsername());
}
if (StringUtils.isNotEmpty(cf.getPassword())) {
ldapSender.setCredentials(cf.getPassword());
}
Parameter p = new Parameter();
p.setName("entryName");
p.setXpathExpression("concat('cn=',*)");
p.configure();
ldapSender.addParameter(p);
ldapSender.configure();
return ldapSender;
} catch (ConfigurationException e) {
log.warn(getLogPrefix(null) + "exception on retrieving ldapSender", e);
}
return null;
}
use of nl.nn.adapterframework.ldap.LdapSender in project iaf by ibissource.
the class GetTibcoQueues method doPipeWithTimeoutGuarded.
public String doPipeWithTimeoutGuarded(Object input, IPipeLineSession session) throws PipeRunException {
String result;
String url_work;
String authAlias_work;
String userName_work;
String password_work;
String queueName_work = null;
ParameterValueList pvl = null;
if (getParameterList() != null) {
ParameterResolutionContext prc = new ParameterResolutionContext((String) input, session);
try {
pvl = prc.getValues(getParameterList());
} catch (ParameterException e) {
throw new PipeRunException(this, getLogPrefix(session) + "exception on extracting parameters", e);
}
}
url_work = getParameterValue(pvl, "url");
if (url_work == null) {
url_work = getUrl();
}
authAlias_work = getParameterValue(pvl, "authAlias");
if (authAlias_work == null) {
authAlias_work = getAuthAlias();
}
userName_work = getParameterValue(pvl, "userName");
if (userName_work == null) {
userName_work = getUserName();
}
password_work = getParameterValue(pvl, "password");
if (password_work == null) {
password_work = getPassword();
}
CredentialFactory cf = new CredentialFactory(authAlias_work, userName_work, password_work);
Connection connection = null;
Session jSession = null;
TibjmsAdmin admin = null;
try {
admin = TibcoUtils.getActiveServerAdmin(url_work, cf);
if (admin == null) {
throw new PipeRunException(this, "could not find an active server");
}
String ldapUrl = getParameterValue(pvl, "ldapUrl");
LdapSender ldapSender = null;
if (StringUtils.isNotEmpty(ldapUrl)) {
ldapSender = retrieveLdapSender(ldapUrl, cf);
}
queueName_work = getParameterValue(pvl, "queueName");
if (StringUtils.isNotEmpty(queueName_work)) {
String countOnly_work = getParameterValue(pvl, "countOnly");
boolean countOnly = ("true".equalsIgnoreCase(countOnly_work) ? true : false);
if (countOnly) {
return getQueueMessageCountOnly(admin, queueName_work);
}
}
ConnectionFactory factory = new com.tibco.tibjms.TibjmsConnectionFactory(url_work);
connection = factory.createConnection(cf.getUsername(), cf.getPassword());
jSession = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
if (StringUtils.isNotEmpty(queueName_work)) {
String queueItem_work = getParameterValue(pvl, "queueItem");
int qi;
if (StringUtils.isNumeric(queueItem_work)) {
qi = Integer.parseInt(queueItem_work);
} else {
qi = 1;
}
result = getQueueMessage(jSession, admin, queueName_work, qi, ldapSender);
} else {
String showAge_work = getParameterValue(pvl, "showAge");
boolean showAge = ("true".equalsIgnoreCase(showAge_work) ? true : false);
result = getQueuesInfo(jSession, admin, showAge, ldapSender);
}
} catch (Exception e) {
String msg = getLogPrefix(session) + "exception on showing Tibco queues, url [" + url_work + "]" + (StringUtils.isNotEmpty(queueName_work) ? " queue [" + queueName_work + "]" : "");
throw new PipeRunException(this, msg, e);
} finally {
if (admin != null) {
try {
admin.close();
} catch (TibjmsAdminException e) {
log.warn(getLogPrefix(session) + "exception on closing Tibjms Admin", e);
}
}
if (connection != null) {
try {
connection.close();
} catch (JMSException e) {
log.warn(getLogPrefix(session) + "exception on closing connection", e);
}
}
}
return result;
}
Aggregations