@Test public void testWithParam() throws Exception { request = new MockHttpServletRequest("GET", "http: request.setQueryString("pP_announcementId=1834"); request.setCharacterEncoding("UTF-8"); assertEquals( "https: encoder.encodeLoginAndRefUrl(request)); }
@Override public String encodeLoginAndRefUrl(HttpServletRequest request) throws UnsupportedEncodingException { final String requestEncoding = request.getCharacterEncoding(); final StringBuilder loginRedirect = new StringBuilder(); loginRedirect.append(casLoginUrl); loginRedirect.append(URLEncoder.encode("?", requestEncoding)); loginRedirect.append( URLEncoder.encode(LoginController.REFERER_URL_PARAM + "=", requestEncoding)); loginRedirect.append(URLEncoder.encode(request.getRequestURI(), requestEncoding)); final String queryString = request.getQueryString(); if (queryString != null) { String firstEncoding = URLEncoder.encode("?" + queryString, requestEncoding); loginRedirect.append(URLEncoder.encode(firstEncoding, requestEncoding)); } return urlCustomizer.customizeUrl(request, loginRedirect.toString()); }
CasLoginRefUrlEncoder implements LoginRefUrlEncoder { @Override public String encodeLoginAndRefUrl(HttpServletRequest request) throws UnsupportedEncodingException { final String requestEncoding = request.getCharacterEncoding(); final StringBuilder loginRedirect = new StringBuilder(); loginRedirect.append(casLoginUrl); loginRedirect.append(URLEncoder.encode("?", requestEncoding)); loginRedirect.append( URLEncoder.encode(LoginController.REFERER_URL_PARAM + "=", requestEncoding)); loginRedirect.append(URLEncoder.encode(request.getRequestURI(), requestEncoding)); final String queryString = request.getQueryString(); if (queryString != null) { String firstEncoding = URLEncoder.encode("?" + queryString, requestEncoding); loginRedirect.append(URLEncoder.encode(firstEncoding, requestEncoding)); } return urlCustomizer.customizeUrl(request, loginRedirect.toString()); } }
CasLoginRefUrlEncoder implements LoginRefUrlEncoder { @Override public String encodeLoginAndRefUrl(HttpServletRequest request) throws UnsupportedEncodingException { final String requestEncoding = request.getCharacterEncoding(); final StringBuilder loginRedirect = new StringBuilder(); loginRedirect.append(casLoginUrl); loginRedirect.append(URLEncoder.encode("?", requestEncoding)); loginRedirect.append( URLEncoder.encode(LoginController.REFERER_URL_PARAM + "=", requestEncoding)); loginRedirect.append(URLEncoder.encode(request.getRequestURI(), requestEncoding)); final String queryString = request.getQueryString(); if (queryString != null) { String firstEncoding = URLEncoder.encode("?" + queryString, requestEncoding); loginRedirect.append(URLEncoder.encode(firstEncoding, requestEncoding)); } return urlCustomizer.customizeUrl(request, loginRedirect.toString()); }  }
CasLoginRefUrlEncoder implements LoginRefUrlEncoder { @Override public String encodeLoginAndRefUrl(HttpServletRequest request) throws UnsupportedEncodingException { final String requestEncoding = request.getCharacterEncoding(); final StringBuilder loginRedirect = new StringBuilder(); loginRedirect.append(casLoginUrl); loginRedirect.append(URLEncoder.encode("?", requestEncoding)); loginRedirect.append( URLEncoder.encode(LoginController.REFERER_URL_PARAM + "=", requestEncoding)); loginRedirect.append(URLEncoder.encode(request.getRequestURI(), requestEncoding)); final String queryString = request.getQueryString(); if (queryString != null) { String firstEncoding = URLEncoder.encode("?" + queryString, requestEncoding); loginRedirect.append(URLEncoder.encode(firstEncoding, requestEncoding)); } return urlCustomizer.customizeUrl(request, loginRedirect.toString()); }  @Required void setCasLoginUrl(String casLoginUrl); @Autowired void setUrlCustomizer(UrlAuthCustomizerRegistry urlCustomizer); String getCasLoginUrl(final HttpServletRequest request); @Override String encodeLoginAndRefUrl(HttpServletRequest request); }
CasLoginRefUrlEncoder implements LoginRefUrlEncoder { @Override public String encodeLoginAndRefUrl(HttpServletRequest request) throws UnsupportedEncodingException { final String requestEncoding = request.getCharacterEncoding(); final StringBuilder loginRedirect = new StringBuilder(); loginRedirect.append(casLoginUrl); loginRedirect.append(URLEncoder.encode("?", requestEncoding)); loginRedirect.append( URLEncoder.encode(LoginController.REFERER_URL_PARAM + "=", requestEncoding)); loginRedirect.append(URLEncoder.encode(request.getRequestURI(), requestEncoding)); final String queryString = request.getQueryString(); if (queryString != null) { String firstEncoding = URLEncoder.encode("?" + queryString, requestEncoding); loginRedirect.append(URLEncoder.encode(firstEncoding, requestEncoding)); } return urlCustomizer.customizeUrl(request, loginRedirect.toString()); }  @Required void setCasLoginUrl(String casLoginUrl); @Autowired void setUrlCustomizer(UrlAuthCustomizerRegistry urlCustomizer); String getCasLoginUrl(final HttpServletRequest request); @Override String encodeLoginAndRefUrl(HttpServletRequest request);  }