Search in sources :

Example 1 with KeyPairPopulationThread

use of edu.uiuc.ncsa.security.util.pkcs.KeyPairPopulationThread in project OA4MP by ncsa.

the class MyProxyDelegationServlet method loadProperties2.

@Override
public ServiceEnvironmentImpl loadProperties2() throws IOException {
    ServiceEnvironmentImpl se2 = super.loadProperties2();
    if (se2.isPollingEnabled()) {
        caThread = se2.getClientApprovalThread();
    }
    kpt = new KeyPairPopulationThread(se2.getKeyPairQueue());
    return se2;
}
Also used : ServiceEnvironmentImpl(edu.uiuc.ncsa.myproxy.oa4mp.server.ServiceEnvironmentImpl) KeyPairPopulationThread(edu.uiuc.ncsa.security.util.pkcs.KeyPairPopulationThread)

Example 2 with KeyPairPopulationThread

use of edu.uiuc.ncsa.security.util.pkcs.KeyPairPopulationThread 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)

Aggregations

ServiceEnvironmentImpl (edu.uiuc.ncsa.myproxy.oa4mp.server.ServiceEnvironmentImpl)2 KeyPairPopulationThread (edu.uiuc.ncsa.security.util.pkcs.KeyPairPopulationThread)2 MyProxyConnectable (edu.uiuc.ncsa.myproxy.MyProxyConnectable)1 AbstractCLIApprover (edu.uiuc.ncsa.myproxy.oa4mp.server.util.AbstractCLIApprover)1 ConnectionCacheRetentionPolicy (edu.uiuc.ncsa.myproxy.oa4mp.server.util.ConnectionCacheRetentionPolicy)1 Identifier (edu.uiuc.ncsa.security.core.Identifier)1 Cache (edu.uiuc.ncsa.security.core.cache.Cache)1 CachedObject (edu.uiuc.ncsa.security.core.cache.CachedObject)1 Cleanup (edu.uiuc.ncsa.security.core.cache.Cleanup)1 ValidTimestampPolicy (edu.uiuc.ncsa.security.core.cache.ValidTimestampPolicy)1 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)1 MyLoggingFacade (edu.uiuc.ncsa.security.core.util.MyLoggingFacade)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 List (java.util.List)1 ServletException (javax.servlet.ServletException)1