@Override public String getPath(String contextPath) { return contextPath + format(PATH, encodeMessage(email), encodeMessage(userIdentity.getProviderLogin()), encodeMessage(provider.getKey()), encodeMessage(existingUser.getExternalLogin()), encodeMessage(existingUser.getExternalIdentityProvider())); } }
public static void redirectToUnauthorized(HttpServletResponse response) { redirectTo(response, UNAUTHORIZED_PATH); }
static void handleAuthenticationError(AuthenticationException e, HttpServletResponse response, String contextPath) { redirectTo(response, getPath(e, contextPath)); }
private static String getPath(AuthenticationException e, String contextPath) { String publicMessage = e.getPublicMessage(); if (publicMessage == null || publicMessage.isEmpty()) { return UNAUTHORIZED_PATH; } return contextPath + format(UNAUTHORIZED_PATH_WITH_MESSAGE, encodeMessage(publicMessage)); }
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())); } }
@Override public String getPath(String contextPath) { return contextPath + format(PATH, encodeMessage(userIdentity.getProviderLogin()), encodeMessage(provider.getKey()), encodeMessage(provider.getName()), encodeMessage(user.getLogin()), encodeMessage(organization.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())); } }
@Override public String getPath(String contextPath) { return contextPath + format(PATH, encodeMessage(email), encodeMessage(userIdentity.getProviderLogin()), encodeMessage(provider.getKey()), encodeMessage(existingUser.getExternalLogin()), encodeMessage(existingUser.getExternalIdentityProvider())); } }
public static void redirectToUnauthorized(HttpServletResponse response) { redirectTo(response, UNAUTHORIZED_PATH); }
private static String getPath(AuthenticationException e, String contextPath) { String publicMessage = e.getPublicMessage(); if (publicMessage == null || publicMessage.isEmpty()) { return UNAUTHORIZED_PATH; } return contextPath + format(UNAUTHORIZED_PATH_WITH_MESSAGE, encodeMessage(publicMessage)); }
static void handleAuthenticationError(AuthenticationException e, HttpServletResponse response, String contextPath) { redirectTo(response, getPath(e, contextPath)); }
@Override public String getPath(String contextPath) { return contextPath + format(PATH, encodeMessage(userIdentity.getProviderLogin()), encodeMessage(provider.getKey()), encodeMessage(provider.getName()), encodeMessage(user.getLogin()), encodeMessage(organization.getKey())); } }
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())); } }