Search in sources :

Example 6 with MyLoggingFacade

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

the class OA4MPServletInitializer method init.

@Override
public void init() throws ServletException {
    if (isInitRun)
        return;
    isInitRun = true;
    MyProxyDelegationServlet mps = (MyProxyDelegationServlet) getServlet();
    try {
        // mps.storeUpdates();
        mps.processStoreCheck(mps.getTransactionStore());
        mps.processStoreCheck(mps.getServiceEnvironment().getClientStore());
        mps.processStoreCheck(mps.getServiceEnvironment().getClientApprovalStore());
    } catch (IOException | SQLException e) {
        e.printStackTrace();
        throw new ServletException("Could not update table", e);
    }
    Cleanup transactionCleanup = MyProxyDelegationServlet.transactionCleanup;
    ServiceEnvironmentImpl env = (ServiceEnvironmentImpl) getEnvironment();
    MyLoggingFacade logger = env.getMyLogger();
    logger.info("Cleaning up incomplete client registrations");
    if (transactionCleanup == null) {
        transactionCleanup = new Cleanup<>(logger);
        // set it in the servlet
        MyProxyDelegationServlet.transactionCleanup = transactionCleanup;
        transactionCleanup.setStopThread(false);
        transactionCleanup.setMap(env.getTransactionStore());
        transactionCleanup.addRetentionPolicy(new ValidTimestampPolicy());
        transactionCleanup.start();
        logger.info("Starting transaction store cleanup thread");
    }
    Cleanup<Identifier, CachedObject> myproxyConnectionCleanup = MyProxyDelegationServlet.myproxyConnectionCleanup;
    if (myproxyConnectionCleanup == null) {
        myproxyConnectionCleanup = new Cleanup<Identifier, CachedObject>(logger) {

            @Override
            public List<CachedObject> age() {
                List<CachedObject> x = super.age();
                // is just trying to clean up afterwards.
                for (CachedObject co : x) {
                    Object mp = co.getValue();
                    if (mp instanceof MyProxyConnectable) {
                        try {
                            ((MyProxyConnectable) mp).close();
                        } catch (Throwable t) {
                        // don't care if it fails, get rid of it.
                        }
                    }
                }
                return x;
            }
        };
        // set it in the servlet
        MyProxyDelegationServlet.myproxyConnectionCleanup = myproxyConnectionCleanup;
        myproxyConnectionCleanup.setStopThread(false);
        Cache myproxyConnectionCache = MyProxyDelegationServlet.myproxyConnectionCache;
        if (myproxyConnectionCache == null) {
            myproxyConnectionCache = new Cache();
            // set it in the servlet
            MyProxyDelegationServlet.myproxyConnectionCache = myproxyConnectionCache;
        }
        myproxyConnectionCleanup.setMap(myproxyConnectionCache);
        myproxyConnectionCleanup.addRetentionPolicy(new ConnectionCacheRetentionPolicy(myproxyConnectionCache, env.getTransactionStore()));
        myproxyConnectionCleanup.start();
        logger.info("Starting myproxy connection cache cleanup thread");
    }
    AbstractCLIApprover.ClientApprovalThread caThread = MyProxyDelegationServlet.caThread;
    if (caThread != null && !caThread.isAlive()) {
        caThread.setStopThread(false);
        caThread.start();
    }
    KeyPairPopulationThread kpt = MyProxyDelegationServlet.kpt;
    if (kpt != null && !kpt.isAlive()) {
        kpt.setStopThread(false);
        kpt.start();
    }
    try {
        setupNotifiers();
    } catch (IOException e) {
        throw new GeneralException("Error: could not set up notifiers ", e);
    }
}
Also used : GeneralException(edu.uiuc.ncsa.security.core.exceptions.GeneralException) CachedObject(edu.uiuc.ncsa.security.core.cache.CachedObject) SQLException(java.sql.SQLException) ServiceEnvironmentImpl(edu.uiuc.ncsa.myproxy.oa4mp.server.ServiceEnvironmentImpl) ConnectionCacheRetentionPolicy(edu.uiuc.ncsa.myproxy.oa4mp.server.util.ConnectionCacheRetentionPolicy) IOException(java.io.IOException) Cleanup(edu.uiuc.ncsa.security.core.cache.Cleanup) KeyPairPopulationThread(edu.uiuc.ncsa.security.util.pkcs.KeyPairPopulationThread) ServletException(javax.servlet.ServletException) MyLoggingFacade(edu.uiuc.ncsa.security.core.util.MyLoggingFacade) MyProxyConnectable(edu.uiuc.ncsa.myproxy.MyProxyConnectable) Identifier(edu.uiuc.ncsa.security.core.Identifier) AbstractCLIApprover(edu.uiuc.ncsa.myproxy.oa4mp.server.util.AbstractCLIApprover) List(java.util.List) CachedObject(edu.uiuc.ncsa.security.core.cache.CachedObject) ValidTimestampPolicy(edu.uiuc.ncsa.security.core.cache.ValidTimestampPolicy) Cache(edu.uiuc.ncsa.security.core.cache.Cache)

