use of password.pwm.PwmApplicationMode in project pwm by pwm-project.
the class ConfigAccessFilter method processFilter.
@Override
void processFilter(final PwmApplicationMode mode, final PwmRequest pwmRequest, final PwmFilterChain filterChain) throws PwmException, IOException, ServletException {
final PwmApplicationMode appMode = pwmRequest.getPwmApplication().getApplicationMode();
if (appMode == PwmApplicationMode.NEW) {
filterChain.doFilter();
return;
}
final boolean blockOldIE = Boolean.parseBoolean(pwmRequest.getPwmApplication().getConfig().readAppProperty(AppProperty.CONFIG_EDITOR_BLOCK_OLD_IE));
if (blockOldIE) {
try {
UserAgentUtils.checkIfPreIE11(pwmRequest);
} catch (PwmException e) {
pwmRequest.respondWithError(e.getErrorInformation());
return;
}
}
final ConfigManagerBean configManagerBean = pwmRequest.getPwmApplication().getSessionStateService().getBean(pwmRequest, ConfigManagerBean.class);
if (checkAuthentication(pwmRequest, configManagerBean) == ProcessStatus.Continue) {
filterChain.doFilter();
}
}
use of password.pwm.PwmApplicationMode in project pwm by pwm-project.
the class RequestInitializationFilter method doFilter.
public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
final HttpServletRequest req = (HttpServletRequest) servletRequest;
final HttpServletResponse resp = (HttpServletResponse) servletResponse;
final PwmApplicationMode mode = PwmApplicationMode.determineMode(req);
final PwmURL pwmURL = new PwmURL(req);
PwmApplication testPwmApplicationLoad = null;
try {
testPwmApplicationLoad = ContextManager.getPwmApplication(req);
} catch (PwmException e) {
}
if (testPwmApplicationLoad != null && mode == PwmApplicationMode.RUNNING) {
if (testPwmApplicationLoad.getStatisticsManager() != null) {
testPwmApplicationLoad.getStatisticsManager().updateEps(EpsStatistic.REQUESTS, 1);
}
}
if (testPwmApplicationLoad == null && pwmURL.isResourceURL()) {
filterChain.doFilter(req, resp);
} else if (pwmURL.isRestService()) {
filterChain.doFilter(req, resp);
} else {
if (mode == PwmApplicationMode.ERROR) {
try {
final ContextManager contextManager = ContextManager.getContextManager(req.getServletContext());
if (contextManager != null) {
final ErrorInformation startupError = contextManager.getStartupErrorInformation();
servletRequest.setAttribute(PwmRequestAttribute.PwmErrorInfo.toString(), startupError);
}
} catch (Exception e) {
if (pwmURL.isResourceURL()) {
filterChain.doFilter(servletRequest, servletResponse);
return;
}
LOGGER.error("error while trying to detect application status: " + e.getMessage());
}
LOGGER.error("unable to satisfy incoming request, application is not available");
resp.setStatus(500);
final String url = JspUrl.APP_UNAVAILABLE.getPath();
servletRequest.getServletContext().getRequestDispatcher(url).forward(servletRequest, servletResponse);
} else {
initializeServletRequest(req, resp, filterChain);
}
}
}
Aggregations