use of org.apache.commons.configuration.tree.ConfigurationNode in project OA4MP by ncsa.
the class AbstractConfigurationLoader method getAuthorizationServletConfig.
public AuthorizationServletConfig getAuthorizationServletConfig() {
if (authorizationServletConfig == null) {
List kids = cn.getChildren(OA4MPConfigTags.AUTHORIZATION_SERVLET);
String headFieldName = null;
boolean requiredHeader = false;
boolean useheader = false;
boolean showLogon = true;
boolean verifyUsername = true;
boolean returnDnAsUsername = false;
boolean convertDNToGlobusID = false;
String authorizationURI = null;
if (!kids.isEmpty()) {
ConfigurationNode sn = (ConfigurationNode) kids.get(0);
try {
// implicitly uses the fact that null (so missing parameter) parses to false.
authorizationURI = getFirstAttribute(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_URI);
useheader = getCfgBoolean(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_HEADER_USE, useheader);
requiredHeader = getCfgBoolean(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_HEADER_REQUIRE, requiredHeader);
headFieldName = getFirstAttribute(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_HEADER_FIELD_NAME);
returnDnAsUsername = getCfgBoolean(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_RETURN_DN_AS_USERNAME, returnDnAsUsername);
showLogon = getCfgBoolean(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_SHOW_LOGON, showLogon);
verifyUsername = getCfgBoolean(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_VERIFY_USERNAME, verifyUsername);
convertDNToGlobusID = getCfgBoolean(sn, OA4MPConfigTags.CONVERT_DN_TO_GLOBUS_ID, convertDNToGlobusID);
} catch (Throwable t) {
info("Error loading authorization configuration. Disabling use of headers");
}
}
authorizationServletConfig = new AuthorizationServletConfig(authorizationURI, useheader, requiredHeader, headFieldName, returnDnAsUsername, showLogon, verifyUsername, convertDNToGlobusID);
}
return authorizationServletConfig;
}
use of org.apache.commons.configuration.tree.ConfigurationNode in project OA4MP by ncsa.
the class MyProxyConfigurationLoader method getMyProxyFacadeProvider.
protected LinkedList<MyProxyFacadeProvider> getMyProxyFacadeProvider() {
if (mfp == null) {
mfp = new LinkedList<MyProxyFacadeProvider>();
// This is the global default for all instances. It can be overridden below.
String defaultDN = Configurations.getFirstAttribute(cn, MYPROXY_SERVER_DN);
if (0 < cn.getChildrenCount(OA4MPConfigTags.MYPROXY)) {
List kids = cn.getChildren(OA4MPConfigTags.MYPROXY);
for (int i = 0; i < kids.size(); i++) {
ConfigurationNode currentNode = (ConfigurationNode) kids.get(i);
// Fix for CIL-196.
String currentDN = getFirstAttribute(currentNode, MYPROXY_SERVER_DN);
mfp.add(new MyProxyFacadeProvider(((ConfigurationNode) kids.get(i)), (currentDN == null ? defaultDN : currentDN)));
}
} else {
// set up with defaults
mfp.add(new MyProxyFacadeProvider());
}
}
return mfp;
}
use of org.apache.commons.configuration.tree.ConfigurationNode in project OA4MP by ncsa.
the class MyProxyFacadeProvider method get.
@Override
public MyProxyServiceFacade get() {
ServiceFacadeConfiguration sfc;
HashMap<String, Integer> loas = new HashMap<String, Integer>();
String localhostname = null;
String serverDN = null;
try {
localhostname = java.net.InetAddress.getLocalHost().getCanonicalHostName();
} catch (UnknownHostException e) {
localhostname = "localhost";
}
// start with default port.
int port = 7512;
// start with default
long socketTimeout = 0L;
if (getConfig() == null) {
// No configuration, so use the defaults.
sfc = new ServiceFacadeConfiguration(localhostname, port, socketTimeout, loas, serverDN);
// return new MyProxyServiceFacade(sfc);
} else {
serverDN = getAttribute(MYPROXY_SERVER_DN);
if (serverDN == null && hasDefaultServerDN()) {
serverDN = getDefaultServerDN();
}
try {
port = getIntAttribute(MYPROXY_PORT);
} catch (Throwable t) {
// do nothing. If the port is not given, use the default
}
try {
socketTimeout = getIntAttribute(MYPROXY_SOCKET_TIMEOUT);
} catch (Throwable t) {
// do nix.
}
if (getAttribute(MYPROXY_HOST) != null) {
localhostname = getAttribute(MYPROXY_HOST);
}
sfc = new ServiceFacadeConfiguration(localhostname, port, socketTimeout, loas, serverDN);
List list = getConfig().getChildren(MYPROXY_LOA);
if (!list.isEmpty()) {
for (Object obj : list) {
ConfigurationNode cn = (ConfigurationNode) obj;
loas.put(Configurations.getFirstAttribute(cn, MYPROXY_LOA_NAME), Integer.parseInt(Configurations.getFirstAttribute(cn, MYPROXY_LOA_PORT)));
}
}
}
// Unless there is something very exotic about your setup, a basic configuration that
// points to the standard keystore available in java should be more than sufficient.
SSLKeystoreConfiguration sslKeystoreConfiguration = SSLConfigurationUtil.getSSLConfiguration(null, getConfig());
return new MyProxyServiceFacade(sfc, sslKeystoreConfiguration);
}
use of org.apache.commons.configuration.tree.ConfigurationNode in project OA4MP by ncsa.
the class ClientConfigTest method testConfig.
@Test
public void testConfig() throws Exception {
ConfigurationNode cn = getConfig("sample");
say("id = " + Configurations.getNodeValue(cn, "id"));
printNodes(cn);
}
use of org.apache.commons.configuration.tree.ConfigurationNode in project OA4MP by ncsa.
the class CopyTool method getEnv.
protected ServiceEnvironmentImpl getEnv(String cfgFileOption, String cfgNameOption) {
if (getCommandLine().getOptionValue(SOURCE_CONFIG_NAME_OPTION).equals(getCommandLine().getOptionValue(TARGET_CONFIG_NAME_OPTION))) {
throw new MyConfigurationException("Error! You have specified that source and target as the same.");
}
String fileName = getCommandLine().getOptionValue(cfgFileOption);
if (fileName == null) {
fileName = getCommandLine().getOptionValue(SOURCE_CONFIG_FILE_OPTION);
}
String configName = getCommandLine().getOptionValue(cfgNameOption);
sayv("loading configuration \"" + (configName == null ? "(none)" : configName) + "\" from file " + fileName);
ConfigurationNode node = ConfigUtil.findConfiguration(fileName, getCommandLine().getOptionValue(cfgNameOption), OA4MPConfigTags.COMPONENT);
// override the logging in the configuration file, since that might be remote.
ConfigurationLoader loader = null;
setConfigurationNode(node);
try {
loader = getLoader();
} catch (Exception e) {
throw new GeneralException("Error: Could not get loader", e);
}
// new CILogonConfigurationLoader(node, getMyLogger());
ServiceEnvironmentImpl env = (ServiceEnvironmentImpl) loader.load();
return env;
}
Aggregations