Search in sources :

Example 1 with ServiceFacadeConfiguration

use of edu.uiuc.ncsa.myproxy.ServiceFacadeConfiguration 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);
}
Also used : UnknownHostException(java.net.UnknownHostException) HashMap(java.util.HashMap) SSLKeystoreConfiguration(edu.uiuc.ncsa.security.util.ssl.SSLKeystoreConfiguration) ServiceFacadeConfiguration(edu.uiuc.ncsa.myproxy.ServiceFacadeConfiguration) ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) MyProxyServiceFacade(edu.uiuc.ncsa.myproxy.MyProxyServiceFacade) List(java.util.List)

Aggregations

MyProxyServiceFacade (edu.uiuc.ncsa.myproxy.MyProxyServiceFacade)1 ServiceFacadeConfiguration (edu.uiuc.ncsa.myproxy.ServiceFacadeConfiguration)1 SSLKeystoreConfiguration (edu.uiuc.ncsa.security.util.ssl.SSLKeystoreConfiguration)1 UnknownHostException (java.net.UnknownHostException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ConfigurationNode (org.apache.commons.configuration.tree.ConfigurationNode)1