Commit 2c722beb authored by Quxl's avatar Quxl

x

parent 958b008f
......@@ -50,6 +50,7 @@ public interface OAuthApi {
builder.setParameter("realm", config.getRealm());
OAuthClientRequest oauthResponse = builder.buildQueryMessage();
String redirectUrl = oauthResponse.getLocationUri();
redirectUrl = redirectUrl.replaceAll("\\+", "%20");
System.out.println("redirect:" + redirectUrl);
response.sendRedirect(redirectUrl);
} catch (Exception e) {
......
......@@ -29,7 +29,7 @@ public class UrlBuilder {
return headers;
}
public String toUrlString() throws UnsupportedEncodingException {
public String toEncodeUrlString() throws UnsupportedEncodingException {
StringBuffer sb = new StringBuffer(url);
if (!url.contains("?")) {
sb.append("?");
......@@ -44,6 +44,28 @@ public class UrlBuilder {
value = value.trim();
sb.append(key).append("=").append(URLEncoder.encode(value, "utf-8")).append("&");
}
String urlString = sb.toString().replaceAll("\\+", "%20");
if (urlString.endsWith("&")) {
urlString = urlString.substring(0, urlString.length() - 1);
}
return urlString;
}
public String toUrlString() {
StringBuffer sb = new StringBuffer(url);
if (!url.contains("?")) {
sb.append("?");
} else {
sb.append("&");
}
for (String key : parameters.keySet()) {
String value = parameters.get(key);
if (value == null) {
value = "";
}
value = value.trim();
sb.append(key).append("=").append(value).append("&");
}
String urlString = sb.toString();
if (urlString.endsWith("&")) {
urlString = urlString.substring(0, urlString.length() - 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment