Search in sources :

Example 1 with MyLoggingFacade

use of edu.uiuc.ncsa.security.core.util.MyLoggingFacade in project OA4MP by ncsa.

the class MyProxyLogon method main.

/**
 * Provides a simple command-line interface.
 */
public static void main(String[] args) {
    try {
        Logger logger = Logger.getLogger(MyProxyLogon.class.getName());
        logger.setUseParentHandlers(false);
        MyLoggingFacade facade = new MyLoggingFacade(logger);
        MyProxyLogon m = new MyProxyLogon(facade);
        // MyLoggingFacade myLoggingFacade = new MyLoggingFacade(MyProxyLogon.class.getName());
        // MyProxyLogon m = new MyProxyLogon(myLoggingFacade);
        // Console cons = System.console();
        String passphrase = null;
        X509Certificate[] CAcerts;
        X509CRL[] CRLs;
        // MyProxyLogon.logger.setLevel(Level.ALL);
        // Turn on for debugging if needed.
        // if (cons != null) {
        // char[] pass = cons.readPassword("[%s]", "MyProxy Passphrase:
        // ");
        // if (pass != null) {
        // passphrase = new String(pass);
        // }
        // } else {
        System.out.println("Warning: terminal will echo passphrase as you type.");
        System.out.print("MyProxy Passphrase: ");
        passphrase = m.readLine(System.in);
        // }
        if (passphrase == null) {
            System.err.println("Error reading passphrase.");
            System.exit(1);
        }
        m.setPassphrase(passphrase);
        m.requestTrustRoots(true);
        m.getCredentials();
        m.writeProxyFile();
        System.out.println("Credential written successfully.");
        CAcerts = m.getTrustedCAs();
        if (CAcerts != null) {
            System.out.println(Integer.toString(CAcerts.length) + " CA certificates received.");
        }
        CRLs = m.getCRLs();
        if (CRLs != null) {
            System.out.println(Integer.toString(CRLs.length) + " CRLs received.");
        }
        if (m.writeTrustRoots()) {
            System.out.println("Wrote trust roots to " + MyProxyLogon.getTrustRootPath() + ".");
        } else {
            System.out.println("Received no trust roots from MyProxy server.");
        }
    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
}
Also used : MyLoggingFacade(edu.uiuc.ncsa.security.core.util.MyLoggingFacade) X509CRL(java.security.cert.X509CRL) Logger(java.util.logging.Logger) X509Certificate(java.security.cert.X509Certificate) GeneralException(edu.uiuc.ncsa.security.core.exceptions.GeneralException) GeneralSecurityException(java.security.GeneralSecurityException) FailedLoginException(javax.security.auth.login.FailedLoginException) CertificateException(java.security.cert.CertificateException) UnknownHostException(java.net.UnknownHostException) ProtocolException(java.net.ProtocolException)

Example 2 with MyLoggingFacade

use of edu.uiuc.ncsa.security.core.util.MyLoggingFacade in project OA4MP by ncsa.

the class OA4MPServletInitializer method setupNotifiers.

public void setupNotifiers() throws IOException {
    // do this once or you will have a message sent for each listener!
    if (notifiersSet)
        return;
    MyProxyDelegationServlet mps = (MyProxyDelegationServlet) getServlet();
    ServiceEnvironmentImpl env = (ServiceEnvironmentImpl) getEnvironment();
    MyLoggingFacade logger = env.getMyLogger();
    // debugging this...
    NewClientNotifier newClientNotifier = createNewClientNotifier(env.getMailUtil(), logger);
    MyProxyDelegationServlet.addNotificationListener(newClientNotifier);
    MailUtil x = new MailUtil(env.getMailUtil().getMailEnvironment());
    String fName = mps.getServletContext().getInitParameter(ERROR_NOTIFICATION_SUBJECT_KEY);
    if (fName == null) {
        logger.info("No error notification subject set. Skipping...");
        notifiersSet = true;
        return;
    } else {
        logger.info("Set error notification subject to " + fName);
    }
    x.setSubjectTemplate(getTemplate(new File(fName)));
    fName = mps.getServletContext().getInitParameter(ERROR_NOTIFICATION_BODY_KEY);
    if (fName == null) {
        logger.info("No error notification message body set. Skipping...");
        notifiersSet = true;
        return;
    } else {
        logger.info("Set error notification message body to " + fName);
    }
    x.setMessageTemplate(getTemplate(new File(fName)));
    ExceptionEventNotifier exceptionNotifier = new ExceptionEventNotifier(x, logger);
    MyProxyDelegationServlet.addNotificationListener(exceptionNotifier);
    notifiersSet = true;
}
Also used : MyLoggingFacade(edu.uiuc.ncsa.security.core.util.MyLoggingFacade) NewClientNotifier(edu.uiuc.ncsa.myproxy.oa4mp.server.util.NewClientNotifier) ExceptionEventNotifier(edu.uiuc.ncsa.myproxy.oa4mp.server.util.ExceptionEventNotifier) ServiceEnvironmentImpl(edu.uiuc.ncsa.myproxy.oa4mp.server.ServiceEnvironmentImpl) MailUtil(edu.uiuc.ncsa.security.util.mail.MailUtil) File(java.io.File)

Example 3 with MyLoggingFacade

use of edu.uiuc.ncsa.security.core.util.MyLoggingFacade in project OA4MP by ncsa.

the class AbstractClientBootstrapper method getConfigurationLoader.

@Override
public ConfigurationLoader getConfigurationLoader(ServletContext servletContext) throws Exception {
    MyLoggingFacade logger = new MyLoggingFacade(getClass().getSimpleName());
    logger.info("Starting to load configuration");
    try {
        ConfigurationLoader x = getConfigurationLoader(ServletConfigUtil.findConfigurationNode(servletContext, getOa4mpConfigFileKey(), getOa4mpConfigNameKey(), ClientXMLTags.COMPONENT));
        logger.info("Loaded configuration named " + servletContext.getInitParameter(getOa4mpConfigNameKey()) + " from file " + servletContext.getInitParameter(getOa4mpConfigFileKey()));
        return x;
    } catch (MyConfigurationException ce) {
        logger.info("Did not find a configuration via the servlet context:" + ce.getMessage());
    }
    logger.info("No configuration found in servlet context. Trying default locations");
    // That didn't work, so try to look for it in a few other places.
    String configName = servletContext.getInitParameter(getOa4mpConfigNameKey());
    ConfigurationLoader loader = loadFromDefaultLocations(logger, configName);
    if (loader != null) {
        return loader;
    }
    MyConfigurationException cx = new MyConfigurationException("Error: No configuration found anyplace. OA4MP client startup aborted!");
    logger.error(cx);
    throw cx;
}
Also used : MyLoggingFacade(edu.uiuc.ncsa.security.core.util.MyLoggingFacade) MyConfigurationException(edu.uiuc.ncsa.security.core.exceptions.MyConfigurationException) ConfigurationLoader(edu.uiuc.ncsa.security.core.util.ConfigurationLoader)

Example 4 with MyLoggingFacade

use of edu.uiuc.ncsa.security.core.util.MyLoggingFacade in project OA4MP by ncsa.

the class OA2ConfigurationLoader method getMLDAP.

protected MultiLDAPStoreProvider getMLDAP() {
    if (mldap == null) {
        mldap = new MultiLDAPStoreProvider(cn, isDefaultStoreDisabled(), (MyLoggingFacade) loggerProvider.get(), null, null, LDAPStoreProviderUtil.getLdapEntryProvider());
        mldap.addListener(LDAPStoreProviderUtil.getM(cn));
        mldap.addListener(LDAPStoreProviderUtil.getFSP(cn));
        mldap.addListener(LDAPStoreProviderUtil.getMariaDB(cn, getMariaDBConnectionPoolProvider()));
        mldap.addListener(LDAPStoreProviderUtil.getMysql(cn, getMySQLConnectionPoolProvider()));
        mldap.addListener(LDAPStoreProviderUtil.getPG(cn, getPgConnectionPoolProvider()));
    }
    return mldap;
}
Also used : MyLoggingFacade(edu.uiuc.ncsa.security.core.util.MyLoggingFacade) MultiLDAPStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.oauth2.cm.ldap.MultiLDAPStoreProvider)

