use of edu.uiuc.ncsa.myproxy.oa4mp.server.ServiceEnvironmentImpl 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;
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.ServiceEnvironmentImpl 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;
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.ServiceEnvironmentImpl 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.oa4mp.server.ServiceEnvironmentImpl in project OA4MP by ncsa.
the class AbstractConfigurationLoader method load.
@Override
public T load() {
info("loading configuration.");
ServiceEnvironmentImpl se2 = createInstance();
// now peel off the service address
se2.setServiceAddress(getServiceAddress());
se2.setDebugOn(Boolean.parseBoolean(Configurations.getFirstAttribute(cn, OA4MPConfigTags.DEBUG)));
DebugUtil.setIsEnabled(se2.isDebugOn());
se2.info("Debugging is " + (se2.isDebugOn() ? "on" : "off"));
// part 2. This is done after main config load.
Object[] polling = loadPolling();
if (polling != null) {
info("Loading polling for " + polling[0]);
AbstractCLIApprover.ClientApprovalThread cat = new AbstractCLIApprover.ClientApprovalThread(myLogger, se2, (File) polling[0], (Long) polling[1]);
se2.setClientApprovalThread(cat);
}
if (se2.isDebugOn()) {
info("Debug mode enabled.");
for (MyProxyServiceFacade x : se2.getMyProxyServices()) {
debug("loaded myproxy configuration for " + x.getFacadeConfiguration().getHostname() + ":" + x.getFacadeConfiguration().getPort());
}
}
return (T) se2;
}
Aggregations