Example 7 with MyLoggingFacade

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

the class ServiceConfigTest method testClientStoreProvider.

/**
 * Just reads in the configuration and calls "get" on the provider. This should work if the
 * configuration file is read.
 * @throws Exception
 */
@Test
public void testClientStoreProvider() throws Exception {
    ConfigurationNode cn = getConfig("mixed config");
    ClientProvider clientProvider = new ClientProvider(new OA4MPIdentifierProvider(OA4MPIdentifierProvider.CLIENT_ID));
    MultiDSClientStoreProvider csp = new MultiDSClientStoreProvider(cn, true, new MyLoggingFacade("test"), null, null, clientProvider);
    ClientConverter converter = new ClientConverter(clientProvider);
    csp.addListener(new DSFSClientStoreProvider(cn, converter, clientProvider));
    csp.addListener(new DSClientSQLStoreProvider(cn, new MySQLConnectionPoolProvider("oauth", "oauth"), MYSQL_STORE, converter, clientProvider));
    csp.addListener(new DSClientSQLStoreProvider(cn, new PGConnectionPoolProvider("oauth", "oauth"), POSTGRESQL_STORE, converter, clientProvider));
    ClientStore<Client> cs = (ClientStore<Client>) csp.get();
}
Also used : MultiDSClientStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientStoreProvider) ClientConverter(edu.uiuc.ncsa.security.delegation.storage.impl.ClientConverter) PGConnectionPoolProvider(edu.uiuc.ncsa.security.storage.sql.postgres.PGConnectionPoolProvider) ClientProvider(edu.uiuc.ncsa.security.delegation.storage.ClientProvider) DSFSClientStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientStoreProvider) MyLoggingFacade(edu.uiuc.ncsa.security.core.util.MyLoggingFacade) MySQLConnectionPoolProvider(edu.uiuc.ncsa.security.storage.sql.mysql.MySQLConnectionPoolProvider) ClientStore(edu.uiuc.ncsa.security.delegation.server.storage.ClientStore) DSClientSQLStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.sql.provider.DSClientSQLStoreProvider) OA4MPIdentifierProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.transactions.OA4MPIdentifierProvider) ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) Client(edu.uiuc.ncsa.security.delegation.storage.Client) ConfigTest(edu.uiuc.ncsa.security.core.configuration.ConfigTest) Test(org.junit.Test)

Example 8 with MyLoggingFacade

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

the class ClientServletInitializer method init.

@Override
public void init() throws ServletException {
    if (hasRun)
        return;
    // run it once and only once.
    hasRun = true;
    MyLoggingFacade logger = getEnvironment().getMyLogger();
    ClientEnvironment ce = (ClientEnvironment) getEnvironment();
    // This next bit is a
    if (ce.hasAssetStore()) {
        if (ce.getAssetStore() instanceof SQLStore) {
            SQLStore sqlStore = (SQLStore) ce.getAssetStore();
            try {
                sqlStore.checkTable();
                sqlStore.checkColumns();
            } catch (SQLException sqlX) {
                logger.warn("Could not update store table:" + sqlX.getMessage());
            }
        }
        Cleanup<Identifier, Asset> assetCleanup = ClientServlet.assetCleanup;
        if (ce.isEnableAssetCleanup() && assetCleanup == null) {
            assetCleanup = new Cleanup<Identifier, Asset>(logger);
            assetCleanup.setStopThread(false);
            assetCleanup.setMap(ce.getAssetStore());
            assetCleanup.addRetentionPolicy(new ValidTimestampPolicy(ce.getMaxAssetLifetime()));
            logger.info("Starting asset cleanup thread");
            assetCleanup.start();
            ClientServlet.assetCleanup = assetCleanup;
        }
    } else {
        logger.info("No assets store, so no cleanup possible.");
    }
}
Also used : MyLoggingFacade(edu.uiuc.ncsa.security.core.util.MyLoggingFacade) SQLStore(edu.uiuc.ncsa.security.storage.sql.SQLStore) Identifier(edu.uiuc.ncsa.security.core.Identifier) SQLException(java.sql.SQLException) Asset(edu.uiuc.ncsa.myproxy.oa4mp.client.Asset) ClientEnvironment(edu.uiuc.ncsa.myproxy.oa4mp.client.ClientEnvironment) ValidTimestampPolicy(edu.uiuc.ncsa.security.core.cache.ValidTimestampPolicy)

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