Source:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try { HttpServletRequest req = (HttpServletRequest) request; if (!FiltersHelper.isAuthenticated(req)) { LoginUserParameters params = null; String profileName = (String) request.getAttribute(FiltersHelper.Constants.REQUEST_PROFILE_KEY); ExtMap authRecord = (ExtMap) request.getAttribute(FiltersHelper.Constants.REQUEST_AUTH_RECORD_KEY); if (authRecord != null) { String engineSessionId = UUID.randomUUID().toString(); params = new LoginUserParameters(profileName, authRecord); params.setSessionId(engineSessionId); params.setActionType(loginAsAdmin ? VdcActionType.LoginAdminUser : VdcActionType.LoginUser); InitialContext context = new InitialContext(); try { HttpSession session = req.getSession(true); if (FiltersHelper.getBackend(context).login(params).getSucceeded()) { session.setAttribute( FiltersHelper.Constants.SESSION_AUTHENTICATED_KEY, engineSessionId ); } VdcQueryReturnValue result = FiltersHelper.getBackend(context).runPublicQuery(VdcQueryType.GetConfigurationValue, new GetConfigurationValueParameters(ConfigurationValues.ApplicationMode, ConfigCommon.defaultConfigurationVersion)); ApplicationMode appMode = null; if (result.getSucceeded()) { appMode = ApplicationMode.from((Integer) result.getReturnValue()); } else { appMode = ApplicationMode.AllModes; } session.setAttribute(FiltersHelper.Constants.SESSION_APPLICATION_MODE_KEY, appMode); } finally { context.close(); } } } chain.doFilter(request, response); } catch (Exception ex) { log.error(String.format("Error in login to engine. Message is: %1$s", ex.getMessage())); ((HttpServletResponse) response).sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { boolean exceptionOccurred = false; try { HttpServletRequest req = (HttpServletRequest) request; if (!FiltersHelper.isAuthenticated(req)) { LoginUserParameters params = null; String profileName = (String) request.getAttribute(FiltersHelper.Constants.REQUEST_PROFILE_KEY); ExtMap authRecord = (ExtMap) request.getAttribute(FiltersHelper.Constants.REQUEST_AUTH_RECORD_KEY); if (authRecord != null) { String engineSessionId = UUID.randomUUID().toString(); params = new LoginUserParameters(profileName, authRecord); params.setSessionId(engineSessionId); params.setActionType(loginAsAdmin ? VdcActionType.LoginAdminUser : VdcActionType.LoginUser); InitialContext context = new InitialContext(); try { VdcReturnValueBase returnValue = FiltersHelper.getBackend(context).login(params); if (returnValue.getSucceeded()) { HttpSession session = req.getSession(true); session.setAttribute( FiltersHelper.Constants.SESSION_ENGINE_SESSION_ID_KEY, engineSessionId ); req.setAttribute(FiltersHelper.Constants.REQUEST_USER_KEY, returnValue.getActionReturnValue()); VdcQueryReturnValue result = FiltersHelper.getBackend(context) .runPublicQuery(VdcQueryType.GetConfigurationValue, new GetConfigurationValueParameters(ConfigurationValues.ApplicationMode, ConfigCommon.defaultConfigurationVersion)); if (result.getSucceeded()) { SetDataOnSessionParameters setDataParams = new SetDataOnSessionParameters( FiltersHelper.Constants.SESSION_APPLICATION_MODE_KEY, ApplicationMode.from((Integer) result.getReturnValue() )); setDataParams.setSessionId(engineSessionId); FiltersHelper.getBackend(context).runAction(VdcActionType.SetDataOnSession, setDataParams); } } } finally { context.close(); } } } } catch (Exception ex) { exceptionOccurred = true; log.error(String.format("Error in login to engine. Message is: %1$s", ex.getMessage())); ((HttpServletResponse) response).sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } if (!exceptionOccurred) { chain.doFilter(request, response); } }