use of edu.uiuc.ncsa.myproxy.MyProxyConnectable in project OA4MP by ncsa.
the class CRServlet method getX509Certificates.
/**
* Loops through the facade looking for the active connection and calls it.
*
* @param transaction
* @param localCertRequest
* @param statusString
* @return
* @throws GeneralSecurityException
*/
protected LinkedList<X509Certificate> getX509Certificates(ServiceTransaction transaction, MyPKCS10CertRequest localCertRequest, String statusString) throws GeneralSecurityException {
MyProxyConnectable mpc = getMPConnection(transaction);
mpc.setLifetime(transaction.getLifetime());
LinkedList<X509Certificate> certs = mpc.getCerts(localCertRequest);
if (certs.isEmpty()) {
info(statusString + "Error: MyProxy service returned no certs.");
throw new GeneralException("Error: MyProxy service returned no certs.");
}
info(statusString + "Got cert from MyProxy, issuing a limited proxy & storing it.");
return certs;
}
use of edu.uiuc.ncsa.myproxy.MyProxyConnectable in project OA4MP by ncsa.
the class OA2AuthorizationServer method setupMPConnection.
@Override
protected void setupMPConnection(ServiceTransaction trans, String username, String password) throws GeneralSecurityException {
if (((OA2SE) getServiceEnvironment()).isTwoFactorSupportEnabled()) {
// Stash username and password in an bogus MyProxy logon instance.
MyMyProxyLogon myProxyLogon = new MyMyProxyLogon();
myProxyLogon.setUsername(username);
myProxyLogon.setPassphrase(password);
MyProxyConnectable mpc = new MPSingleConnectionProvider.MyProxyLogonConnection(myProxyLogon);
mpc.setIdentifier(trans.getIdentifier());
getMyproxyConnectionCache().add(mpc);
} else {
createMPConnection(trans.getIdentifier(), username, password, trans.getLifetime());
if (hasMPConnection(trans.getIdentifier())) {
getMPConnection(trans.getIdentifier()).close();
}
}
}
use of edu.uiuc.ncsa.myproxy.MyProxyConnectable 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);
}
}
use of edu.uiuc.ncsa.myproxy.MyProxyConnectable in project OA4MP by ncsa.
the class CRServlet method createMPConnection.
protected MyProxyConnectable createMPConnection(Identifier identifier, String userName, String password, long lifetime, String loa) throws GeneralSecurityException {
MPConnectionProvider facades = new MPConnectionProvider(getMyLogger(), MyProxyDelegationServlet.getServiceEnvironment().getMyProxyServices());
MyProxyConnectable mpc = facades.findConnection(identifier, userName, password, loa, lifetime);
DebugUtil.dbg(this, ((MPSingleConnectionProvider.MyProxyLogonConnection) mpc).getMyProxyLogon().toString());
getMyproxyConnectionCache().add(mpc);
return mpc;
}
Aggregations