Example 5 with MyLoggingFacade

use of edu.uiuc.ncsa.security.core.util.MyLoggingFacade in project OA4MP by ncsa.

the class ServiceConfigTest method testClientApprovalStoreProvider.

public void testClientApprovalStoreProvider() throws Exception {
    ConfigurationNode cn = getConfig("postgresql config");
    MultiDSClientApprovalStoreProvider dap = new MultiDSClientApprovalStoreProvider(cn, true, new MyLoggingFacade("test"), null, null);
    ClientApproverConverter cp = new ClientApproverConverter(new ClientApprovalProvider());
    dap.addListener(new DSFSClientApprovalStoreProvider(cn, cp));
    dap.addListener(new DSSQLClientApprovalStoreProvider(cn, new MySQLConnectionPoolProvider("oauth", "oauth"), MYSQL_STORE, cp));
    dap.addListener(new DSSQLClientApprovalStoreProvider(cn, new PGConnectionPoolProvider("oauth", "oauth"), POSTGRESQL_STORE, cp));
    ClientApprovalStore<ClientApproval> as = (ClientApprovalStore<ClientApproval>) dap.get();
}
Also used : MultiDSClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientApprovalStoreProvider) MyLoggingFacade(edu.uiuc.ncsa.security.core.util.MyLoggingFacade) MySQLConnectionPoolProvider(edu.uiuc.ncsa.security.storage.sql.mysql.MySQLConnectionPoolProvider) PGConnectionPoolProvider(edu.uiuc.ncsa.security.storage.sql.postgres.PGConnectionPoolProvider) ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) DSFSClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStoreProvider) ClientApproverConverter(edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter) ClientApprovalStore(edu.uiuc.ncsa.security.delegation.server.storage.ClientApprovalStore) ClientApprovalProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.ClientApprovalProvider) DSSQLClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.sql.provider.DSSQLClientApprovalStoreProvider)

