Commit 2c722beb authored by Quxl's avatar Quxl

x

parent 958b008f
...@@ -50,6 +50,7 @@ public interface OAuthApi { ...@@ -50,6 +50,7 @@ public interface OAuthApi {
builder.setParameter("realm", config.getRealm()); builder.setParameter("realm", config.getRealm());
OAuthClientRequest oauthResponse = builder.buildQueryMessage(); OAuthClientRequest oauthResponse = builder.buildQueryMessage();
String redirectUrl = oauthResponse.getLocationUri(); String redirectUrl = oauthResponse.getLocationUri();
redirectUrl = redirectUrl.replaceAll("\\+", "%20");
System.out.println("redirect:" + redirectUrl); System.out.println("redirect:" + redirectUrl);
response.sendRedirect(redirectUrl); response.sendRedirect(redirectUrl);
} catch (Exception e) { } catch (Exception e) {
......
...@@ -29,7 +29,7 @@ public class UrlBuilder { ...@@ -29,7 +29,7 @@ public class UrlBuilder {
return headers; return headers;
} }
public String toUrlString() throws UnsupportedEncodingException { public String toEncodeUrlString() throws UnsupportedEncodingException {
StringBuffer sb = new StringBuffer(url); StringBuffer sb = new StringBuffer(url);
if (!url.contains("?")) { if (!url.contains("?")) {
sb.append("?"); sb.append("?");
...@@ -44,6 +44,28 @@ public class UrlBuilder { ...@@ -44,6 +44,28 @@ public class UrlBuilder {
value = value.trim(); value = value.trim();
sb.append(key).append("=").append(URLEncoder.encode(value, "utf-8")).append("&"); 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(); String urlString = sb.toString();
if (urlString.endsWith("&")) { if (urlString.endsWith("&")) {
urlString = urlString.substring(0, urlString.length() - 1); 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