Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41582038
JustAuth
提交
8a486107
J
JustAuth
项目概览
weixin_41582038
/
JustAuth
与 Fork 源项目一致
Fork自
justauth / JustAuth
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
JustAuth
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8a486107
编写于
7月 16, 2019
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
♻
rename
上级
65334d0f
变更
50
隐藏空白更改
内联
并排
Showing
50 changed file
with
210 addition
and
172 deletion
+210
-172
src/main/java/me/zhyd/oauth/config/AuthSource.java
src/main/java/me/zhyd/oauth/config/AuthSource.java
+5
-5
src/main/java/me/zhyd/oauth/exception/AuthException.java
src/main/java/me/zhyd/oauth/exception/AuthException.java
+3
-3
src/main/java/me/zhyd/oauth/model/AuthResponse.java
src/main/java/me/zhyd/oauth/model/AuthResponse.java
+1
-2
src/main/java/me/zhyd/oauth/model/AuthResponseStatus.java
src/main/java/me/zhyd/oauth/model/AuthResponseStatus.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
+5
-5
src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthDefaultRequest.java
src/main/java/me/zhyd/oauth/request/AuthDefaultRequest.java
+11
-12
src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
+4
-4
src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java
src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java
src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java
+5
-5
src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
+4
-4
src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
...main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
+4
-4
src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthRequest.java
src/main/java/me/zhyd/oauth/request/AuthRequest.java
+5
-4
src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
+5
-8
src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
...n/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java
src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
+4
-4
src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
+3
-3
src/main/java/me/zhyd/oauth/url/AuthAlipayUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthAlipayUrlBuilder.java
+7
-5
src/main/java/me/zhyd/oauth/url/AuthBaiduUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthBaiduUrlBuilder.java
+4
-2
src/main/java/me/zhyd/oauth/url/AuthCodingUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthCodingUrlBuilder.java
+5
-3
src/main/java/me/zhyd/oauth/url/AuthCsdnUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthCsdnUrlBuilder.java
+5
-3
src/main/java/me/zhyd/oauth/url/AuthDefaultUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthDefaultUrlBuilder.java
+3
-3
src/main/java/me/zhyd/oauth/url/AuthDingtalkUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthDingtalkUrlBuilder.java
+6
-4
src/main/java/me/zhyd/oauth/url/AuthDouyinUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthDouyinUrlBuilder.java
+4
-2
src/main/java/me/zhyd/oauth/url/AuthFacebookUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthFacebookUrlBuilder.java
+5
-3
src/main/java/me/zhyd/oauth/url/AuthGiteeUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthGiteeUrlBuilder.java
+5
-3
src/main/java/me/zhyd/oauth/url/AuthGithubUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthGithubUrlBuilder.java
+5
-3
src/main/java/me/zhyd/oauth/url/AuthGoogleUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthGoogleUrlBuilder.java
+5
-3
src/main/java/me/zhyd/oauth/url/AuthLinkedinUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthLinkedinUrlBuilder.java
+4
-2
src/main/java/me/zhyd/oauth/url/AuthMiUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthMiUrlBuilder.java
+4
-2
src/main/java/me/zhyd/oauth/url/AuthMicrosoftUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthMicrosoftUrlBuilder.java
+4
-2
src/main/java/me/zhyd/oauth/url/AuthOschinaUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthOschinaUrlBuilder.java
+5
-3
src/main/java/me/zhyd/oauth/url/AuthQqUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthQqUrlBuilder.java
+5
-3
src/main/java/me/zhyd/oauth/url/AuthTaobaoUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthTaobaoUrlBuilder.java
+6
-4
src/main/java/me/zhyd/oauth/url/AuthTencentCloudUrlBuilder.java
...in/java/me/zhyd/oauth/url/AuthTencentCloudUrlBuilder.java
+5
-3
src/main/java/me/zhyd/oauth/url/AuthToutiaoUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthToutiaoUrlBuilder.java
+5
-3
src/main/java/me/zhyd/oauth/url/AuthWechatUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthWechatUrlBuilder.java
+4
-2
src/main/java/me/zhyd/oauth/url/AuthWeiboUrlBuilder.java
src/main/java/me/zhyd/oauth/url/AuthWeiboUrlBuilder.java
+5
-3
src/main/java/me/zhyd/oauth/utils/AuthChecker.java
src/main/java/me/zhyd/oauth/utils/AuthChecker.java
+7
-7
src/main/java/me/zhyd/oauth/utils/AuthState.java
src/main/java/me/zhyd/oauth/utils/AuthState.java
+2
-2
update.md
update.md
+2
-0
未找到文件。
src/main/java/me/zhyd/oauth/config/AuthSource.java
浏览文件 @
8a486107
package
me.zhyd.oauth.config
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.
request.
ResponseStatus
;
import
me.zhyd.oauth.
model.Auth
ResponseStatus
;
/**
* 各api需要的url, 用枚举类分平台类型管理
...
...
@@ -79,7 +79,7 @@ public enum AuthSource {
@Override
public
String
accessToken
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
throw
new
AuthException
(
Auth
ResponseStatus
.
UNSUPPORTED
);
}
@Override
...
...
@@ -265,7 +265,7 @@ public enum AuthSource {
@Override
public
String
userInfo
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
throw
new
AuthException
(
Auth
ResponseStatus
.
UNSUPPORTED
);
}
},
/**
...
...
@@ -473,7 +473,7 @@ public enum AuthSource {
* @return url
*/
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
throw
new
AuthException
(
Auth
ResponseStatus
.
UNSUPPORTED
);
}
/**
...
...
@@ -482,7 +482,7 @@ public enum AuthSource {
* @return url
*/
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
throw
new
AuthException
(
Auth
ResponseStatus
.
UNSUPPORTED
);
}
}
\ No newline at end of file
src/main/java/me/zhyd/oauth/exception/AuthException.java
浏览文件 @
8a486107
package
me.zhyd.oauth.exception
;
import
me.zhyd.oauth.
request.
ResponseStatus
;
import
me.zhyd.oauth.
model.Auth
ResponseStatus
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
...
...
@@ -13,7 +13,7 @@ public class AuthException extends RuntimeException {
private
String
errorMsg
;
public
AuthException
(
String
errorMsg
)
{
this
(
ResponseStatus
.
FAILURE
.
getCode
(),
errorMsg
);
this
(
Auth
ResponseStatus
.
FAILURE
.
getCode
(),
errorMsg
);
}
public
AuthException
(
int
errorCode
,
String
errorMsg
)
{
...
...
@@ -22,7 +22,7 @@ public class AuthException extends RuntimeException {
this
.
errorMsg
=
errorMsg
;
}
public
AuthException
(
ResponseStatus
status
)
{
public
AuthException
(
Auth
ResponseStatus
status
)
{
super
(
status
.
getMsg
());
}
...
...
src/main/java/me/zhyd/oauth/model/AuthResponse.java
浏览文件 @
8a486107
...
...
@@ -3,7 +3,6 @@ package me.zhyd.oauth.model;
import
lombok.Builder
;
import
lombok.Getter
;
import
lombok.Setter
;
import
me.zhyd.oauth.request.ResponseStatus
;
/**
* JustAuth统一授权响应类
...
...
@@ -37,6 +36,6 @@ public class AuthResponse<T> {
* @return true or false
*/
public
boolean
ok
()
{
return
this
.
code
==
ResponseStatus
.
SUCCESS
.
getCode
();
return
this
.
code
==
Auth
ResponseStatus
.
SUCCESS
.
getCode
();
}
}
src/main/java/me/zhyd/oauth/
request/
ResponseStatus.java
→
src/main/java/me/zhyd/oauth/
model/Auth
ResponseStatus.java
浏览文件 @
8a486107
package
me.zhyd.oauth.
request
;
package
me.zhyd.oauth.
model
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
enum
ResponseStatus
{
public
enum
Auth
ResponseStatus
{
SUCCESS
(
2000
,
"Success"
),
FAILURE
(
5000
,
"Failure"
),
NOT_IMPLEMENTED
(
5001
,
"Not Implemented"
),
...
...
@@ -21,7 +21,7 @@ public enum ResponseStatus {
private
int
code
;
private
String
msg
;
ResponseStatus
(
int
code
,
String
msg
)
{
Auth
ResponseStatus
(
int
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
...
...
src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
浏览文件 @
8a486107
...
...
@@ -14,7 +14,7 @@ import me.zhyd.oauth.model.AuthCallback;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.AlipayUrlBuilder
;
import
me.zhyd.oauth.url.A
uthA
lipayUrlBuilder
;
import
me.zhyd.oauth.utils.StringUtils
;
/**
...
...
@@ -24,12 +24,12 @@ import me.zhyd.oauth.utils.StringUtils;
* @version 1.0
* @since 1.8
*/
public
class
AuthAlipayRequest
extends
BaseAuth
Request
{
public
class
AuthAlipayRequest
extends
AuthDefault
Request
{
private
AlipayClient
alipayClient
;
public
AuthAlipayRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
ALIPAY
,
new
AlipayUrlBuilder
());
super
(
config
,
AuthSource
.
ALIPAY
,
new
A
uthA
lipayUrlBuilder
());
this
.
alipayClient
=
new
DefaultAlipayClient
(
AuthSource
.
ALIPAY
.
accessToken
(),
config
.
getClientId
(),
config
.
getClientSecret
(),
"json"
,
"UTF-8"
,
config
.
getAlipayPublicKey
(),
"RSA2"
);
}
...
...
src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
浏览文件 @
8a486107
...
...
@@ -8,7 +8,7 @@ import me.zhyd.oauth.config.AuthSource;
import
me.zhyd.oauth.enums.AuthBaiduErrorCode
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.url.BaiduUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
BaiduUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
/**
...
...
@@ -18,10 +18,10 @@ import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
* @version 1.0
* @since 1.8
*/
public
class
AuthBaiduRequest
extends
BaseAuth
Request
{
public
class
AuthBaiduRequest
extends
AuthDefault
Request
{
public
AuthBaiduRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
BAIDU
,
new
BaiduUrlBuilder
());
super
(
config
,
AuthSource
.
BAIDU
,
new
Auth
BaiduUrlBuilder
());
}
@Override
...
...
@@ -71,11 +71,11 @@ public class AuthBaiduRequest extends BaseAuthRequest {
JSONObject
object
=
JSONObject
.
parseObject
(
userInfo
);
if
(
object
.
containsKey
(
"error_code"
))
{
return
AuthResponse
.
builder
()
.
code
(
ResponseStatus
.
FAILURE
.
getCode
())
.
code
(
Auth
ResponseStatus
.
FAILURE
.
getCode
())
.
msg
(
object
.
getString
(
"error_msg"
))
.
build
();
}
ResponseStatus
status
=
object
.
getIntValue
(
"result"
)
==
1
?
ResponseStatus
.
SUCCESS
:
ResponseStatus
.
FAILURE
;
AuthResponseStatus
status
=
object
.
getIntValue
(
"result"
)
==
1
?
AuthResponseStatus
.
SUCCESS
:
Auth
ResponseStatus
.
FAILURE
;
return
AuthResponse
.
builder
().
code
(
status
.
getCode
()).
msg
(
status
.
getMsg
()).
build
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
浏览文件 @
8a486107
...
...
@@ -10,7 +10,7 @@ import me.zhyd.oauth.model.AuthCallback;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.CodingUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
CodingUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
/**
...
...
@@ -20,10 +20,10 @@ import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
* @version 1.0
* @since 1.8
*/
public
class
AuthCodingRequest
extends
BaseAuth
Request
{
public
class
AuthCodingRequest
extends
AuthDefault
Request
{
public
AuthCodingRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
CODING
,
new
CodingUrlBuilder
());
super
(
config
,
AuthSource
.
CODING
,
new
Auth
CodingUrlBuilder
());
}
@Override
...
...
src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
浏览文件 @
8a486107
...
...
@@ -10,7 +10,7 @@ import me.zhyd.oauth.model.AuthCallback;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.CsdnUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
CsdnUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
/**
...
...
@@ -21,10 +21,10 @@ import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
* @since 1.8
*/
@Deprecated
public
class
AuthCsdnRequest
extends
BaseAuth
Request
{
public
class
AuthCsdnRequest
extends
AuthDefault
Request
{
public
AuthCsdnRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
CSDN
,
new
CsdnUrlBuilder
());
super
(
config
,
AuthSource
.
CSDN
,
new
Auth
CsdnUrlBuilder
());
}
@Override
...
...
src/main/java/me/zhyd/oauth/request/
BaseAuth
Request.java
→
src/main/java/me/zhyd/oauth/request/
AuthDefault
Request.java
浏览文件 @
8a486107
...
...
@@ -4,35 +4,34 @@ import lombok.Data;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthCallback
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.url.AbstractUrlBuilder
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.url.AuthDefaultUrlBuilder
;
import
me.zhyd.oauth.utils.AuthChecker
;
/**
* 默认的request处理类
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
@Data
public
abstract
class
BaseAuth
Request
implements
AuthRequest
{
public
abstract
class
AuthDefault
Request
implements
AuthRequest
{
protected
AuthConfig
config
;
protected
AuthSource
source
;
protected
A
bstrac
tUrlBuilder
urlBuilder
;
protected
A
uthDefaul
tUrlBuilder
urlBuilder
;
public
BaseAuth
Request
(
AuthConfig
config
,
AuthSource
source
)
{
public
AuthDefault
Request
(
AuthConfig
config
,
AuthSource
source
)
{
this
.
config
=
config
;
this
.
source
=
source
;
if
(!
AuthChecker
.
isSupportedAuth
(
config
,
source
))
{
throw
new
AuthException
(
ResponseStatus
.
PARAMETER_INCOMPLETE
);
throw
new
AuthException
(
Auth
ResponseStatus
.
PARAMETER_INCOMPLETE
);
}
// 校验配置合法性
AuthChecker
.
checkConfig
(
config
,
source
);
}
public
BaseAuthRequest
(
AuthConfig
config
,
AuthSource
source
,
Abstrac
tUrlBuilder
urlBuilder
)
{
public
AuthDefaultRequest
(
AuthConfig
config
,
AuthSource
source
,
AuthDefaul
tUrlBuilder
urlBuilder
)
{
this
(
config
,
source
);
this
.
urlBuilder
=
urlBuilder
;
this
.
urlBuilder
.
setAuthConfig
(
config
);
...
...
@@ -50,14 +49,14 @@ public abstract class BaseAuthRequest implements AuthRequest {
AuthToken
authToken
=
this
.
getAccessToken
(
authCallback
);
AuthUser
user
=
this
.
getUserInfo
(
authToken
);
return
AuthResponse
.
builder
().
code
(
ResponseStatus
.
SUCCESS
.
getCode
()).
data
(
user
).
build
();
return
AuthResponse
.
builder
().
code
(
Auth
ResponseStatus
.
SUCCESS
.
getCode
()).
data
(
user
).
build
();
}
catch
(
Exception
e
)
{
return
this
.
responseError
(
e
);
}
}
private
AuthResponse
responseError
(
Exception
e
)
{
int
errorCode
=
ResponseStatus
.
FAILURE
.
getCode
();
int
errorCode
=
Auth
ResponseStatus
.
FAILURE
.
getCode
();
if
(
e
instanceof
AuthException
)
{
errorCode
=
((
AuthException
)
e
).
getErrorCode
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
浏览文件 @
8a486107
...
...
@@ -12,7 +12,7 @@ import me.zhyd.oauth.model.AuthCallback;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.DingtalkUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
DingtalkUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
me.zhyd.oauth.utils.GlobalAuthUtil
;
...
...
@@ -23,10 +23,10 @@ import me.zhyd.oauth.utils.GlobalAuthUtil;
* @version 1.0
* @since 1.8
*/
public
class
AuthDingTalkRequest
extends
BaseAuth
Request
{
public
class
AuthDingTalkRequest
extends
AuthDefault
Request
{
public
AuthDingTalkRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
DINGTALK
,
new
DingtalkUrlBuilder
());
super
(
config
,
AuthSource
.
DINGTALK
,
new
Auth
DingtalkUrlBuilder
());
}
@Override
...
...
src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
浏览文件 @
8a486107
...
...
@@ -7,7 +7,7 @@ import me.zhyd.oauth.config.AuthConfig;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.url.DouyinUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
DouyinUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
...
...
@@ -18,10 +18,10 @@ import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
* @version 1.0
* @since 1.8
*/
public
class
AuthDouyinRequest
extends
BaseAuth
Request
{
public
class
AuthDouyinRequest
extends
AuthDefault
Request
{
public
AuthDouyinRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
DOUYIN
,
new
DouyinUrlBuilder
());
super
(
config
,
AuthSource
.
DOUYIN
,
new
Auth
DouyinUrlBuilder
());
}
@Override
...
...
@@ -59,7 +59,7 @@ public class AuthDouyinRequest extends BaseAuthRequest {
public
AuthResponse
refresh
(
AuthToken
oldToken
)
{
String
refreshTokenUrl
=
this
.
urlBuilder
.
getRefreshUrl
(
oldToken
.
getRefreshToken
());
return
AuthResponse
.
builder
()
.
code
(
ResponseStatus
.
SUCCESS
.
getCode
())
.
code
(
Auth
ResponseStatus
.
SUCCESS
.
getCode
())
.
data
(
this
.
getToken
(
refreshTokenUrl
))
.
build
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java
浏览文件 @
8a486107
...
...
@@ -10,7 +10,7 @@ import me.zhyd.oauth.model.AuthCallback;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.FacebookUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
FacebookUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
/**
...
...
@@ -20,10 +20,10 @@ import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
* @version 1.0
* @since 1.8
*/
public
class
AuthFacebookRequest
extends
BaseAuth
Request
{
public
class
AuthFacebookRequest
extends
AuthDefault
Request
{
public
AuthFacebookRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
FACEBOOK
,
new
FacebookUrlBuilder
());
super
(
config
,
AuthSource
.
FACEBOOK
,
new
Auth
FacebookUrlBuilder
());
}
@Override
...
...
src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
浏览文件 @
8a486107
...
...
@@ -10,7 +10,7 @@ import me.zhyd.oauth.model.AuthCallback;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.GiteeUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
GiteeUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
/**
...
...
@@ -20,10 +20,10 @@ import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
* @version 1.0
* @since 1.8
*/
public
class
AuthGiteeRequest
extends
BaseAuth
Request
{
public
class
AuthGiteeRequest
extends
AuthDefault
Request
{
public
AuthGiteeRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
GITEE
,
new
GiteeUrlBuilder
());
super
(
config
,
AuthSource
.
GITEE
,
new
Auth
GiteeUrlBuilder
());
}
@Override
...
...
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
浏览文件 @
8a486107
...
...
@@ -10,7 +10,7 @@ import me.zhyd.oauth.model.AuthCallback;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.GithubUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
GithubUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
me.zhyd.oauth.utils.GlobalAuthUtil
;
...
...
@@ -23,10 +23,10 @@ import java.util.Map;
* @version 1.0
* @since 1.8
*/
public
class
AuthGithubRequest
extends
BaseAuth
Request
{
public
class
AuthGithubRequest
extends
AuthDefault
Request
{
public
AuthGithubRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
GITHUB
,
new
GithubUrlBuilder
());
super
(
config
,
AuthSource
.
GITHUB
,
new
Auth
GithubUrlBuilder
());
}
@Override
...
...
src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
浏览文件 @
8a486107
...
...
@@ -10,7 +10,7 @@ import me.zhyd.oauth.model.AuthCallback;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.GoogleUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
GoogleUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
/**
...
...
@@ -20,10 +20,10 @@ import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
* @version 1.3
* @since 1.3
*/
public
class
AuthGoogleRequest
extends
BaseAuth
Request
{
public
class
AuthGoogleRequest
extends
AuthDefault
Request
{
public
AuthGoogleRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
GOOGLE
,
new
GoogleUrlBuilder
());
super
(
config
,
AuthSource
.
GOOGLE
,
new
Auth
GoogleUrlBuilder
());
}
@Override
...
...
src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java
浏览文件 @
8a486107
...
...
@@ -8,7 +8,7 @@ import me.zhyd.oauth.config.AuthConfig;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.url.LinkedinUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
LinkedinUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
me.zhyd.oauth.utils.StringUtils
;
...
...
@@ -20,10 +20,10 @@ import me.zhyd.oauth.utils.StringUtils;
* @version 1.0
* @since 1.8
*/
public
class
AuthLinkedinRequest
extends
BaseAuth
Request
{
public
class
AuthLinkedinRequest
extends
AuthDefault
Request
{
public
AuthLinkedinRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
LINKEDIN
,
new
LinkedinUrlBuilder
());
super
(
config
,
AuthSource
.
LINKEDIN
,
new
Auth
LinkedinUrlBuilder
());
}
@Override
...
...
@@ -116,11 +116,11 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
@Override
public
AuthResponse
refresh
(
AuthToken
oldToken
)
{
if
(
StringUtils
.
isEmpty
(
oldToken
.
getRefreshToken
()))
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
throw
new
AuthException
(
Auth
ResponseStatus
.
UNSUPPORTED
);
}
String
refreshTokenUrl
=
this
.
urlBuilder
.
getRefreshUrl
(
oldToken
.
getRefreshToken
());
return
AuthResponse
.
builder
()
.
code
(
ResponseStatus
.
SUCCESS
.
getCode
())
.
code
(
Auth
ResponseStatus
.
SUCCESS
.
getCode
())
.
data
(
this
.
getToken
(
refreshTokenUrl
))
.
build
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
浏览文件 @
8a486107
...
...
@@ -8,7 +8,7 @@ import me.zhyd.oauth.config.AuthConfig;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.url.MiUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
MiUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -20,11 +20,11 @@ import java.text.MessageFormat;
* @version 1.5
* @since 1.5
*/
public
class
AuthMiRequest
extends
BaseAuth
Request
{
public
class
AuthMiRequest
extends
AuthDefault
Request
{
private
static
final
String
PREFIX
=
"&&&START&&&"
;
public
AuthMiRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
MI
,
new
MiUrlBuilder
());
super
(
config
,
AuthSource
.
MI
,
new
Auth
MiUrlBuilder
());
}
@Override
...
...
@@ -105,6 +105,6 @@ public class AuthMiRequest extends BaseAuthRequest {
public
AuthResponse
refresh
(
AuthToken
authToken
)
{
String
miRefreshUrl
=
this
.
urlBuilder
.
getRefreshUrl
(
authToken
.
getRefreshToken
());
return
AuthResponse
.
builder
().
code
(
ResponseStatus
.
SUCCESS
.
getCode
()).
data
(
getToken
(
miRefreshUrl
)).
build
();
return
AuthResponse
.
builder
().
code
(
Auth
ResponseStatus
.
SUCCESS
.
getCode
()).
data
(
getToken
(
miRefreshUrl
)).
build
();
}
}
src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
浏览文件 @
8a486107
...
...
@@ -8,7 +8,7 @@ import me.zhyd.oauth.config.AuthConfig;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.url.MicrosoftUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
MicrosoftUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.util.HashMap
;
...
...
@@ -21,9 +21,9 @@ import java.util.Map;
* @version 1.5
* @since 1.5
*/
public
class
AuthMicrosoftRequest
extends
BaseAuth
Request
{
public
class
AuthMicrosoftRequest
extends
AuthDefault
Request
{
public
AuthMicrosoftRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
MICROSOFT
,
new
MicrosoftUrlBuilder
());
super
(
config
,
AuthSource
.
MICROSOFT
,
new
Auth
MicrosoftUrlBuilder
());
}
@Override
...
...
@@ -99,6 +99,6 @@ public class AuthMicrosoftRequest extends BaseAuthRequest {
public
AuthResponse
refresh
(
AuthToken
authToken
)
{
String
refreshTokenUrl
=
this
.
urlBuilder
.
getRefreshUrl
(
authToken
.
getRefreshToken
());
return
AuthResponse
.
builder
().
code
(
ResponseStatus
.
SUCCESS
.
getCode
()).
data
(
getToken
(
refreshTokenUrl
)).
build
();
return
AuthResponse
.
builder
().
code
(
Auth
ResponseStatus
.
SUCCESS
.
getCode
()).
data
(
getToken
(
refreshTokenUrl
)).
build
();
}
}
src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
浏览文件 @
8a486107
...
...
@@ -10,7 +10,7 @@ import me.zhyd.oauth.model.AuthCallback;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.OschinaUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
OschinaUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
/**
...
...
@@ -20,10 +20,10 @@ import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
* @version 1.0
* @since 1.8
*/
public
class
AuthOschinaRequest
extends
BaseAuth
Request
{
public
class
AuthOschinaRequest
extends
AuthDefault
Request
{
public
AuthOschinaRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
OSCHINA
,
new
OschinaUrlBuilder
());
super
(
config
,
AuthSource
.
OSCHINA
,
new
Auth
OschinaUrlBuilder
());
}
@Override
...
...
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
浏览文件 @
8a486107
...
...
@@ -11,7 +11,7 @@ import me.zhyd.oauth.model.AuthCallback;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.QqUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
QqUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
me.zhyd.oauth.utils.GlobalAuthUtil
;
import
me.zhyd.oauth.utils.StringUtils
;
...
...
@@ -26,9 +26,9 @@ import java.util.Map;
* @version 1.0
* @since 1.8
*/
public
class
AuthQqRequest
extends
BaseAuth
Request
{
public
class
AuthQqRequest
extends
AuthDefault
Request
{
public
AuthQqRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
QQ
,
new
QqUrlBuilder
());
super
(
config
,
AuthSource
.
QQ
,
new
Auth
QqUrlBuilder
());
}
@Override
...
...
src/main/java/me/zhyd/oauth/request/AuthRequest.java
浏览文件 @
8a486107
...
...
@@ -3,6 +3,7 @@ package me.zhyd.oauth.request;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthCallback
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.model.AuthToken
;
/**
...
...
@@ -18,7 +19,7 @@ public interface AuthRequest {
* @return 返回授权地址
*/
default
String
authorize
()
{
throw
new
AuthException
(
ResponseStatus
.
NOT_IMPLEMENTED
);
throw
new
AuthException
(
Auth
ResponseStatus
.
NOT_IMPLEMENTED
);
}
/**
...
...
@@ -28,7 +29,7 @@ public interface AuthRequest {
* @return 返回登录成功后的用户信息
*/
default
AuthResponse
login
(
AuthCallback
authCallback
)
{
throw
new
AuthException
(
ResponseStatus
.
NOT_IMPLEMENTED
);
throw
new
AuthException
(
Auth
ResponseStatus
.
NOT_IMPLEMENTED
);
}
/**
...
...
@@ -38,7 +39,7 @@ public interface AuthRequest {
* @return AuthResponse
*/
default
AuthResponse
revoke
(
AuthToken
authToken
)
{
throw
new
AuthException
(
ResponseStatus
.
NOT_IMPLEMENTED
);
throw
new
AuthException
(
Auth
ResponseStatus
.
NOT_IMPLEMENTED
);
}
/**
...
...
@@ -48,6 +49,6 @@ public interface AuthRequest {
* @return AuthResponse
*/
default
AuthResponse
refresh
(
AuthToken
authToken
)
{
throw
new
AuthException
(
ResponseStatus
.
NOT_IMPLEMENTED
);
throw
new
AuthException
(
Auth
ResponseStatus
.
NOT_IMPLEMENTED
);
}
}
src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
浏览文件 @
8a486107
...
...
@@ -6,11 +6,8 @@ import com.alibaba.fastjson.JSONObject;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthCallback
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.TaobaoUrlBuilder
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.url.AuthTaobaoUrlBuilder
;
import
me.zhyd.oauth.utils.GlobalAuthUtil
;
/**
...
...
@@ -20,10 +17,10 @@ import me.zhyd.oauth.utils.GlobalAuthUtil;
* @version 1.0
* @since 1.8
*/
public
class
AuthTaobaoRequest
extends
BaseAuth
Request
{
public
class
AuthTaobaoRequest
extends
AuthDefault
Request
{
public
AuthTaobaoRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
TAOBAO
,
new
TaobaoUrlBuilder
());
super
(
config
,
AuthSource
.
TAOBAO
,
new
Auth
TaobaoUrlBuilder
());
}
@Override
...
...
@@ -37,7 +34,7 @@ public class AuthTaobaoRequest extends BaseAuthRequest {
HttpResponse
response
=
HttpRequest
.
post
(
this
.
urlBuilder
.
getAccessTokenUrl
(
accessCode
)).
execute
();
JSONObject
accessTokenObject
=
JSONObject
.
parseObject
(
response
.
body
());
if
(
accessTokenObject
.
containsKey
(
"error"
))
{
throw
new
AuthException
(
ResponseStatus
.
FAILURE
+
":"
+
accessTokenObject
.
getString
(
"error_description"
));
throw
new
AuthException
(
Auth
ResponseStatus
.
FAILURE
+
":"
+
accessTokenObject
.
getString
(
"error_description"
));
}
authToken
.
setAccessToken
(
accessTokenObject
.
getString
(
"access_token"
));
authToken
.
setRefreshToken
(
accessTokenObject
.
getString
(
"refresh_token"
));
...
...
src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
浏览文件 @
8a486107
...
...
@@ -10,7 +10,7 @@ import me.zhyd.oauth.model.AuthCallback;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.TencentCloudUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
TencentCloudUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
/**
...
...
@@ -20,10 +20,10 @@ import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
* @version 1.0
* @since 1.8
*/
public
class
AuthTencentCloudRequest
extends
BaseAuth
Request
{
public
class
AuthTencentCloudRequest
extends
AuthDefault
Request
{
public
AuthTencentCloudRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
TENCENT_CLOUD
,
new
TencentCloudUrlBuilder
());
super
(
config
,
AuthSource
.
TENCENT_CLOUD
,
new
Auth
TencentCloudUrlBuilder
());
}
@Override
...
...
src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java
浏览文件 @
8a486107
...
...
@@ -11,7 +11,7 @@ import me.zhyd.oauth.model.AuthCallback;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.ToutiaoUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
ToutiaoUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
/**
...
...
@@ -21,10 +21,10 @@ import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
* @version 1.5
* @since 1.5
*/
public
class
AuthToutiaoRequest
extends
BaseAuth
Request
{
public
class
AuthToutiaoRequest
extends
AuthDefault
Request
{
public
AuthToutiaoRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
TOUTIAO
,
new
ToutiaoUrlBuilder
());
super
(
config
,
AuthSource
.
TOUTIAO
,
new
Auth
ToutiaoUrlBuilder
());
}
@Override
...
...
src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
浏览文件 @
8a486107
...
...
@@ -7,7 +7,7 @@ import me.zhyd.oauth.config.AuthConfig;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.url.WechatUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
WechatUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
/**
...
...
@@ -17,9 +17,9 @@ import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
* @version 1.0
* @since 1.8
*/
public
class
AuthWeChatRequest
extends
BaseAuth
Request
{
public
class
AuthWeChatRequest
extends
AuthDefault
Request
{
public
AuthWeChatRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
WECHAT
,
new
WechatUrlBuilder
());
super
(
config
,
AuthSource
.
WECHAT
,
new
Auth
WechatUrlBuilder
());
}
/**
...
...
@@ -64,7 +64,7 @@ public class AuthWeChatRequest extends BaseAuthRequest {
public
AuthResponse
refresh
(
AuthToken
oldToken
)
{
String
refreshTokenUrl
=
this
.
urlBuilder
.
getRefreshUrl
(
oldToken
.
getRefreshToken
());
return
AuthResponse
.
builder
()
.
code
(
ResponseStatus
.
SUCCESS
.
getCode
())
.
code
(
Auth
ResponseStatus
.
SUCCESS
.
getCode
())
.
data
(
this
.
getToken
(
refreshTokenUrl
))
.
build
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
浏览文件 @
8a486107
...
...
@@ -10,7 +10,7 @@ import me.zhyd.oauth.model.AuthCallback;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.url.WeiboUrlBuilder
;
import
me.zhyd.oauth.url.
Auth
WeiboUrlBuilder
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
me.zhyd.oauth.utils.IpUtils
;
import
me.zhyd.oauth.utils.StringUtils
;
...
...
@@ -23,10 +23,10 @@ import me.zhyd.oauth.utils.StringUtils;
* @version 1.0
* @since 1.8
*/
public
class
AuthWeiboRequest
extends
BaseAuth
Request
{
public
class
AuthWeiboRequest
extends
AuthDefault
Request
{
public
AuthWeiboRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
WEIBO
,
new
WeiboUrlBuilder
());
super
(
config
,
AuthSource
.
WEIBO
,
new
Auth
WeiboUrlBuilder
());
}
@Override
...
...
src/main/java/me/zhyd/oauth/url/AlipayUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/A
uthA
lipayUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,18 +14,18 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
A
lipayUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
A
uthAlipayUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
ALIPAY_AUTHORIZE_PATTERN
=
"{0}?app_id={1}&scope=auth_user&redirect_uri={2}&state={3}"
;
@Override
public
String
getAccessTokenUrl
(
String
code
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getUserInfoUrl
(
AuthUserInfoEntity
userInfoEntity
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
...
...
@@ -33,11 +35,11 @@ public class AlipayUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/BaiduUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
BaiduUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
BaiduUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthBaiduUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
BAIDU_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&grant_type=authorization_code&code={3}&redirect_uri={4}"
;
private
static
final
String
BAIDU_USER_INFO_PATTERN
=
"{0}?access_token={1}"
;
...
...
@@ -36,7 +38,7 @@ public class BaiduUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
...
...
src/main/java/me/zhyd/oauth/url/CodingUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
CodingUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
CodingUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthCodingUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
CODING_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&grant_type=authorization_code&code={3}"
;
private
static
final
String
CODING_USER_INFO_PATTERN
=
"{0}?access_token={1}"
;
...
...
@@ -35,11 +37,11 @@ public class CodingUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/CsdnUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
CsdnUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -13,7 +15,7 @@ import java.text.MessageFormat;
* @since 1.8
*/
@Deprecated
public
class
CsdnUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthCsdnUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
CSDN_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&grant_type=authorization_code&code={3}&redirect_uri={4}"
;
private
static
final
String
CSDN_USER_INFO_PATTERN
=
"{0}?access_token={1}"
;
...
...
@@ -36,11 +38,11 @@ public class CsdnUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/A
bstrac
tUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/A
uthDefaul
tUrlBuilder.java
浏览文件 @
8a486107
...
...
@@ -2,7 +2,7 @@ package me.zhyd.oauth.url;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.
request.
ResponseStatus
;
import
me.zhyd.oauth.
model.Auth
ResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
me.zhyd.oauth.utils.StringUtils
;
...
...
@@ -11,7 +11,7 @@ import me.zhyd.oauth.utils.StringUtils;
* @version 1.0
* @since 1.8
*/
public
abstract
class
A
bstrac
tUrlBuilder
{
public
abstract
class
A
uthDefaul
tUrlBuilder
{
protected
AuthConfig
config
;
...
...
@@ -64,7 +64,7 @@ public abstract class AbstractUrlBuilder {
* @return openIdUrl
*/
public
String
getOpenIdUrl
(
String
accessToken
,
boolean
unionid
)
{
throw
new
AuthException
(
ResponseStatus
.
NOT_IMPLEMENTED
);
throw
new
AuthException
(
Auth
ResponseStatus
.
NOT_IMPLEMENTED
);
}
/**
...
...
src/main/java/me/zhyd/oauth/url/DingtalkUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
DingtalkUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,14 +14,14 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
DingtalkUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthDingtalkUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
DING_TALK_QRCONNECT_PATTERN
=
"{0}?appid={1}&response_type=code&scope=snsapi_login&redirect_uri={2}&state={3}"
;
private
static
final
String
DING_TALK_USER_INFO_PATTERN
=
"{0}?signature={1}×tamp={2}&accessKey={3}"
;
@Override
public
String
getAccessTokenUrl
(
String
code
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
...
...
@@ -34,11 +36,11 @@ public class DingtalkUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/DouyinUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
DouyinUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
DouyinUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthDouyinUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
DOUYIN_AUTHORIZE_PATTERN
=
"{0}?client_key={1}&redirect_uri={2}&state={3}&response_type=code&scope=user_info"
;
private
static
final
String
DOUYIN_ACCESS_TOKEN_PATTERN
=
"{0}?client_key={1}&client_secret={2}&code={3}&grant_type=authorization_code"
;
...
...
@@ -41,6 +43,6 @@ public class DouyinUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/FacebookUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
FacebookUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
FacebookUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthFacebookUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
FACEBOOK_AUTHORIZE_PATTERN
=
"{0}?client_id={1}&redirect_uri={2}&state={3}&response_type=code&scope="
;
private
static
final
String
FACEBOOK_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&code={3}&redirect_uri={4}&grant_type=authorization_code"
;
...
...
@@ -35,11 +37,11 @@ public class FacebookUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/GiteeUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
GiteeUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.*
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
GiteeUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthGiteeUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
GITEE_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&grant_type=authorization_code&code={3}&redirect_uri={4}"
;
private
static
final
String
GITEE_USER_INFO_PATTERN
=
"{0}?access_token={1}"
;
...
...
@@ -35,11 +37,11 @@ public class GiteeUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/GithubUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
GithubUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
GithubUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthGithubUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
GITHUB_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&code={3}&redirect_uri={4}"
;
private
static
final
String
GITHUB_USER_INFO_PATTERN
=
"{0}?access_token={1}"
;
...
...
@@ -35,11 +37,11 @@ public class GithubUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/GoogleUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
GoogleUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
GoogleUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthGoogleUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
GOOGLE_AUTHORIZE_PATTERN
=
"{0}?client_id={1}&response_type=code&scope=openid%20email%20profile&redirect_uri={2}&state={3}"
;
private
static
final
String
GOOGLE_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&code={3}&redirect_uri={4}&grant_type=authorization_code"
;
...
...
@@ -35,11 +37,11 @@ public class GoogleUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/LinkedinUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
LinkedinUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
LinkedinUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthLinkedinUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
LINKEDIN_AUTHORIZE_PATTERN
=
"{0}?client_id={1}&redirect_uri={2}&state={3}&response_type=code&scope=r_liteprofile%20r_emailaddress%20w_member_social"
;
private
static
final
String
LINKEDIN_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&code={3}&redirect_uri={4}&grant_type=authorization_code"
;
...
...
@@ -41,6 +43,6 @@ public class LinkedinUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/MiUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
MiUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
MiUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthMiUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
MI_AUTHORIZE_PATTERN
=
"{0}?client_id={1}&redirect_uri={2}&response_type=code&scope=1%203%204%206&state={3}&skip_confirm=false"
;
private
static
final
String
MI_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&redirect_uri={3}&code={4}&grant_type=authorization_code"
;
...
...
@@ -41,6 +43,6 @@ public class MiUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/MicrosoftUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
MicrosoftUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
MicrosoftUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthMicrosoftUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
MICROSOFT_AUTHORIZE_PATTERN
=
"{0}?client_id={1}&response_type=code&redirect_uri={2}&response_mode=query&scope=offline_access%20user.read%20mail.read&state={3}"
;
private
static
final
String
MICROSOFT_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&scope=user.read%20mail.read&redirect_uri={3}&code={4}&grant_type=authorization_code"
;
...
...
@@ -41,6 +43,6 @@ public class MicrosoftUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/OschinaUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
OschinaUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
OschinaUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthOschinaUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
OSCHINA_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&grant_type=authorization_code&code={3}&redirect_uri={4}&dataType=json"
;
private
static
final
String
OSCHINA_USER_INFO_PATTERN
=
"{0}?access_token={1}&dataType=json"
;
...
...
@@ -35,11 +37,11 @@ public class OschinaUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/QqUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
QqUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
QqUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthQqUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
QQ_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&grant_type=authorization_code&code={3}&redirect_uri={4}"
;
private
static
final
String
QQ_USER_INFO_PATTERN
=
"{0}?oauth_consumer_key={1}&access_token={2}&openid={3}"
;
...
...
@@ -36,12 +38,12 @@ public class QqUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
...
...
src/main/java/me/zhyd/oauth/url/TaobaoUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
TaobaoUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
TaobaoUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthTaobaoUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
TAOBAO_AUTHORIZE_PATTERN
=
"{0}?response_type=code&client_id={1}&redirect_uri={2}&state={3}&view=web"
;
private
static
final
String
TAOBAO_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&code={3}&redirect_uri={4}&grant_type=authorization_code"
;
...
...
@@ -24,7 +26,7 @@ public class TaobaoUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getUserInfoUrl
(
AuthUserInfoEntity
userInfoEntity
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
...
...
@@ -34,11 +36,11 @@ public class TaobaoUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/TencentCloudUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
TencentCloudUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
TencentCloudUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthTencentCloudUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
TENCENT_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&grant_type=authorization_code&code={3}"
;
private
static
final
String
TENCENT_USER_INFO_PATTERN
=
"{0}?access_token={1}"
;
...
...
@@ -35,11 +37,11 @@ public class TencentCloudUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/ToutiaoUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
ToutiaoUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
ToutiaoUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthToutiaoUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
TOUTIAO_ACCESS_TOKEN_PATTERN
=
"{0}?client_key={1}&client_secret={2}&code={3}&grant_type=authorize_code"
;
private
static
final
String
TOUTIAO_USER_INFO_PATTERN
=
"{0}?client_key={1}&access_token={2}"
;
...
...
@@ -35,11 +37,11 @@ public class ToutiaoUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/WechatUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
WechatUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
WechatUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthWechatUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
WECHAT_AUTHORIZE_PATTERN
=
"{0}?appid={1}&redirect_uri={2}&response_type=code&scope=snsapi_login&state={3}#wechat_redirect"
;
private
static
final
String
WECHAT_ACCESS_TOKEN_PATTERN
=
"{0}?appid={1}&secret={2}&code={3}&grant_type=authorization_code"
;
...
...
@@ -41,6 +43,6 @@ public class WechatUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/url/WeiboUrlBuilder.java
→
src/main/java/me/zhyd/oauth/url/
Auth
WeiboUrlBuilder.java
浏览文件 @
8a486107
package
me.zhyd.oauth.url
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponseStatus
;
import
me.zhyd.oauth.url.entity.AuthUserInfoEntity
;
import
java.text.MessageFormat
;
...
...
@@ -12,7 +14,7 @@ import java.text.MessageFormat;
* @version 1.0
* @since 1.8
*/
public
class
WeiboUrlBuilder
extends
Abstrac
tUrlBuilder
{
public
class
AuthWeiboUrlBuilder
extends
AuthDefaul
tUrlBuilder
{
private
static
final
String
WEIBO_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&grant_type=authorization_code&code={3}&redirect_uri={4}"
;
private
static
final
String
WEIBO_USER_INFO_PATTERN
=
"{0}?{1}"
;
...
...
@@ -35,11 +37,11 @@ public class WeiboUrlBuilder extends AbstractUrlBuilder {
@Override
public
String
getRefreshUrl
(
String
refreshToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
@Override
public
String
getRevokeUrl
(
String
accessToken
)
{
return
null
;
throw
new
AuthException
(
AuthResponseStatus
.
NOT_IMPLEMENTED
)
;
}
}
src/main/java/me/zhyd/oauth/utils/AuthChecker.java
浏览文件 @
8a486107
...
...
@@ -3,7 +3,7 @@ package me.zhyd.oauth.utils;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.
request.
ResponseStatus
;
import
me.zhyd.oauth.
model.Auth
ResponseStatus
;
/**
* 授权配置类的校验器
...
...
@@ -38,15 +38,15 @@ public class AuthChecker {
public
static
void
checkConfig
(
AuthConfig
config
,
AuthSource
source
)
{
String
redirectUri
=
config
.
getRedirectUri
();
if
(!
GlobalAuthUtil
.
isHttpProtocol
(
redirectUri
)
&&
!
GlobalAuthUtil
.
isHttpsProtocol
(
redirectUri
))
{
throw
new
AuthException
(
ResponseStatus
.
ILLEGAL_REDIRECT_URI
);
throw
new
AuthException
(
Auth
ResponseStatus
.
ILLEGAL_REDIRECT_URI
);
}
// facebook的回调地址必须为https的链接
if
(
AuthSource
.
FACEBOOK
==
source
&&
!
GlobalAuthUtil
.
isHttpsProtocol
(
redirectUri
))
{
throw
new
AuthException
(
ResponseStatus
.
ILLEGAL_REDIRECT_URI
);
throw
new
AuthException
(
Auth
ResponseStatus
.
ILLEGAL_REDIRECT_URI
);
}
// 支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1
if
(
AuthSource
.
ALIPAY
==
source
&&
GlobalAuthUtil
.
isLocalHost
(
redirectUri
))
{
throw
new
AuthException
(
ResponseStatus
.
ILLEGAL_REDIRECT_URI
);
throw
new
AuthException
(
Auth
ResponseStatus
.
ILLEGAL_REDIRECT_URI
);
}
}
...
...
@@ -57,7 +57,7 @@ public class AuthChecker {
*/
public
static
void
checkCode
(
String
code
)
{
if
(
StringUtils
.
isEmpty
(
code
))
{
throw
new
AuthException
(
ResponseStatus
.
ILLEGAL_CODE
);
throw
new
AuthException
(
Auth
ResponseStatus
.
ILLEGAL_CODE
);
}
}
...
...
@@ -74,11 +74,11 @@ public class AuthChecker {
}
// 如果授权之前使用了state,但是回调时未返回state,则表示当前请求为非法的请求,可能正在被CSRF攻击
if
(
StringUtils
.
isEmpty
(
newState
))
{
throw
new
AuthException
(
ResponseStatus
.
ILLEGAL_REQUEST
);
throw
new
AuthException
(
Auth
ResponseStatus
.
ILLEGAL_REQUEST
);
}
// 如果授权前后的state不一致,则表示当前请求为非法的请求,新的state可能为伪造
if
(!
newState
.
equals
(
originalState
))
{
throw
new
AuthException
(
ResponseStatus
.
ILLEGAL_REQUEST
);
throw
new
AuthException
(
Auth
ResponseStatus
.
ILLEGAL_REQUEST
);
}
}
}
src/main/java/me/zhyd/oauth/utils/AuthState.java
浏览文件 @
8a486107
...
...
@@ -5,7 +5,7 @@ import cn.hutool.core.util.RandomUtil;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.
request.
ResponseStatus
;
import
me.zhyd.oauth.
model.Auth
ResponseStatus
;
import
java.nio.charset.Charset
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -113,7 +113,7 @@ public class AuthState {
String
noneSourceState
=
decodedState
.
substring
(
source
.
length
()
+
1
);
if
(!
noneSourceState
.
startsWith
(
currentIp
))
{
// ip不相同,可能为非法的请求
throw
new
AuthException
(
ResponseStatus
.
ILLEGAL_REQUEST
);
throw
new
AuthException
(
Auth
ResponseStatus
.
ILLEGAL_REQUEST
);
}
String
body
=
noneSourceState
.
substring
(
currentIp
.
length
()
+
1
);
log
.
debug
(
"body is [{}]"
,
body
);
...
...
update.md
浏览文件 @
8a486107
### 2019/07/16
1.
重构UrlBuilder类
2.
将CSDN相关的类置为
`Deprecated`
,后续可能会删除,也可能一直保留。毕竟CSDN的openAPI已经不对外开放了。
3.
`BaseAuthRequest`
改名为
`AuthDefaultRequest`
3.
`ResponseStatus`
改名为
`AuthResponseStatus`
并且移动到
`me.zhyd.oauth.model`
### 2019/07/15
1.
新增
`AuthState`
类,内置默认的state生成规则和校验规则
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录