Commit 329817e3 authored by Quxl's avatar Quxl

x

parent d3e00a64
...@@ -30,8 +30,61 @@ import com.alibaba.fastjson.JSONObject; ...@@ -30,8 +30,61 @@ import com.alibaba.fastjson.JSONObject;
* <p>1. getOAuthConfig 获取OAuth系统配置信息</p> * <p>1. getOAuthConfig 获取OAuth系统配置信息</p>
* <p>2.getHttpServletRequest 获取HttpServletRequest对象, 用户获取Session保存OAuthToken信息, 也用于获取和解析授权后OAuth回调中的Token信息</p> * <p>2.getHttpServletRequest 获取HttpServletRequest对象, 用户获取Session保存OAuthToken信息, 也用于获取和解析授权后OAuth回调中的Token信息</p>
* <p>3.getHttpServletResponse 获取HttpServletResponse对象, 用于直接重定向到OAuth授权页面, 如果业务不需要直接重定向, 也可以通过 getAuthorizationUrl 方法获取OAuth的授权地址, 由用户主动点击跳转到 OAuth授权页面</p> * <p>3.getHttpServletResponse 获取HttpServletResponse对象, 用于直接重定向到OAuth授权页面, 如果业务不需要直接重定向, 也可以通过 getAuthorizationUrl 方法获取OAuth的授权地址, 由用户主动点击跳转到 OAuth授权页面</p>
* <p>以下为接口实现案例</p>
* <p>Example():</p>
* <pre>
public class OAuthApiImpl implements OAuthApi {
private OAuthConfig config;
<span>@</span>Autowired
HttpServletRequest request;
<span>@</span>Autowired
HttpServletResponse response;
<span>@</span>Value("${client_id}") private String clientId;
<span>@</span>Value("${client_secret}") private String clientSecret;
<span>@</span>Value("${callback_url}") private String callbackUrl;
<span>@</span>Value("${authorize_url}") private String authorizeUrl;
<span>@</span>Value("${access_token_url}") private String accessTokenUrl;
<span>@</span>Override
public OAuthConfig getOAuthConfig() {
if(config == null) {
synchronized (this) {
if(config == null) {
config = new OAuthConfig();
config.setAccessTokenUrl(accessTokenUrl);
config.setAuthorizeUrl(authorizeUrl);
config.setCallbackUrl(callbackUrl);
config.setClientId(clientId);
config.setClientSecret(clientSecret);
}
}
}
return config;
}
<span>@</span>Override
public HttpServletRequest getHttpServletRequest() {
return request;
}
<span>@</span>Override
public HttpServletResponse getHttpServletResponse() {
return response;
}
}
* </pre>
*
*
*
* *
* Example: * <p>以下为接口调用案例</p>
* <p>Example():</p>
* <pre> * <pre>
* public class LoginController { * public class LoginController {
* *
......
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