Source:
<code>protected void authenticateWithSSO(HttpServletRequest req, HttpServletResponse res) throws ServletException { String headerValue = req.getHeader(FiltersHelper.Constants.HEADER_AUTHORIZATION); if (headerValue != null && (headerValue.startsWith(BASIC) || headerValue.startsWith(BEARER))) { try { String token; boolean userSessionExists = false; if (headerValue.startsWith(BASIC)) { Map<String, Object> response = SSOOAuthServiceUtils.authenticate(req, res, scope); FiltersHelper.isStatusOk(response); token = (String) response.get("access_token"); } else if (headerValue.startsWith(BEARER)) { token = headerValue.substring("Bearer ".length()); InitialContext ctx = new InitialContext(); try { VdcQueryReturnValue queryRetVal = FiltersHelper.getBackend(ctx).runPublicQuery( VdcQueryType.GetEngineSessionIdForSSOToken, new GetEngineSessionIdForSSOTokenQueryParameters(token)); if (queryRetVal.getSucceeded()) { req.setAttribute( SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY, queryRetVal.getReturnValue()); req.getSession(true).setAttribute( SessionConstants.SSO_TOKEN_KEY, token); req.getSession(true).setAttribute( SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY, <START> queryRetVal.getReturnValue()); <END> userSessionExists = true; } } finally { ctx.close(); } } else { throw new RuntimeException(String.format("Unsupported authentication header: %s", headerValue)); } if (!userSessionExists) { SSOUtils.createUserSession(req, FiltersHelper.getPayloadForToken(res, token), false); req.setAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY, req.getSession().getAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY)); } } catch (Exception e) { log.error("Cannot authenticate using authentication Headers: {}", e.getMessage()); log.debug("Cannot authenticate using authentication Headers", e); } } }</code><technical_language>need</technical_language>

Target:
protected void authenticateWithSSO(HttpServletRequest req, HttpServletResponse res) throws ServletException { String headerValue = req.getHeader(FiltersHelper.Constants.HEADER_AUTHORIZATION); if (headerValue != null && (headerValue.startsWith(BASIC) || headerValue.startsWith(BEARER))) { try { String token; boolean userSessionExists = false; if (headerValue.startsWith(BASIC)) { Map<String, Object> response = SSOOAuthServiceUtils.authenticate(req, res, scope); FiltersHelper.isStatusOk(response); token = (String) response.get("access_token"); } else if (headerValue.startsWith(BEARER)) { token = headerValue.substring("Bearer".length()).trim(); InitialContext ctx = new InitialContext(); try { VdcQueryReturnValue queryRetVal = FiltersHelper.getBackend(ctx).runPublicQuery( VdcQueryType.GetEngineSessionIdForSSOToken, new GetEngineSessionIdForSSOTokenQueryParameters(token)); if (queryRetVal.getSucceeded()) { req.getSession(true).setAttribute( SessionConstants.SSO_TOKEN_KEY, token); req.getSession(true).setAttribute( SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY, queryRetVal.getReturnValue()); userSessionExists = true; } } finally { ctx.close(); } } else { throw new RuntimeException(String.format("Unsupported authentication header: %s", headerValue)); } if (!userSessionExists) { SSOUtils.createUserSession(req, FiltersHelper.getPayloadForToken(res, token), false); req.setAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY, req.getSession().getAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY)); } } catch (Exception e) { log.error("Cannot authenticate using authentication Headers: {}", e.getMessage()); log.debug("Cannot authenticate using authentication Headers", e); } } }