use of nl.nn.adapterframework.configuration.Configuration 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.configuration.Configuration in project iaf by ibissource.
the class ConfigurationBase method doGet.
/**
* When extending this class, copy and extend the doGet method in the new
* child class.
*/
protected String doGet(IPipeLineSession session) throws PipeRunException {
IbisManager ibisManager = RestListenerUtils.retrieveIbisManager(session);
String configurationName = null;
if (configurationName == null) {
configurationName = retrieveConfigurationName(session);
}
Configuration configuration = null;
boolean configAll;
if (configurationName == null || configurationName.equalsIgnoreCase(CONFIG_ALL)) {
configAll = true;
} else {
configuration = ibisManager.getConfiguration(configurationName);
if (configuration == null) {
configAll = true;
} else {
configAll = false;
}
}
List<Configuration> allConfigurations = ibisManager.getConfigurations();
XmlBuilder configurationsXml = toConfigurationsXml(allConfigurations);
storeConfiguration(session, configAll, configuration);
XmlBuilder root = new XmlBuilder("root");
root.addSubElement(configurationsXml);
return root.toXML();
}
use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.
the class ShowConfigurationStatus method toConfigurationExceptionsXml.
private XmlBuilder toConfigurationExceptionsXml(List<Configuration> configurations, Configuration configurationSelected) {
List<String[]> configurationExceptions = new ArrayList<String[]>();
if (configurationSelected != null) {
if (configurationSelected.getConfigurationException() != null) {
String[] item = new String[2];
item[0] = configurationSelected.getName();
item[1] = configurationSelected.getConfigurationException().getMessage();
configurationExceptions.add(item);
}
} else {
for (Configuration configuration : configurations) {
if (configuration.getConfigurationException() != null) {
String[] item = new String[2];
item[0] = configuration.getName();
item[1] = configuration.getConfigurationException().getMessage();
configurationExceptions.add(item);
}
}
}
if (!configurationExceptions.isEmpty()) {
XmlBuilder exceptionsXML = new XmlBuilder("exceptions");
for (int j = 0; j < configurationExceptions.size(); j++) {
XmlBuilder exceptionXML = new XmlBuilder("exception");
exceptionXML.addAttribute("config", configurationExceptions.get(j)[0]);
exceptionXML.setValue(configurationExceptions.get(j)[1]);
exceptionsXML.addSubElement(exceptionXML);
}
return exceptionsXML;
}
return null;
}
use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.
the class ShowConfigurationStatus method retrieveErrorStoreCounters.
private List<ErrorStoreCounter> retrieveErrorStoreCounters(List<Configuration> configurations, Configuration configurationSelected) {
List<ErrorStoreCounter> errorStoreCounters = new ArrayList<ErrorStoreCounter>();
if (SHOW_COUNT_ERRORSTORE) {
errorStoreCounters = new ArrayList<ErrorStoreCounter>();
if (configurationSelected != null) {
String config = configurationSelected.getName();
int counter = 0;
for (Iterator adapterIt = configurationSelected.getRegisteredAdapters().iterator(); adapterIt.hasNext(); ) {
Adapter adapter = (Adapter) adapterIt.next();
counter += retrieveErrorStoragesMessageCount(adapter);
}
if (counter > 0) {
errorStoreCounters.add(new ErrorStoreCounter(config, counter));
}
} else {
for (Configuration configuration : configurations) {
String config = configuration.getName();
int counter = 0;
for (Iterator adapterIt = configuration.getRegisteredAdapters().iterator(); adapterIt.hasNext(); ) {
Adapter adapter = (Adapter) adapterIt.next();
counter += retrieveErrorStoragesMessageCount(adapter);
}
if (counter > 0) {
errorStoreCounters.add(new ErrorStoreCounter(config, counter));
}
}
}
}
return errorStoreCounters;
}
use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.
the class ShowConfigurationStatus method doGet.
@Override
protected String doGet(IPipeLineSession session) throws PipeRunException {
IbisManager ibisManager = retrieveIbisManager();
String configurationName = null;
ShowConfigurationStatusManager showConfigurationStatusManager = new ShowConfigurationStatusManager();
String countStr = (String) session.get("count");
showConfigurationStatusManager.count = Boolean.parseBoolean(countStr);
String alertStr = (String) session.get("alert");
if (alertStr != null) {
showConfigurationStatusManager.alert = Boolean.parseBoolean(alertStr);
configurationName = CONFIG_ALL;
}
if (configurationName == null) {
configurationName = retrieveConfigurationName(session);
}
Configuration configuration = null;
boolean configAll;
if (configurationName == null || configurationName.equalsIgnoreCase(CONFIG_ALL)) {
configAll = true;
} else {
configuration = ibisManager.getConfiguration(configurationName);
if (configuration == null) {
configAll = true;
} else {
configAll = false;
}
}
List<Configuration> allConfigurations = ibisManager.getConfigurations();
XmlBuilder configurationsXml = toConfigurationsXml(allConfigurations);
List<IAdapter> registeredAdapters = retrieveRegisteredAdapters(ibisManager, configAll, configuration);
storeConfiguration(session, configAll, configuration);
XmlBuilder adapters = toAdaptersXml(ibisManager, allConfigurations, configuration, registeredAdapters, showConfigurationStatusManager);
XmlBuilder root = new XmlBuilder("root");
root.addSubElement(configurationsXml);
root.addSubElement(adapters);
return root.toXML();
}
Aggregations