public abstract class AuthDefaultRequest extends Object implements AuthRequest
Modifier and Type | Field and Description |
---|---|
protected AuthStateCache |
authStateCache |
protected AuthConfig |
config |
protected AuthSource |
source |
Constructor and Description |
---|
AuthDefaultRequest(AuthConfig config,
AuthSource source) |
AuthDefaultRequest(AuthConfig config,
AuthSource source,
AuthStateCache authStateCache) |
Modifier and Type | Method and Description |
---|---|
protected String |
accessTokenUrl(String code)
返回获取accessToken的url
|
String |
authorize()
Deprecated.
|
String |
authorize(String state)
返回带
state 参数的授权url,授权回调时会带上这个state |
protected String |
doGetAuthorizationCode(String code)
通用的 authorizationCode 协议
|
protected String |
doGetRevoke(AuthToken authToken)
通用的post形式的取消授权方法
|
protected String |
doGetUserInfo(AuthToken authToken)
通用的 用户信息
|
protected String |
doPostAuthorizationCode(String code)
通用的 authorizationCode 协议
|
protected String |
doPostRevoke(AuthToken authToken)
Deprecated.
|
protected String |
doPostUserInfo(AuthToken authToken)
Deprecated.
|
protected abstract AuthToken |
getAccessToken(AuthCallback authCallback)
获取access token
|
protected String |
getRealState(String state)
获取state,如果为空, 则默认取当前日期的时间戳
|
protected String |
getScopes(String separator,
boolean encode,
List<String> defaultScopes)
获取以
separator 分割过后的 scope 信息 |
protected abstract AuthUser |
getUserInfo(AuthToken authToken)
使用token换取用户信息
|
AuthResponse |
login(AuthCallback authCallback)
统一的登录入口。当通过
authorize(String) 授权成功后,会跳转到调用方的相关回调方法中
方法的入参可以使用AuthCallback ,AuthCallback 类中封装好了OAuth2授权回调所需要的参数 |
protected String |
refreshTokenUrl(String refreshToken)
返回获取accessToken的url
|
protected String |
revokeUrl(AuthToken authToken)
返回获取revoke authorization的url
|
protected String |
userInfoUrl(AuthToken authToken)
返回获取userInfo的url
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
refresh, revoke
protected AuthConfig config
protected AuthSource source
protected AuthStateCache authStateCache
public AuthDefaultRequest(AuthConfig config, AuthSource source)
public AuthDefaultRequest(AuthConfig config, AuthSource source, AuthStateCache authStateCache)
protected abstract AuthToken getAccessToken(AuthCallback authCallback)
authCallback
- 授权成功后的回调参数authorize()
,
authorize(String)
protected abstract AuthUser getUserInfo(AuthToken authToken)
authToken
- token信息getAccessToken(AuthCallback)
public AuthResponse login(AuthCallback authCallback)
authorize(String)
授权成功后,会跳转到调用方的相关回调方法中
方法的入参可以使用AuthCallback
,AuthCallback
类中封装好了OAuth2授权回调所需要的参数login
in interface AuthRequest
authCallback
- 用于接收回调参数的实体@Deprecated public String authorize()
不建议使用该方式获取授权地址,不带state
的授权地址,容易受到csrf攻击。
建议使用authorize(String)
方法生成授权地址,在回调方法中对state
进行校验
authorize
in interface AuthRequest
authorize(String)
public String authorize(String state)
state
参数的授权url,授权回调时会带上这个state
authorize
in interface AuthRequest
state
- state 验证授权流程的参数,可以防止csrfprotected String accessTokenUrl(String code)
code
- 授权码protected String refreshTokenUrl(String refreshToken)
refreshToken
- refreshTokenprotected String userInfoUrl(AuthToken authToken)
authToken
- tokenprotected String revokeUrl(AuthToken authToken)
authToken
- tokenprotected String getRealState(String state)
state
- 原始的stateprotected String doPostAuthorizationCode(String code)
code
- code码protected String doGetAuthorizationCode(String code)
code
- code码@Deprecated protected String doPostUserInfo(AuthToken authToken)
authToken
- token封装protected String doGetUserInfo(AuthToken authToken)
authToken
- token封装@Deprecated protected String doPostRevoke(AuthToken authToken)
authToken
- token封装protected String doGetRevoke(AuthToken authToken)
authToken
- token封装Copyright © 2021. All rights reserved.