Commit 0d6622ec authored by Quxl's avatar Quxl

x

parent c0b2cc21
......@@ -6,6 +6,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.oltu.oauth2.client.OAuthClient;
import org.apache.oltu.oauth2.client.URLConnectionClient;
import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest;
......@@ -23,6 +25,8 @@ import com.alibaba.fastjson.JSONObject;
public interface OAuthApi {
Log logger = LogFactory.getLog(OAuthApi.class);
OAuthConfig getOAuthConfig();
HttpServletRequest getHttpServletRequest();
......@@ -42,9 +46,8 @@ public interface OAuthApi {
return token;
}
default void toLogin() {
default String getOAuthPath() {
try {
HttpServletResponse response = this.getHttpServletResponse();
OAuthConfig config = this.getOAuthConfig();
AuthenticationRequestBuilder builder = OAuthClientRequest.authorizationLocation(config.getAuthorizeUrl());
builder.setResponseType(OAuth.OAUTH_CODE);
......@@ -55,14 +58,14 @@ public interface OAuthApi {
OAuthClientRequest oauthResponse = builder.buildQueryMessage();
String redirectUrl = oauthResponse.getLocationUri();
redirectUrl = redirectUrl.replaceAll("\\+", "%20");
System.out.println("redirect:" + redirectUrl);
response.sendRedirect(redirectUrl);
logger.debug("redirect:" + redirectUrl);
return redirectUrl;
} catch (Exception e) {
throw new OAuthApiException(e.getMessage(), e);
}
}
default void doLogin() {
default void doOAuthCallback() {
try {
HttpServletRequest request = this.getHttpServletRequest();
HttpSession session = request.getSession();
......
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