Aggregations

MyLoggingFacade (edu.uiuc.ncsa.security.core.util.MyLoggingFacade)8 ServiceEnvironmentImpl (edu.uiuc.ncsa.myproxy.oa4mp.server.ServiceEnvironmentImpl)2 Identifier (edu.uiuc.ncsa.security.core.Identifier)2 ValidTimestampPolicy (edu.uiuc.ncsa.security.core.cache.ValidTimestampPolicy)2 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)2 MySQLConnectionPoolProvider (edu.uiuc.ncsa.security.storage.sql.mysql.MySQLConnectionPoolProvider)2 PGConnectionPoolProvider (edu.uiuc.ncsa.security.storage.sql.postgres.PGConnectionPoolProvider)2 SQLException (java.sql.SQLException)2 ConfigurationNode (org.apache.commons.configuration.tree.ConfigurationNode)2 MyProxyConnectable (edu.uiuc.ncsa.myproxy.MyProxyConnectable)1 Asset (edu.uiuc.ncsa.myproxy.oa4mp.client.Asset)1 ClientEnvironment (edu.uiuc.ncsa.myproxy.oa4mp.client.ClientEnvironment)1 MultiLDAPStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.cm.ldap.MultiLDAPStoreProvider)1 ClientApprovalProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.ClientApprovalProvider)1 OA4MPIdentifierProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.transactions.OA4MPIdentifierProvider)1 MultiDSClientApprovalStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientApprovalStoreProvider)1 MultiDSClientStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientStoreProvider)1 DSFSClientApprovalStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStoreProvider)1 DSFSClientStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientStoreProvider)1 DSClientSQLStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.sql.provider.DSClientSQLStoreProvider)1