public boolean initUserSession(HttpServletRequest request, HttpServletResponse response) { String path = request.getRequestURI().replaceFirst(request.getContextPath(), ""); try { // Do not set user session when url is excluded if (URL_PATTERN.matches(path)) { loadUserSession(request, response, PASSCODE_URLS.matches(path)); } return true; } catch (AuthenticationException e) { authenticationEvent.loginFailure(request, e); if (isWsUrl(path)) { response.setStatus(HTTP_UNAUTHORIZED); return false; } if (isNotLocalOrJwt(e.getSource())) { // redirect to Unauthorized error page handleAuthenticationError(e, response, request.getContextPath()); return false; } // Web pages should redirect to the index.html file return true; } }
private void handleProvider(HttpServletRequest request, HttpServletResponse response, IdentityProvider provider) { try { if (provider instanceof OAuth2IdentityProvider) { handleOAuth2Provider(response, request, (OAuth2IdentityProvider) provider); } else { handleError(response, format("Not an OAuth2IdentityProvider: %s", provider.getClass())); } } catch (AuthenticationException e) { oauth2Parameters.delete(request, response); authenticationEvent.loginFailure(request, e); handleAuthenticationError(e, response, getContextPath()); } catch (RedirectionException e) { oauth2Parameters.delete(request, response); redirectTo(response, e.getPath(getContextPath())); } catch (Exception e) { oauth2Parameters.delete(request, response); handleError(e, response, format("Fail to callback authentication with '%s'", provider.getKey())); } }
private void handleProvider(HttpServletRequest request, HttpServletResponse response, IdentityProvider provider) { try { if (provider instanceof BaseIdentityProvider) { handleBaseIdentityProvider(request, response, (BaseIdentityProvider) provider); } else if (provider instanceof OAuth2IdentityProvider) { oAuthOAuth2AuthenticationParameters.init(request, response); handleOAuth2IdentityProvider(request, response, (OAuth2IdentityProvider) provider); } else { handleError(response, format("Unsupported IdentityProvider class: %s", provider.getClass())); } } catch (AuthenticationException e) { oAuthOAuth2AuthenticationParameters.delete(request, response); authenticationEvent.loginFailure(request, e); handleAuthenticationError(e, response, getContextPath()); } catch (RedirectionException e) { oAuthOAuth2AuthenticationParameters.delete(request, response); redirectTo(response, e.getPath(getContextPath())); } catch (Exception e) { oAuthOAuth2AuthenticationParameters.delete(request, response); handleError(e, response, format("Fail to initialize authentication with provider '%s'", provider.getKey())); } }
public boolean initUserSession(HttpServletRequest request, HttpServletResponse response) { String path = request.getRequestURI().replaceFirst(request.getContextPath(), ""); try { // Do not set user session when url is excluded if (URL_PATTERN.matches(path)) { loadUserSession(request, response, PASSCODE_URLS.matches(path)); } return true; } catch (AuthenticationException e) { authenticationEvent.loginFailure(request, e); if (isWsUrl(path)) { response.setStatus(HTTP_UNAUTHORIZED); return false; } if (isNotLocalOrJwt(e.getSource())) { // redirect to Unauthorized error page handleAuthenticationError(e, response, request.getContextPath()); return false; } // Web pages should redirect to the index.html file return true; } }
private void handleProvider(HttpServletRequest request, HttpServletResponse response, IdentityProvider provider) { try { if (provider instanceof OAuth2IdentityProvider) { handleOAuth2Provider(response, request, (OAuth2IdentityProvider) provider); } else { handleError(response, format("Not an OAuth2IdentityProvider: %s", provider.getClass())); } } catch (AuthenticationException e) { oauth2Parameters.delete(request, response); authenticationEvent.loginFailure(request, e); handleAuthenticationError(e, response, getContextPath()); } catch (RedirectionException e) { oauth2Parameters.delete(request, response); redirectTo(response, e.getPath(getContextPath())); } catch (Exception e) { oauth2Parameters.delete(request, response); handleError(e, response, format("Fail to callback authentication with '%s'", provider.getKey())); } }
private void handleProvider(HttpServletRequest request, HttpServletResponse response, IdentityProvider provider) { try { if (provider instanceof BaseIdentityProvider) { handleBaseIdentityProvider(request, response, (BaseIdentityProvider) provider); } else if (provider instanceof OAuth2IdentityProvider) { oAuthOAuth2AuthenticationParameters.init(request, response); handleOAuth2IdentityProvider(request, response, (OAuth2IdentityProvider) provider); } else { handleError(response, format("Unsupported IdentityProvider class: %s", provider.getClass())); } } catch (AuthenticationException e) { oAuthOAuth2AuthenticationParameters.delete(request, response); authenticationEvent.loginFailure(request, e); handleAuthenticationError(e, response, getContextPath()); } catch (RedirectionException e) { oAuthOAuth2AuthenticationParameters.delete(request, response); redirectTo(response, e.getPath(getContextPath())); } catch (Exception e) { oAuthOAuth2AuthenticationParameters.delete(request, response); handleError(e, response, format("Fail to initialize authentication with provider '%s'", provider.getKey())); } }