private String encodeUserInfo(final String userInfo) { return this.encode ? CommonUtils.urlEncode(userInfo) : userInfo; }
private String encodePath(final String path) { return this.encode ? CommonUtils.urlEncode(path) : path; }
private String encodeUric(final String fragment) { return this.encode ? CommonUtils.urlEncode(fragment) : fragment; }
/** * Constructs the URL to use to redirect to the CAS server. * * @param casServerLoginUrl the CAS Server login url. * @param serviceParameterName the name of the parameter that defines the service. * @param serviceUrl the actual service's url. * @param renew whether we should send renew or not. * @param gateway where we should send gateway or not. * @return the fully constructed redirect url. */ public static String constructRedirectUrl(final String casServerLoginUrl, final String serviceParameterName, final String serviceUrl, final boolean renew, final boolean gateway) { return casServerLoginUrl + (casServerLoginUrl.contains("?") ? "&" : "?") + serviceParameterName + "=" + urlEncode(serviceUrl) + (renew ? "&renew=true" : "") + (gateway ? "&gateway=true" : ""); }
private String encodeUrlForm(final List<BasicNameValuePair> params) { final StringBuilder result = new StringBuilder(); for (final BasicNameValuePair parameter : params) { final String encodedName = this.encode ? CommonUtils.urlEncode(parameter.getName()) : parameter.getName(); final String encodedValue = this.encode ? CommonUtils.urlEncode(parameter.getValue()) : parameter.getValue(); if (result.length() > 0) { result.append("&"); } result.append(encodedName); if (encodedValue != null) { result.append("="); result.append(encodedValue); } } return result.toString(); }
public void testUrlEncode() { assertEquals("this+is+a+very+special+parameter+with+%3D%25%2F", CommonUtils.urlEncode("this is a very special parameter with =%/")); }