Package me.zhyd.oauth.request
Class AuthDefaultRequest
java.lang.Object
me.zhyd.oauth.request.AuthDefaultRequest
- All Implemented Interfaces:
AuthRequest
- Direct Known Subclasses:
AbstractAuthDingtalkRequest,AbstractAuthMicrosoftRequest,AbstractAuthWeChatEnterpriseRequest,AuthAfDianRequest,AuthAlipayCertRequest,AuthAlipayRequest,AuthAliyunRequest,AuthAmazonRequest,AuthAppleRequest,AuthBaiduRequest,AuthCodingRequest,AuthCsdnRequest,AuthDingTalkV2Request,AuthDouyinRequest,AuthElemeRequest,AuthFacebookRequest,AuthFeishuRequest,AuthFigmaRequest,AuthGiteeRequest,AuthGithubRequest,AuthGitlabRequest,AuthGoogleRequest,AuthHuaweiRequest,AuthHuaweiV3Request,AuthJdRequest,AuthKujialeRequest,AuthLineRequest,AuthLinkedinRequest,AuthMeituanRequest,AuthMiRequest,AuthOktaRequest,AuthOschinaRequest,AuthPinterestRequest,AuthProginnRequest,AuthQQMiniProgramRequest,AuthQqRequest,AuthRenrenRequest,AuthSlackRequest,AuthStackOverflowRequest,AuthTaobaoRequest,AuthTeambitionRequest,AuthToutiaoRequest,AuthTwitterRequest,AuthWechatMiniProgramRequest,AuthWeChatMpRequest,AuthWeChatOpenRequest,AuthWeiboRequest,AuthXmlyRequest
默认的request处理类
- Since:
- 1.0.0
- Author:
- yadong.zhang (yadong.zhang0415(a)gmail.com), yangkai.shen (https://xkcoding.com)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AuthStateCacheprotected AuthConfigprotected AuthSource -
Constructor Summary
ConstructorsConstructorDescriptionAuthDefaultRequest(AuthConfig config, AuthSource source) AuthDefaultRequest(AuthConfig config, AuthSource source, AuthStateCache authStateCache) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringaccessTokenUrl(String code) 返回获取accessToken的urlDeprecated.返回带state参数的授权url,授权回调时会带上这个stateprotected voidcheckCode(AuthCallback authCallback) protected voidcheckConfig(AuthConfig config) protected StringdoGetAuthorizationCode(String code) 通用的 authorizationCode 协议protected StringdoGetRevoke(AuthToken authToken) 通用的post形式的取消授权方法protected StringdoGetUserInfo(AuthToken authToken) 通用的 用户信息protected String通用的 authorizationCode 协议protected StringdoPostRevoke(AuthToken authToken) Deprecated.protected StringdoPostUserInfo(AuthToken authToken) Deprecated.protected StringgetRealState(String state) 获取state,如果为空, 则默认取当前日期的时间戳protected String获取以separator分割过后的 scope 信息login(AuthCallback authCallback) 统一的登录入口。protected StringrefreshTokenUrl(String refreshToken) 返回获取accessToken的url(package private) AuthResponse<AuthUser>处理login(AuthCallback)发生异常的情况,统一响应参数protected String返回获取revoke authorization的urlprotected StringuserInfoUrl(AuthToken authToken) 返回获取userInfo的urlMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.zhyd.oauth.request.AuthRequest
getAccessToken, getUserInfo, refresh, revoke
-
Field Details
-
config
-
source
-
authStateCache
-
-
Constructor Details
-
AuthDefaultRequest
-
AuthDefaultRequest
-
-
Method Details
-
login
统一的登录入口。当通过authorize(String)授权成功后,会跳转到调用方的相关回调方法中 方法的入参可以使用AuthCallback,AuthCallback类中封装好了OAuth2授权回调所需要的参数- Specified by:
loginin interfaceAuthRequest- Parameters:
authCallback- 用于接收回调参数的实体- Returns:
- AuthResponse
-
checkCode
-
responseError
处理login(AuthCallback)发生异常的情况,统一响应参数- Parameters:
e- 具体的异常- Returns:
- AuthResponse
-
authorize
Deprecated.返回授权url,可自行跳转页面不建议使用该方式获取授权地址,不带
state的授权地址,容易受到csrf攻击。 建议使用authorize(String)方法生成授权地址,在回调方法中对state进行校验- Specified by:
authorizein interfaceAuthRequest- Returns:
- 返回授权地址
- See Also:
-
authorize
返回带state参数的授权url,授权回调时会带上这个state- Specified by:
authorizein interfaceAuthRequest- Parameters:
state- state 验证授权流程的参数,可以防止csrf- Returns:
- 返回授权地址
- Since:
- 1.9.3
-
accessTokenUrl
返回获取accessToken的url- Parameters:
code- 授权码- Returns:
- 返回获取accessToken的url
-
refreshTokenUrl
返回获取accessToken的url- Parameters:
refreshToken- refreshToken- Returns:
- 返回获取accessToken的url
-
userInfoUrl
返回获取userInfo的url- Parameters:
authToken- token- Returns:
- 返回获取userInfo的url
-
revokeUrl
返回获取revoke authorization的url- Parameters:
authToken- token- Returns:
- 返回获取revoke authorization的url
-
getRealState
获取state,如果为空, 则默认取当前日期的时间戳- Parameters:
state- 原始的state- Returns:
- 返回不为null的state
-
doPostAuthorizationCode
通用的 authorizationCode 协议- Parameters:
code- code码- Returns:
- Response
-
doGetAuthorizationCode
通用的 authorizationCode 协议- Parameters:
code- code码- Returns:
- Response
-
doPostUserInfo
Deprecated.通用的 用户信息- Parameters:
authToken- token封装- Returns:
- Response
-
doGetUserInfo
通用的 用户信息- Parameters:
authToken- token封装- Returns:
- Response
-
doPostRevoke
Deprecated.通用的post形式的取消授权方法- Parameters:
authToken- token封装- Returns:
- Response
-
doGetRevoke
通用的post形式的取消授权方法- Parameters:
authToken- token封装- Returns:
- Response
-
getScopes
获取以separator分割过后的 scope 信息- Parameters:
separator- 多个scope间的分隔符encode- 是否 encode 编码defaultScopes- 默认的 scope, 当客户端没有配置scopes时启用- Returns:
- String
- Since:
- 1.16.7
-
checkConfig
-