Skip to content

Commit

Permalink
Added logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
at88mph committed May 6, 2024
1 parent 110faaf commit 112523a
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import ca.nrc.cadc.auth.AuthenticationUtil;
import ca.nrc.cadc.auth.IdentityManager;
import org.apache.log4j.Logger;
import org.opencadc.posix.mapper.auth.DelegatingAPIKeyIdentityManager;

import javax.servlet.ServletContextEvent;
Expand All @@ -12,17 +13,23 @@
* A bit of an ugly hack to reset the IdentityManager with a delegating one.
*/
public class PosixMapperListener implements ServletContextListener {
public static final Logger LOGGER = Logger.getLogger(PosixMapperListener.class);

@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
LOGGER.debug("contextInitialized: START");
DelegatingAPIKeyIdentityManager.DELEGATED_IDENTITY_MANAGER = AuthenticationUtil.getIdentityManager();
System.setProperty(IdentityManager.class.getName(), DelegatingAPIKeyIdentityManager.class.getName());
LOGGER.debug("contextInitialized: OK");
}

@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
LOGGER.debug("contextDestroyed: START");
// Reset.
System.setProperty(IdentityManager.class.getName(),
DelegatingAPIKeyIdentityManager.DELEGATED_IDENTITY_MANAGER.getClass().getName());
DelegatingAPIKeyIdentityManager.DELEGATED_IDENTITY_MANAGER = null;
LOGGER.debug("contextDestroyed: OK");
}
}

0 comments on commit 112523a

Please sign in to comment.