use of nl.nn.adapterframework.util.CredentialFactory in project iaf by ibissource.
the class JNDIBase method getJndiEnv.
protected Hashtable getJndiEnv() throws NamingException {
Properties jndiEnv = new Properties();
if (StringUtils.isNotEmpty(getJndiProperties())) {
URL url = ClassUtils.getResourceURL(classLoader, getJndiProperties());
if (url == null) {
throw new NamingException("cannot find jndiProperties from [" + getJndiProperties() + "]");
}
try {
jndiEnv.load(url.openStream());
} catch (IOException e) {
throw new NamingException("cannot load jndiProperties [" + getJndiProperties() + "] from url [" + url.toString() + "]");
}
}
if (getInitialContextFactoryName() != null)
jndiEnv.put(Context.INITIAL_CONTEXT_FACTORY, getInitialContextFactoryName());
if (getProviderURL() != null)
jndiEnv.put(Context.PROVIDER_URL, getProviderURL());
if (getAuthentication() != null)
jndiEnv.put(Context.SECURITY_AUTHENTICATION, getAuthentication());
if (getPrincipal() != null || getCredentials() != null || getJndiAuthAlias() != null) {
CredentialFactory jndiCf = new CredentialFactory(getJndiAuthAlias(), getPrincipal(), getCredentials());
if (StringUtils.isNotEmpty(jndiCf.getUsername()))
jndiEnv.put(Context.SECURITY_PRINCIPAL, jndiCf.getUsername());
if (StringUtils.isNotEmpty(jndiCf.getPassword()))
jndiEnv.put(Context.SECURITY_CREDENTIALS, jndiCf.getPassword());
}
if (getUrlPkgPrefixes() != null)
jndiEnv.put(Context.URL_PKG_PREFIXES, getUrlPkgPrefixes());
if (getSecurityProtocol() != null)
jndiEnv.put(Context.SECURITY_PROTOCOL, getSecurityProtocol());
if (log.isDebugEnabled()) {
for (Iterator it = jndiEnv.keySet().iterator(); it.hasNext(); ) {
String key = (String) it.next();
String value = jndiEnv.getProperty(key);
log.debug("jndiEnv [" + key + "] = [" + value + "]");
}
}
return jndiEnv;
}
use of nl.nn.adapterframework.util.CredentialFactory in project iaf by ibissource.
the class ShowSecurityItems method addAuthEntries.
private ArrayList<Object> addAuthEntries() {
ArrayList<Object> authEntries = new ArrayList<Object>();
Collection<Node> entries = null;
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.getOriginalConfiguration();
configString = StringResolver.substVars(configString, AppConstants.getInstance());
configString = ConfigurationUtils.getActivatedConfiguration(configuration, configString);
String ae = XmlUtils.transformXml(t, configString);
Element authEntriesElement = XmlUtils.buildElement(ae);
if (entries == null) {
entries = XmlUtils.getChildTags(authEntriesElement, "entry");
} else {
entries.addAll(XmlUtils.getChildTags(authEntriesElement, "entry"));
}
}
}
} catch (Exception e) {
authEntries.add("*** ERROR ***");
}
if (entries != null) {
Iterator<Node> iter = entries.iterator();
while (iter.hasNext()) {
Map<String, Object> ae = new HashMap<String, Object>();
Element itemElement = (Element) iter.next();
String alias = itemElement.getAttribute("alias");
ae.put("alias", alias);
CredentialFactory cf = new CredentialFactory(alias, null, null);
String userName;
String passWord;
try {
userName = cf.getUsername();
passWord = StringUtils.repeat("*", cf.getPassword().length());
} catch (Exception e) {
userName = "*** ERROR ***";
passWord = "*** ERROR ***";
}
ae.put("username", userName);
ae.put("password", passWord);
authEntries.add(ae);
}
}
return authEntries;
}
use of nl.nn.adapterframework.util.CredentialFactory in project iaf by ibissource.
the class ShowSecurityItems method addRegisteredAdapters.
private void addRegisteredAdapters(XmlBuilder securityItems) {
XmlBuilder registeredAdapters = new XmlBuilder("registeredAdapters");
securityItems.addSubElement(registeredAdapters);
for (IAdapter iAdapter : ibisManager.getRegisteredAdapters()) {
Adapter adapter = (Adapter) iAdapter;
XmlBuilder adapterXML = new XmlBuilder("adapter");
registeredAdapters.addSubElement(adapterXML);
adapterXML.addAttribute("name", adapter.getName());
Iterator recIt = adapter.getReceiverIterator();
if (recIt.hasNext()) {
XmlBuilder receiversXML = new XmlBuilder("receivers");
while (recIt.hasNext()) {
IReceiver receiver = (IReceiver) recIt.next();
XmlBuilder receiverXML = new XmlBuilder("receiver");
receiversXML.addSubElement(receiverXML);
receiverXML.addAttribute("name", receiver.getName());
if (receiver instanceof HasSender) {
ISender sender = ((HasSender) receiver).getSender();
if (sender != null) {
receiverXML.addAttribute("senderName", sender.getName());
}
}
}
adapterXML.addSubElement(receiversXML);
}
// make list of pipes to be displayed in configuration status
XmlBuilder pipesElem = new XmlBuilder("pipes");
adapterXML.addSubElement(pipesElem);
PipeLine pipeline = adapter.getPipeLine();
for (int i = 0; i < pipeline.getPipes().size(); i++) {
IPipe pipe = pipeline.getPipe(i);
String pipename = pipe.getName();
if (pipe instanceof MessageSendingPipe) {
MessageSendingPipe msp = (MessageSendingPipe) pipe;
XmlBuilder pipeElem = new XmlBuilder("pipe");
pipeElem.addAttribute("name", pipename);
ISender sender = msp.getSender();
pipeElem.addAttribute("sender", ClassUtils.nameOf(sender));
pipesElem.addSubElement(pipeElem);
if (sender instanceof WebServiceSender) {
WebServiceSender s = (WebServiceSender) sender;
String certificate = s.getCertificate();
if (StringUtils.isNotEmpty(certificate)) {
XmlBuilder certElem = new XmlBuilder("certificate");
certElem.addAttribute("name", certificate);
String certificateAuthAlias = s.getCertificateAuthAlias();
certElem.addAttribute("authAlias", certificateAuthAlias);
URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
if (certificateUrl == null) {
certElem.addAttribute("url", "");
pipeElem.addSubElement(certElem);
XmlBuilder infoElem = new XmlBuilder("info");
infoElem.setCdataValue("*** ERROR ***");
certElem.addSubElement(infoElem);
} else {
certElem.addAttribute("url", certificateUrl.toString());
pipeElem.addSubElement(certElem);
String certificatePassword = s.getCertificatePassword();
CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
String keystoreType = s.getKeystoreType();
addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
}
}
} else {
if (sender instanceof HttpSender) {
HttpSender s = (HttpSender) sender;
String certificate = s.getCertificate();
if (StringUtils.isNotEmpty(certificate)) {
XmlBuilder certElem = new XmlBuilder("certificate");
certElem.addAttribute("name", certificate);
String certificateAuthAlias = s.getCertificateAuthAlias();
certElem.addAttribute("authAlias", certificateAuthAlias);
URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
if (certificateUrl == null) {
certElem.addAttribute("url", "");
pipeElem.addSubElement(certElem);
XmlBuilder infoElem = new XmlBuilder("info");
infoElem.setCdataValue("*** ERROR ***");
certElem.addSubElement(infoElem);
} else {
certElem.addAttribute("url", certificateUrl.toString());
pipeElem.addSubElement(certElem);
String certificatePassword = s.getCertificatePassword();
CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
String keystoreType = s.getKeystoreType();
addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
}
}
} else {
if (sender instanceof FtpSender) {
FtpSender s = (FtpSender) sender;
String certificate = s.getCertificate();
if (StringUtils.isNotEmpty(certificate)) {
XmlBuilder certElem = new XmlBuilder("certificate");
certElem.addAttribute("name", certificate);
String certificateAuthAlias = s.getCertificateAuthAlias();
certElem.addAttribute("authAlias", certificateAuthAlias);
URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
if (certificateUrl == null) {
certElem.addAttribute("url", "");
pipeElem.addSubElement(certElem);
XmlBuilder infoElem = new XmlBuilder("info");
infoElem.setCdataValue("*** ERROR ***");
certElem.addSubElement(infoElem);
} else {
certElem.addAttribute("url", certificateUrl.toString());
pipeElem.addSubElement(certElem);
String certificatePassword = s.getCertificatePassword();
CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
String keystoreType = s.getCertificateType();
addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
}
}
}
}
}
}
}
}
}
use of nl.nn.adapterframework.util.CredentialFactory in project iaf by ibissource.
the class NetStorageSender method configure.
public void configure() throws ConfigurationException {
super.configure();
// Safety checks
if (getAction() == null)
throw new ConfigurationException(getLogPrefix() + "action must be specified");
if (!actions.contains(getAction()))
throw new ConfigurationException(getLogPrefix() + "unknown or invalid action [" + getAction() + "] supported actions are " + actions.toString() + "");
if (getCpCode() == null)
throw new ConfigurationException(getLogPrefix() + "cpCode must be specified");
if (!getUrl().startsWith("http"))
throw new ConfigurationException(getLogPrefix() + "url must be start with http(s)");
if (hashAlgorithm != null && !hashAlgorithms.contains(hashAlgorithm))
throw new ConfigurationException(getLogPrefix() + "unknown authenticationMethod [" + hashAlgorithm + "] supported methods are " + hashAlgorithms.toString() + "");
if (getSignVersion() < 3 || getSignVersion() > 5)
throw new ConfigurationException(getLogPrefix() + "signVersion must be either 3, 4 or 5");
ParameterList parameterList = getParameterList();
if (getAction().equals("upload") && parameterList.findParameter("file") == null)
throw new ConfigurationException(getLogPrefix() + "the upload action requires a file parameter to be present");
if (getAction().equals("rename") && parameterList.findParameter("destination") == null)
throw new ConfigurationException(getLogPrefix() + "the rename action requires a destination parameter to be present");
if (getAction().equals("mtime") && parameterList.findParameter("mtime") == null)
throw new ConfigurationException(getLogPrefix() + "the mtime action requires a mtime parameter to be present");
accessTokenCf = new CredentialFactory(getAuthAlias(), getNonce(), getAccessToken());
}
use of nl.nn.adapterframework.util.CredentialFactory in project iaf by ibissource.
the class CmisSender method getSession.
public Session getSession() {
if (session == null || !isKeepSession()) {
CredentialFactory cf = new CredentialFactory(getAuthAlias(), getUserName(), getPassword());
session = connect(cf.getUsername(), cf.getPassword());
}
return session;
}
Aggregations