List of usage examples for org.springframework.security.oauth2.client.resource UserRedirectRequiredException getRequestParams
public Map<String, String> getRequestParams()
From source file:org.meruvian.yama.webapp.interceptor.OAuth2ClientContextInterceptor.java
/** * Redirect the user according to the specified exception. * //from ww w. jav a2 s.c o m * @param resourceThatNeedsAuthorization * @param e The user redirect exception. * @param request The request. * @param response The response. */ protected void redirectUser(UserRedirectRequiredException e, HttpServletRequest request, HttpServletResponse response) throws IOException { String redirectUri = e.getRedirectUri(); StringBuilder builder = new StringBuilder(redirectUri); Map<String, String> requestParams = e.getRequestParams(); char appendChar = redirectUri.indexOf('?') < 0 ? '?' : '&'; for (Map.Entry<String, String> param : requestParams.entrySet()) { try { builder.append(appendChar).append(param.getKey()).append('=') .append(URLEncoder.encode(param.getValue(), "UTF-8")); } catch (UnsupportedEncodingException uee) { throw new IllegalStateException(uee); } appendChar = '&'; } if (e.getStateKey() != null) { builder.append(appendChar).append("state").append('=').append(e.getStateKey()); } this.redirectStrategy.sendRedirect(request, response, builder.toString()); }