Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kuyz
JustAuth
提交
bb613010
J
JustAuth
项目概览
kuyz
/
JustAuth
与 Fork 源项目一致
Fork自
justauth / JustAuth
通知
1
Star
0
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,发现更多精彩内容 >>
提交
bb613010
编写于
6月 19, 2019
作者:
不合群的混子
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🏗
架构调整,简化代码
上级
937fba37
变更
47
隐藏空白更改
内联
并排
Showing
47 changed file
with
355 addition
and
824 deletion
+355
-824
src/main/java/me/zhyd/oauth/authorization/AlipayAuthorization.java
...java/me/zhyd/oauth/authorization/AlipayAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/Authorization.java
src/main/java/me/zhyd/oauth/authorization/Authorization.java
+0
-21
src/main/java/me/zhyd/oauth/authorization/AuthorizationFactory.java
...ava/me/zhyd/oauth/authorization/AuthorizationFactory.java
+0
-81
src/main/java/me/zhyd/oauth/authorization/BaiduAuthorization.java
.../java/me/zhyd/oauth/authorization/BaiduAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/CodingAuthorization.java
...java/me/zhyd/oauth/authorization/CodingAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/CsdnAuthorization.java
...n/java/me/zhyd/oauth/authorization/CsdnAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/DingTalkAuthorization.java
...va/me/zhyd/oauth/authorization/DingTalkAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/DouyinAuthorization.java
...java/me/zhyd/oauth/authorization/DouyinAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/FacebookAuthorization.java
...va/me/zhyd/oauth/authorization/FacebookAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/GiteeAuthorization.java
.../java/me/zhyd/oauth/authorization/GiteeAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/GithubAuthorization.java
...java/me/zhyd/oauth/authorization/GithubAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/GoogleAuthorization.java
...java/me/zhyd/oauth/authorization/GoogleAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/LinkedinAuthorization.java
...va/me/zhyd/oauth/authorization/LinkedinAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/MiAuthorization.java
...ain/java/me/zhyd/oauth/authorization/MiAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/MicrosoftAuthorization.java
...a/me/zhyd/oauth/authorization/MicrosoftAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/OschinaAuthorization.java
...ava/me/zhyd/oauth/authorization/OschinaAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/QqAuthorization.java
...ain/java/me/zhyd/oauth/authorization/QqAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/TaobaoAuthorization.java
...java/me/zhyd/oauth/authorization/TaobaoAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/TencentCloudAuthorization.java
...e/zhyd/oauth/authorization/TencentCloudAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/ToutiaoAuthorization.java
...ava/me/zhyd/oauth/authorization/ToutiaoAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/WeChatAuthorization.java
...java/me/zhyd/oauth/authorization/WeChatAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/authorization/WeiboAuthorization.java
.../java/me/zhyd/oauth/authorization/WeiboAuthorization.java
+0
-19
src/main/java/me/zhyd/oauth/config/AuthSource.java
src/main/java/me/zhyd/oauth/config/AuthSource.java
+10
-176
src/main/java/me/zhyd/oauth/model/AuthSource.java
src/main/java/me/zhyd/oauth/model/AuthSource.java
+0
-31
src/main/java/me/zhyd/oauth/model/AuthUser.java
src/main/java/me/zhyd/oauth/model/AuthUser.java
+1
-0
src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
+15
-5
src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
+15
-6
src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
+12
-4
src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
+14
-5
src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
+14
-7
src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
+11
-1
src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java
src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java
+13
-2
src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
+14
-5
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
+14
-5
src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
+11
-1
src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java
src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java
+21
-5
src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
+11
-1
src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
...main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
+11
-1
src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
+14
-5
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
+11
-1
src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
+14
-5
src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
...n/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
+12
-4
src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java
src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java
+11
-0
src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
+16
-1
src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
+15
-3
src/main/java/me/zhyd/oauth/request/BaseAuthRequest.java
src/main/java/me/zhyd/oauth/request/BaseAuthRequest.java
+7
-5
src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
+68
-63
未找到文件。
src/main/java/me/zhyd/oauth/authorization/AlipayAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 支付宝授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
AlipayAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getAlipayAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/Authorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
/**
* 授权接口,用来获取具体第三方平台的授权地址
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
interface
Authorization
{
/**
* 获取授权页面地址
*
* @param config 授权基础配置
* @return 授权页面地址
*/
String
getAuthorizeUrl
(
AuthConfig
config
);
}
src/main/java/me/zhyd/oauth/authorization/AuthorizationFactory.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.request.ResponseStatus
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 授权工厂类,负责创建指定平台的授权类获取授权地址
* <p>
* 使用策略模式 + 工厂模式 避免大量的if else(swatch)操作
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
AuthorizationFactory
{
private
static
Map
<
String
,
Authorization
>
authorizationMap
=
new
HashMap
<>();
private
static
boolean
loader
=
false
;
private
AuthorizationFactory
()
{
}
/**
* 根据第三方平台,获取具体的授权工具
*
* @param source 平台
* @return 具体的Authorization
*/
public
static
Authorization
getAuthorize
(
AuthSource
source
)
{
if
(
null
==
source
)
{
throw
new
AuthException
(
ResponseStatus
.
NO_AUTH_SOURCE
);
}
registerAllAuthorize
();
Authorization
authorization
=
authorizationMap
.
get
(
source
.
toString
());
if
(
null
==
authorization
)
{
throw
new
AuthException
(
ResponseStatus
.
UNIDENTIFIED_PLATFORM
);
}
return
authorization
;
}
/**
* 将所有Authorize的实现类注册到authorizeMap中,
* 每次增加新的平台都需要在这儿添加注册代码
*/
private
static
void
registerAllAuthorize
()
{
if
(
loader
)
{
return
;
}
AuthorizationFactory
.
register
(
AuthSource
.
ALIPAY
,
new
AlipayAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
BAIDU
,
new
BaiduAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
CODING
,
new
CodingAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
CSDN
,
new
CsdnAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
DINGTALK
,
new
DingTalkAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
GITEE
,
new
GiteeAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
GITHUB
,
new
GithubAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
GOOGLE
,
new
GoogleAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
OSCHINA
,
new
OschinaAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
QQ
,
new
QqAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
TAOBAO
,
new
TaobaoAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
TENCENT_CLOUD
,
new
TencentCloudAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
WECHAT
,
new
WeChatAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
WEIBO
,
new
WeiboAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
FACEBOOK
,
new
FacebookAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
DOUYIN
,
new
DouyinAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
LINKEDIN
,
new
LinkedinAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
MICROSOFT
,
new
MicrosoftAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
MI
,
new
MiAuthorization
());
AuthorizationFactory
.
register
(
AuthSource
.
TOUTIAO
,
new
ToutiaoAuthorization
());
loader
=
true
;
}
private
static
void
register
(
AuthSource
authSource
,
Authorization
authorization
)
{
authorizationMap
.
put
(
authSource
.
toString
(),
authorization
);
}
}
src/main/java/me/zhyd/oauth/authorization/BaiduAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 百度授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
BaiduAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getBaiduAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/CodingAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* Coding授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
CodingAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getCodingAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/CsdnAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* CSDN授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
CsdnAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getCsdnAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/DingTalkAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 钉钉授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
DingTalkAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getDingTalkQrConnectUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/DouyinAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 抖音授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
DouyinAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getDouyinAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/FacebookAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* Facebook授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.3
* @since 1.3
*/
public
class
FacebookAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getFacebookAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/GiteeAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 码云授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
GiteeAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getGiteeAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/GithubAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* Github授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
GithubAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getGithubAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/GoogleAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* Google授权
*
* @author yangkai.shen (https://xkcoding.com)
* @version 1.3
* @since 1.3
*/
public
class
GoogleAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getGoogleAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/LinkedinAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 领英授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
LinkedinAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getLinkedinAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/MiAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 小米授权
*
* @author yangkai.shen (https://xkcoding.com)
* @version 1.5
* @since 1.5
*/
public
class
MiAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getMiAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/MicrosoftAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 微软授权
*
* @author yangkai.shen (https://xkcoding.com)
* @version 1.5
* @since 1.5
*/
public
class
MicrosoftAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getMicrosoftAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/OschinaAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 开源中国授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
OschinaAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getOschinaAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/QqAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* QQ授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
QqAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getQqAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/TaobaoAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 淘宝授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
TaobaoAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getTaobaoAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/TencentCloudAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 腾讯云授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
TencentCloudAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getTencentCloudAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/ToutiaoAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 今日头条授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
ToutiaoAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getToutiaoAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/WeChatAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 微信授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
WeChatAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getWeChatAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/authorization/WeiboAuthorization.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.authorization
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 微博授权
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
class
WeiboAuthorization
implements
Authorization
{
@Override
public
String
getAuthorizeUrl
(
AuthConfig
config
)
{
return
UrlBuilder
.
getWeiboAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
src/main/java/me/zhyd/oauth/con
sts/ApiUrl
.java
→
src/main/java/me/zhyd/oauth/con
fig/AuthSource
.java
浏览文件 @
bb613010
package
me.zhyd.oauth.con
sts
;
package
me.zhyd.oauth.con
fig
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.request.ResponseStatus
;
import
me.zhyd.oauth.request.ResponseStatus
;
...
@@ -10,7 +10,7 @@ import me.zhyd.oauth.request.ResponseStatus;
...
@@ -10,7 +10,7 @@ import me.zhyd.oauth.request.ResponseStatus;
* @version 1.0
* @version 1.0
* @since 1.0
* @since 1.0
*/
*/
public
enum
A
piUrl
{
public
enum
A
uthSource
{
/**
/**
* Github
* Github
*/
*/
...
@@ -29,16 +29,6 @@ public enum ApiUrl {
...
@@ -29,16 +29,6 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
return
"https://api.github.com/user"
;
return
"https://api.github.com/user"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* 新浪微博
* 新浪微博
...
@@ -58,16 +48,6 @@ public enum ApiUrl {
...
@@ -58,16 +48,6 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
return
"https://api.weibo.com/2/users/show.json"
;
return
"https://api.weibo.com/2/users/show.json"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* gitee
* gitee
...
@@ -87,16 +67,6 @@ public enum ApiUrl {
...
@@ -87,16 +67,6 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
return
"https://gitee.com/api/v5/user"
;
return
"https://gitee.com/api/v5/user"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* 钉钉
* 钉钉
...
@@ -116,16 +86,6 @@ public enum ApiUrl {
...
@@ -116,16 +86,6 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
return
"https://oapi.dingtalk.com/sns/getuserinfo_bycode"
;
return
"https://oapi.dingtalk.com/sns/getuserinfo_bycode"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* 百度
* 百度
...
@@ -150,11 +110,6 @@ public enum ApiUrl {
...
@@ -150,11 +110,6 @@ public enum ApiUrl {
public
String
revoke
()
{
public
String
revoke
()
{
return
"https://openapi.baidu.com/rest/2.0/passport/auth/revokeAuthorization"
;
return
"https://openapi.baidu.com/rest/2.0/passport/auth/revokeAuthorization"
;
}
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* csdn
* csdn
...
@@ -174,16 +129,6 @@ public enum ApiUrl {
...
@@ -174,16 +129,6 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
return
"https://api.csdn.net/user/getinfo"
;
return
"https://api.csdn.net/user/getinfo"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* Coding
* Coding
...
@@ -203,21 +148,11 @@ public enum ApiUrl {
...
@@ -203,21 +148,11 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
return
"https://coding.net/api/account/current_user"
;
return
"https://coding.net/api/account/current_user"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* 腾讯云开发者平台(coding升级后就变成腾讯云开发者平台了)
* 腾讯云开发者平台(coding升级后就变成腾讯云开发者平台了)
*/
*/
TENCENTCLOUD
{
TENCENT
_
CLOUD
{
@Override
@Override
public
String
authorize
()
{
public
String
authorize
()
{
return
"https://dev.tencent.com/oauth_authorize.html"
;
return
"https://dev.tencent.com/oauth_authorize.html"
;
...
@@ -232,16 +167,6 @@ public enum ApiUrl {
...
@@ -232,16 +167,6 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
return
"https://dev.tencent.com/api/account/current_user"
;
return
"https://dev.tencent.com/api/account/current_user"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* oschina 开源中国
* oschina 开源中国
...
@@ -261,16 +186,6 @@ public enum ApiUrl {
...
@@ -261,16 +186,6 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
return
"https://www.oschina.net/action/openapi/user"
;
return
"https://www.oschina.net/action/openapi/user"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* 支付宝
* 支付宝
...
@@ -290,16 +205,6 @@ public enum ApiUrl {
...
@@ -290,16 +205,6 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
return
"https://openapi.alipay.com/gateway.do"
;
return
"https://openapi.alipay.com/gateway.do"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* QQ
* QQ
...
@@ -319,16 +224,6 @@ public enum ApiUrl {
...
@@ -319,16 +224,6 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
return
"https://graph.qq.com/user/get_user_info"
;
return
"https://graph.qq.com/user/get_user_info"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* 微信
* 微信
...
@@ -349,11 +244,6 @@ public enum ApiUrl {
...
@@ -349,11 +244,6 @@ public enum ApiUrl {
return
"https://api.weixin.qq.com/sns/userinfo"
;
return
"https://api.weixin.qq.com/sns/userinfo"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
@Override
public
String
refresh
()
{
public
String
refresh
()
{
return
"https://api.weixin.qq.com/sns/oauth2/refresh_token"
;
return
"https://api.weixin.qq.com/sns/oauth2/refresh_token"
;
...
@@ -377,16 +267,6 @@ public enum ApiUrl {
...
@@ -377,16 +267,6 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* Google
* Google
...
@@ -406,16 +286,6 @@ public enum ApiUrl {
...
@@ -406,16 +286,6 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
return
"https://oauth2.googleapis.com/tokeninfo"
;
return
"https://oauth2.googleapis.com/tokeninfo"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* Facebook
* Facebook
...
@@ -435,16 +305,6 @@ public enum ApiUrl {
...
@@ -435,16 +305,6 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
return
"https://graph.facebook.com/v3.3/me"
;
return
"https://graph.facebook.com/v3.3/me"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
},
},
/**
/**
* 抖音
* 抖音
...
@@ -465,11 +325,6 @@ public enum ApiUrl {
...
@@ -465,11 +325,6 @@ public enum ApiUrl {
return
"https://open.douyin.com/oauth/userinfo"
;
return
"https://open.douyin.com/oauth/userinfo"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
@Override
public
String
refresh
()
{
public
String
refresh
()
{
return
"https://open.douyin.com/oauth/refresh_token"
;
return
"https://open.douyin.com/oauth/refresh_token"
;
...
@@ -494,11 +349,6 @@ public enum ApiUrl {
...
@@ -494,11 +349,6 @@ public enum ApiUrl {
return
"https://api.linkedin.com/v2/me"
;
return
"https://api.linkedin.com/v2/me"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
@Override
public
String
refresh
()
{
public
String
refresh
()
{
return
"https://www.linkedin.com/oauth/v2/accessToken"
;
return
"https://www.linkedin.com/oauth/v2/accessToken"
;
...
@@ -523,11 +373,6 @@ public enum ApiUrl {
...
@@ -523,11 +373,6 @@ public enum ApiUrl {
return
"https://graph.microsoft.com/v1.0/me"
;
return
"https://graph.microsoft.com/v1.0/me"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
@Override
public
String
refresh
()
{
public
String
refresh
()
{
return
"https://login.microsoftonline.com/common/oauth2/v2.0/token"
;
return
"https://login.microsoftonline.com/common/oauth2/v2.0/token"
;
...
@@ -552,11 +397,6 @@ public enum ApiUrl {
...
@@ -552,11 +397,6 @@ public enum ApiUrl {
return
"https://open.account.xiaomi.com/user/profile"
;
return
"https://open.account.xiaomi.com/user/profile"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
@Override
public
String
refresh
()
{
public
String
refresh
()
{
return
"https://account.xiaomi.com/oauth2/token"
;
return
"https://account.xiaomi.com/oauth2/token"
;
...
@@ -580,16 +420,6 @@ public enum ApiUrl {
...
@@ -580,16 +420,6 @@ public enum ApiUrl {
public
String
userInfo
()
{
public
String
userInfo
()
{
return
"https://open.snssdk.com/data/user_profile"
;
return
"https://open.snssdk.com/data/user_profile"
;
}
}
@Override
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
@Override
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
};
};
/**
/**
...
@@ -618,13 +448,17 @@ public enum ApiUrl {
...
@@ -618,13 +448,17 @@ public enum ApiUrl {
*
*
* @return url
* @return url
*/
*/
public
abstract
String
revoke
();
public
String
revoke
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
/**
/**
* 刷新授权的api
* 刷新授权的api
*
*
* @return url
* @return url
*/
*/
public
abstract
String
refresh
();
public
String
refresh
()
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
}
}
\ No newline at end of file
src/main/java/me/zhyd/oauth/model/AuthSource.java
已删除
100644 → 0
浏览文件 @
937fba37
package
me.zhyd.oauth.model
;
/**
* 授权来源(平台)
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
*/
public
enum
AuthSource
{
GITHUB
,
GITEE
,
WEIBO
,
DINGTALK
,
BAIDU
,
CSDN
,
CODING
,
OSCHINA
,
TENCENT_CLOUD
,
ALIPAY
,
TAOBAO
,
QQ
,
WECHAT
,
GOOGLE
,
FACEBOOK
,
DOUYIN
,
LINKEDIN
,
MICROSOFT
,
MI
,
TOUTIAO
}
src/main/java/me/zhyd/oauth/model/AuthUser.java
浏览文件 @
bb613010
...
@@ -2,6 +2,7 @@ package me.zhyd.oauth.model;
...
@@ -2,6 +2,7 @@ package me.zhyd.oauth.model;
import
lombok.Builder
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
me.zhyd.oauth.config.AuthSource
;
/**
/**
* 授权成功后的用户信息,根据授权平台的不同,获取的数据完整性也不同
* 授权成功后的用户信息,根据授权平台的不同,获取的数据完整性也不同
...
...
src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
浏览文件 @
bb613010
...
@@ -8,13 +8,13 @@ import com.alipay.api.request.AlipayUserInfoShareRequest;
...
@@ -8,13 +8,13 @@ import com.alipay.api.request.AlipayUserInfoShareRequest;
import
com.alipay.api.response.AlipaySystemOauthTokenResponse
;
import
com.alipay.api.response.AlipaySystemOauthTokenResponse
;
import
com.alipay.api.response.AlipayUserInfoShareResponse
;
import
com.alipay.api.response.AlipayUserInfoShareResponse
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.con
sts.ApiUrl
;
import
me.zhyd.oauth.con
fig.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.utils.StringUtils
;
import
me.zhyd.oauth.utils.StringUtils
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
/**
* 支付宝登录
* 支付宝登录
...
@@ -29,7 +29,8 @@ public class AuthAlipayRequest extends BaseAuthRequest {
...
@@ -29,7 +29,8 @@ public class AuthAlipayRequest extends BaseAuthRequest {
public
AuthAlipayRequest
(
AuthConfig
config
)
{
public
AuthAlipayRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
ALIPAY
);
super
(
config
,
AuthSource
.
ALIPAY
);
this
.
alipayClient
=
new
DefaultAlipayClient
(
ApiUrl
.
ALIPAY
.
accessToken
(),
config
.
getClientId
(),
config
.
getClientSecret
(),
"json"
,
"UTF-8"
,
config
.
getAlipayPublicKey
(),
"RSA2"
);
this
.
alipayClient
=
new
DefaultAlipayClient
(
AuthSource
.
ALIPAY
.
accessToken
(),
config
.
getClientId
(),
config
.
getClientSecret
(),
"json"
,
"UTF-8"
,
config
.
getAlipayPublicKey
(),
"RSA2"
);
}
}
@Override
@Override
...
@@ -67,8 +68,7 @@ public class AuthAlipayRequest extends BaseAuthRequest {
...
@@ -67,8 +68,7 @@ public class AuthAlipayRequest extends BaseAuthRequest {
if
(!
response
.
isSuccess
())
{
if
(!
response
.
isSuccess
())
{
throw
new
AuthException
(
response
.
getSubMsg
());
throw
new
AuthException
(
response
.
getSubMsg
());
}
}
String
province
=
response
.
getProvince
(),
String
province
=
response
.
getProvince
(),
city
=
response
.
getCity
();
city
=
response
.
getCity
();
return
AuthUser
.
builder
()
return
AuthUser
.
builder
()
.
uuid
(
response
.
getUserId
())
.
uuid
(
response
.
getUserId
())
.
username
(
StringUtils
.
isEmpty
(
response
.
getUserName
())
?
response
.
getNickName
()
:
response
.
getUserName
())
.
username
(
StringUtils
.
isEmpty
(
response
.
getUserName
())
?
response
.
getNickName
()
:
response
.
getUserName
())
...
@@ -80,4 +80,14 @@ public class AuthAlipayRequest extends BaseAuthRequest {
...
@@ -80,4 +80,14 @@ public class AuthAlipayRequest extends BaseAuthRequest {
.
source
(
AuthSource
.
ALIPAY
)
.
source
(
AuthSource
.
ALIPAY
)
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getAlipayAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
}
src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
浏览文件 @
bb613010
...
@@ -3,8 +3,8 @@ package me.zhyd.oauth.request;
...
@@ -3,8 +3,8 @@ package me.zhyd.oauth.request;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.utils.UrlBuilder
;
import
me.zhyd.oauth.utils.UrlBuilder
;
...
@@ -24,16 +24,15 @@ public class AuthBaiduRequest extends BaseAuthRequest {
...
@@ -24,16 +24,15 @@ public class AuthBaiduRequest extends BaseAuthRequest {
@Override
@Override
protected
AuthToken
getAccessToken
(
String
code
)
{
protected
AuthToken
getAccessToken
(
String
code
)
{
String
accessTokenUrl
=
UrlBuilder
.
getBaiduAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
String
accessTokenUrl
=
UrlBuilder
.
getBaiduAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
JSONObject
accessTokenObject
=
JSONObject
.
parseObject
(
response
.
body
());
JSONObject
accessTokenObject
=
JSONObject
.
parseObject
(
response
.
body
());
AuthBaiduErrorCode
errorCode
=
AuthBaiduErrorCode
.
getErrorCode
(
accessTokenObject
.
getString
(
"error"
));
AuthBaiduErrorCode
errorCode
=
AuthBaiduErrorCode
.
getErrorCode
(
accessTokenObject
.
getString
(
"error"
));
if
(!
AuthBaiduErrorCode
.
OK
.
equals
(
errorCode
))
{
if
(!
AuthBaiduErrorCode
.
OK
.
equals
(
errorCode
))
{
throw
new
AuthException
(
errorCode
.
getDesc
());
throw
new
AuthException
(
errorCode
.
getDesc
());
}
}
return
AuthToken
.
builder
()
return
AuthToken
.
builder
().
accessToken
(
accessTokenObject
.
getString
(
"access_token"
)).
build
();
.
accessToken
(
accessTokenObject
.
getString
(
"access_token"
))
.
build
();
}
}
@Override
@Override
...
@@ -56,13 +55,23 @@ public class AuthBaiduRequest extends BaseAuthRequest {
...
@@ -56,13 +55,23 @@ public class AuthBaiduRequest extends BaseAuthRequest {
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getBaiduAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
@Override
@Override
public
AuthResponse
revoke
(
AuthToken
authToken
)
{
public
AuthResponse
revoke
(
AuthToken
authToken
)
{
String
accessToken
=
authToken
.
getAccessToken
();
String
accessToken
=
authToken
.
getAccessToken
();
HttpResponse
response
=
HttpRequest
.
get
(
UrlBuilder
.
getBaiduRevokeUrl
(
accessToken
)).
execute
();
HttpResponse
response
=
HttpRequest
.
get
(
UrlBuilder
.
getBaiduRevokeUrl
(
accessToken
)).
execute
();
String
userInfo
=
response
.
body
();
String
userInfo
=
response
.
body
();
JSONObject
object
=
JSONObject
.
parseObject
(
userInfo
);
JSONObject
object
=
JSONObject
.
parseObject
(
userInfo
);
if
(
object
.
containsKey
(
"error_code"
))
{
if
(
object
.
containsKey
(
"error_code"
))
{
return
AuthResponse
.
builder
()
return
AuthResponse
.
builder
()
.
code
(
ResponseStatus
.
FAILURE
.
getCode
())
.
code
(
ResponseStatus
.
FAILURE
.
getCode
())
.
msg
(
object
.
getString
(
"error_msg"
))
.
msg
(
object
.
getString
(
"error_msg"
))
...
...
src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
浏览文件 @
bb613010
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.model.AuthUserGender
;
...
@@ -32,9 +32,7 @@ public class AuthCodingRequest extends BaseAuthRequest {
...
@@ -32,9 +32,7 @@ public class AuthCodingRequest extends BaseAuthRequest {
if
(
accessTokenObject
.
getIntValue
(
"code"
)
!=
0
)
{
if
(
accessTokenObject
.
getIntValue
(
"code"
)
!=
0
)
{
throw
new
AuthException
(
"Unable to get token from coding using code ["
+
code
+
"]"
);
throw
new
AuthException
(
"Unable to get token from coding using code ["
+
code
+
"]"
);
}
}
return
AuthToken
.
builder
()
return
AuthToken
.
builder
().
accessToken
(
accessTokenObject
.
getString
(
"access_token"
)).
build
();
.
accessToken
(
accessTokenObject
.
getString
(
"access_token"
))
.
build
();
}
}
@Override
@Override
...
@@ -61,4 +59,14 @@ public class AuthCodingRequest extends BaseAuthRequest {
...
@@ -61,4 +59,14 @@ public class AuthCodingRequest extends BaseAuthRequest {
.
source
(
AuthSource
.
CODING
)
.
source
(
AuthSource
.
CODING
)
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getCodingAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
}
src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
浏览文件 @
bb613010
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.utils.UrlBuilder
;
import
me.zhyd.oauth.utils.UrlBuilder
;
...
@@ -25,15 +25,14 @@ public class AuthCsdnRequest extends BaseAuthRequest {
...
@@ -25,15 +25,14 @@ public class AuthCsdnRequest extends BaseAuthRequest {
@Override
@Override
protected
AuthToken
getAccessToken
(
String
code
)
{
protected
AuthToken
getAccessToken
(
String
code
)
{
String
accessTokenUrl
=
UrlBuilder
.
getCsdnAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
String
accessTokenUrl
=
UrlBuilder
.
getCsdnAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
JSONObject
accessTokenObject
=
JSONObject
.
parseObject
(
response
.
body
());
JSONObject
accessTokenObject
=
JSONObject
.
parseObject
(
response
.
body
());
if
(
accessTokenObject
.
containsKey
(
"error_code"
))
{
if
(
accessTokenObject
.
containsKey
(
"error_code"
))
{
throw
new
AuthException
(
"Unable to get token from csdn using code ["
+
code
+
"]"
);
throw
new
AuthException
(
"Unable to get token from csdn using code ["
+
code
+
"]"
);
}
}
return
AuthToken
.
builder
()
return
AuthToken
.
builder
().
accessToken
(
accessTokenObject
.
getString
(
"access_token"
)).
build
();
.
accessToken
(
accessTokenObject
.
getString
(
"access_token"
))
.
build
();
}
}
@Override
@Override
...
@@ -53,4 +52,14 @@ public class AuthCsdnRequest extends BaseAuthRequest {
...
@@ -53,4 +52,14 @@ public class AuthCsdnRequest extends BaseAuthRequest {
.
source
(
AuthSource
.
CSDN
)
.
source
(
AuthSource
.
CSDN
)
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getCsdnAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
}
src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
浏览文件 @
bb613010
...
@@ -4,9 +4,9 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,9 +4,9 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthDingTalkErrorCode
;
import
me.zhyd.oauth.model.AuthDingTalkErrorCode
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.utils.GlobalAuthUtil
;
import
me.zhyd.oauth.utils.GlobalAuthUtil
;
...
@@ -29,9 +29,7 @@ public class AuthDingTalkRequest extends BaseAuthRequest {
...
@@ -29,9 +29,7 @@ public class AuthDingTalkRequest extends BaseAuthRequest {
@Override
@Override
protected
AuthToken
getAccessToken
(
String
code
)
{
protected
AuthToken
getAccessToken
(
String
code
)
{
return
AuthToken
.
builder
()
return
AuthToken
.
builder
().
accessCode
(
code
).
build
();
.
accessCode
(
code
)
.
build
();
}
}
@Override
@Override
...
@@ -40,9 +38,8 @@ public class AuthDingTalkRequest extends BaseAuthRequest {
...
@@ -40,9 +38,8 @@ public class AuthDingTalkRequest extends BaseAuthRequest {
// 根据timestamp, appSecret计算签名值
// 根据timestamp, appSecret计算签名值
String
stringToSign
=
System
.
currentTimeMillis
()
+
""
;
String
stringToSign
=
System
.
currentTimeMillis
()
+
""
;
String
urlEncodeSignature
=
GlobalAuthUtil
.
generateDingTalkSignature
(
config
.
getClientSecret
(),
stringToSign
);
String
urlEncodeSignature
=
GlobalAuthUtil
.
generateDingTalkSignature
(
config
.
getClientSecret
(),
stringToSign
);
HttpResponse
response
=
HttpRequest
.
post
(
UrlBuilder
.
getDingTalkUserInfoUrl
(
urlEncodeSignature
,
stringToSign
,
config
.
getClientId
()))
HttpResponse
response
=
HttpRequest
.
post
(
UrlBuilder
.
getDingTalkUserInfoUrl
(
urlEncodeSignature
,
stringToSign
,
config
.
body
(
Objects
.
requireNonNull
(
new
JSONObject
().
put
(
"tmp_auth_code"
,
code
)))
.
getClientId
())).
body
(
Objects
.
requireNonNull
(
new
JSONObject
().
put
(
"tmp_auth_code"
,
code
))).
execute
();
.
execute
();
String
userInfo
=
response
.
body
();
String
userInfo
=
response
.
body
();
JSONObject
object
=
new
JSONObject
(
userInfo
);
JSONObject
object
=
new
JSONObject
(
userInfo
);
AuthDingTalkErrorCode
errorCode
=
AuthDingTalkErrorCode
.
getErrorCode
(
object
.
getInt
(
"errcode"
));
AuthDingTalkErrorCode
errorCode
=
AuthDingTalkErrorCode
.
getErrorCode
(
object
.
getInt
(
"errcode"
));
...
@@ -57,4 +54,14 @@ public class AuthDingTalkRequest extends BaseAuthRequest {
...
@@ -57,4 +54,14 @@ public class AuthDingTalkRequest extends BaseAuthRequest {
.
source
(
AuthSource
.
DINGTALK
)
.
source
(
AuthSource
.
DINGTALK
)
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getDingTalkQrConnectUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
}
src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
浏览文件 @
bb613010
...
@@ -4,9 +4,9 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,9 +4,9 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.utils.UrlBuilder
;
import
me.zhyd.oauth.utils.UrlBuilder
;
...
@@ -50,6 +50,16 @@ public class AuthDouyinRequest extends BaseAuthRequest {
...
@@ -50,6 +50,16 @@ public class AuthDouyinRequest extends BaseAuthRequest {
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getDouyinAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
@Override
@Override
public
AuthResponse
refresh
(
AuthToken
oldToken
)
{
public
AuthResponse
refresh
(
AuthToken
oldToken
)
{
String
refreshTokenUrl
=
UrlBuilder
.
getDouyinRefreshUrl
(
config
.
getClientId
(),
oldToken
.
getRefreshToken
());
String
refreshTokenUrl
=
UrlBuilder
.
getDouyinRefreshUrl
(
config
.
getClientId
(),
oldToken
.
getRefreshToken
());
...
...
src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java
浏览文件 @
bb613010
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.model.AuthUserGender
;
...
@@ -26,7 +26,8 @@ public class AuthFacebookRequest extends BaseAuthRequest {
...
@@ -26,7 +26,8 @@ public class AuthFacebookRequest extends BaseAuthRequest {
@Override
@Override
protected
AuthToken
getAccessToken
(
String
code
)
{
protected
AuthToken
getAccessToken
(
String
code
)
{
String
accessTokenUrl
=
UrlBuilder
.
getFacebookAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
String
accessTokenUrl
=
UrlBuilder
.
getFacebookAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
JSONObject
object
=
JSONObject
.
parseObject
(
response
.
body
());
JSONObject
object
=
JSONObject
.
parseObject
(
response
.
body
());
...
@@ -70,4 +71,14 @@ public class AuthFacebookRequest extends BaseAuthRequest {
...
@@ -70,4 +71,14 @@ public class AuthFacebookRequest extends BaseAuthRequest {
.
source
(
AuthSource
.
FACEBOOK
)
.
source
(
AuthSource
.
FACEBOOK
)
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getFacebookAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
}
src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
浏览文件 @
bb613010
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.utils.UrlBuilder
;
import
me.zhyd.oauth.utils.UrlBuilder
;
...
@@ -25,15 +25,14 @@ public class AuthGiteeRequest extends BaseAuthRequest {
...
@@ -25,15 +25,14 @@ public class AuthGiteeRequest extends BaseAuthRequest {
@Override
@Override
protected
AuthToken
getAccessToken
(
String
code
)
{
protected
AuthToken
getAccessToken
(
String
code
)
{
String
accessTokenUrl
=
UrlBuilder
.
getGiteeAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
String
accessTokenUrl
=
UrlBuilder
.
getGiteeAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
JSONObject
accessTokenObject
=
JSONObject
.
parseObject
(
response
.
body
());
JSONObject
accessTokenObject
=
JSONObject
.
parseObject
(
response
.
body
());
if
(
accessTokenObject
.
containsKey
(
"error"
))
{
if
(
accessTokenObject
.
containsKey
(
"error"
))
{
throw
new
AuthException
(
"Unable to get token from gitee using code ["
+
code
+
"]"
);
throw
new
AuthException
(
"Unable to get token from gitee using code ["
+
code
+
"]"
);
}
}
return
AuthToken
.
builder
()
return
AuthToken
.
builder
().
accessToken
(
accessTokenObject
.
getString
(
"access_token"
)).
build
();
.
accessToken
(
accessTokenObject
.
getString
(
"access_token"
))
.
build
();
}
}
@Override
@Override
...
@@ -56,4 +55,14 @@ public class AuthGiteeRequest extends BaseAuthRequest {
...
@@ -56,4 +55,14 @@ public class AuthGiteeRequest extends BaseAuthRequest {
.
source
(
AuthSource
.
GITEE
)
.
source
(
AuthSource
.
GITEE
)
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getGiteeAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
}
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
浏览文件 @
bb613010
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.utils.GlobalAuthUtil
;
import
me.zhyd.oauth.utils.GlobalAuthUtil
;
...
@@ -28,15 +28,14 @@ public class AuthGithubRequest extends BaseAuthRequest {
...
@@ -28,15 +28,14 @@ public class AuthGithubRequest extends BaseAuthRequest {
@Override
@Override
protected
AuthToken
getAccessToken
(
String
code
)
{
protected
AuthToken
getAccessToken
(
String
code
)
{
String
accessTokenUrl
=
UrlBuilder
.
getGithubAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
String
accessTokenUrl
=
UrlBuilder
.
getGithubAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
Map
<
String
,
String
>
res
=
GlobalAuthUtil
.
parseStringToMap
(
response
.
body
());
Map
<
String
,
String
>
res
=
GlobalAuthUtil
.
parseStringToMap
(
response
.
body
());
if
(
res
.
containsKey
(
"error"
))
{
if
(
res
.
containsKey
(
"error"
))
{
throw
new
AuthException
(
res
.
get
(
"error"
)
+
":"
+
res
.
get
(
"error_description"
));
throw
new
AuthException
(
res
.
get
(
"error"
)
+
":"
+
res
.
get
(
"error_description"
));
}
}
return
AuthToken
.
builder
()
return
AuthToken
.
builder
().
accessToken
(
res
.
get
(
"access_token"
)).
build
();
.
accessToken
(
res
.
get
(
"access_token"
))
.
build
();
}
}
@Override
@Override
...
@@ -59,4 +58,14 @@ public class AuthGithubRequest extends BaseAuthRequest {
...
@@ -59,4 +58,14 @@ public class AuthGithubRequest extends BaseAuthRequest {
.
source
(
AuthSource
.
GITHUB
)
.
source
(
AuthSource
.
GITHUB
)
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getGithubAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
}
src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
浏览文件 @
bb613010
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.utils.UrlBuilder
;
import
me.zhyd.oauth.utils.UrlBuilder
;
...
@@ -61,4 +61,14 @@ public class AuthGoogleRequest extends BaseAuthRequest {
...
@@ -61,4 +61,14 @@ public class AuthGoogleRequest extends BaseAuthRequest {
.
source
(
AuthSource
.
GOOGLE
)
.
source
(
AuthSource
.
GOOGLE
)
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getGoogleAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
}
src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java
浏览文件 @
bb613010
...
@@ -5,9 +5,9 @@ import cn.hutool.http.HttpResponse;
...
@@ -5,9 +5,9 @@ import cn.hutool.http.HttpResponse;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.utils.StringUtils
;
import
me.zhyd.oauth.utils.StringUtils
;
...
@@ -29,7 +29,8 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
...
@@ -29,7 +29,8 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
@Override
@Override
protected
AuthToken
getAccessToken
(
String
code
)
{
protected
AuthToken
getAccessToken
(
String
code
)
{
String
accessTokenUrl
=
UrlBuilder
.
getLinkedinAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
String
accessTokenUrl
=
UrlBuilder
.
getLinkedinAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
return
this
.
getToken
(
accessTokenUrl
);
return
this
.
getToken
(
accessTokenUrl
);
}
}
...
@@ -65,7 +66,8 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
...
@@ -65,7 +66,8 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
String
avatar
=
null
;
String
avatar
=
null
;
JSONObject
profilePictureObject
=
userInfoObject
.
getJSONObject
(
"profilePicture"
);
JSONObject
profilePictureObject
=
userInfoObject
.
getJSONObject
(
"profilePicture"
);
if
(
profilePictureObject
.
containsKey
(
"displayImage~"
))
{
if
(
profilePictureObject
.
containsKey
(
"displayImage~"
))
{
JSONArray
displayImageElements
=
profilePictureObject
.
getJSONObject
(
"displayImage~"
).
getJSONArray
(
"elements"
);
JSONArray
displayImageElements
=
profilePictureObject
.
getJSONObject
(
"displayImage~"
)
.
getJSONArray
(
"elements"
);
if
(
null
!=
displayImageElements
&&
displayImageElements
.
size
()
>
0
)
{
if
(
null
!=
displayImageElements
&&
displayImageElements
.
size
()
>
0
)
{
JSONObject
largestImageObj
=
displayImageElements
.
getJSONObject
(
displayImageElements
.
size
()
-
1
);
JSONObject
largestImageObj
=
displayImageElements
.
getJSONObject
(
displayImageElements
.
size
()
-
1
);
avatar
=
largestImageObj
.
getJSONArray
(
"identifiers"
).
getJSONObject
(
0
).
getString
(
"identifier"
);
avatar
=
largestImageObj
.
getJSONArray
(
"identifiers"
).
getJSONObject
(
0
).
getString
(
"identifier"
);
...
@@ -85,6 +87,16 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
...
@@ -85,6 +87,16 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getLinkedinAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
private
String
getUserEmail
(
String
accessToken
)
{
private
String
getUserEmail
(
String
accessToken
)
{
String
email
=
null
;
String
email
=
null
;
HttpResponse
emailResponse
=
HttpRequest
.
get
(
"https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))"
)
HttpResponse
emailResponse
=
HttpRequest
.
get
(
"https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))"
)
...
@@ -95,7 +107,10 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
...
@@ -95,7 +107,10 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
System
.
out
.
println
(
emailResponse
.
body
());
System
.
out
.
println
(
emailResponse
.
body
());
JSONObject
emailObj
=
JSONObject
.
parseObject
(
emailResponse
.
body
());
JSONObject
emailObj
=
JSONObject
.
parseObject
(
emailResponse
.
body
());
if
(
emailObj
.
containsKey
(
"elements"
))
{
if
(
emailObj
.
containsKey
(
"elements"
))
{
email
=
emailObj
.
getJSONArray
(
"elements"
).
getJSONObject
(
0
).
getJSONObject
(
"handle~"
).
getString
(
"emailAddress"
);
email
=
emailObj
.
getJSONArray
(
"elements"
)
.
getJSONObject
(
0
)
.
getJSONObject
(
"handle~"
)
.
getString
(
"emailAddress"
);
}
}
return
email
;
return
email
;
}
}
...
@@ -114,7 +129,8 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
...
@@ -114,7 +129,8 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
if
(
StringUtils
.
isEmpty
(
oldToken
.
getRefreshToken
()))
{
if
(
StringUtils
.
isEmpty
(
oldToken
.
getRefreshToken
()))
{
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
throw
new
AuthException
(
ResponseStatus
.
UNSUPPORTED
);
}
}
String
refreshTokenUrl
=
UrlBuilder
.
getLinkedinRefreshUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
oldToken
.
getRefreshToken
());
String
refreshTokenUrl
=
UrlBuilder
.
getLinkedinRefreshUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
oldToken
.
getRefreshToken
());
return
AuthResponse
.
builder
()
return
AuthResponse
.
builder
()
.
code
(
ResponseStatus
.
SUCCESS
.
getCode
())
.
code
(
ResponseStatus
.
SUCCESS
.
getCode
())
.
data
(
this
.
getToken
(
refreshTokenUrl
))
.
data
(
this
.
getToken
(
refreshTokenUrl
))
...
...
src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
浏览文件 @
bb613010
...
@@ -5,9 +5,9 @@ import cn.hutool.http.HttpRequest;
...
@@ -5,9 +5,9 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.utils.UrlBuilder
;
import
me.zhyd.oauth.utils.UrlBuilder
;
...
@@ -92,6 +92,16 @@ public class AuthMiRequest extends BaseAuthRequest {
...
@@ -92,6 +92,16 @@ public class AuthMiRequest extends BaseAuthRequest {
return
authUser
;
return
authUser
;
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getMiAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
/**
/**
* 刷新access token (续期)
* 刷新access token (续期)
*
*
...
...
src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
浏览文件 @
bb613010
...
@@ -5,9 +5,9 @@ import cn.hutool.http.HttpResponse;
...
@@ -5,9 +5,9 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.utils.UrlBuilder
;
import
me.zhyd.oauth.utils.UrlBuilder
;
...
@@ -90,6 +90,16 @@ public class AuthMicrosoftRequest extends BaseAuthRequest {
...
@@ -90,6 +90,16 @@ public class AuthMicrosoftRequest extends BaseAuthRequest {
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getMicrosoftAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
/**
/**
* 刷新access token (续期)
* 刷新access token (续期)
*
*
...
...
src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
浏览文件 @
bb613010
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.model.AuthUserGender
;
...
@@ -26,15 +26,14 @@ public class AuthOschinaRequest extends BaseAuthRequest {
...
@@ -26,15 +26,14 @@ public class AuthOschinaRequest extends BaseAuthRequest {
@Override
@Override
protected
AuthToken
getAccessToken
(
String
code
)
{
protected
AuthToken
getAccessToken
(
String
code
)
{
String
accessTokenUrl
=
UrlBuilder
.
getOschinaAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
String
accessTokenUrl
=
UrlBuilder
.
getOschinaAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
JSONObject
accessTokenObject
=
JSONObject
.
parseObject
(
response
.
body
());
JSONObject
accessTokenObject
=
JSONObject
.
parseObject
(
response
.
body
());
if
(
accessTokenObject
.
containsKey
(
"error"
))
{
if
(
accessTokenObject
.
containsKey
(
"error"
))
{
throw
new
AuthException
(
"Unable to get token from oschina using code ["
+
code
+
"]"
);
throw
new
AuthException
(
"Unable to get token from oschina using code ["
+
code
+
"]"
);
}
}
return
AuthToken
.
builder
()
return
AuthToken
.
builder
().
accessToken
(
accessTokenObject
.
getString
(
"access_token"
)).
build
();
.
accessToken
(
accessTokenObject
.
getString
(
"access_token"
))
.
build
();
}
}
@Override
@Override
...
@@ -58,4 +57,14 @@ public class AuthOschinaRequest extends BaseAuthRequest {
...
@@ -58,4 +57,14 @@ public class AuthOschinaRequest extends BaseAuthRequest {
.
source
(
AuthSource
.
OSCHINA
)
.
source
(
AuthSource
.
OSCHINA
)
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getOschinaAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
}
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
浏览文件 @
bb613010
...
@@ -5,8 +5,8 @@ import cn.hutool.http.HttpRequest;
...
@@ -5,8 +5,8 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.model.AuthUserGender
;
...
@@ -71,6 +71,16 @@ public class AuthQqRequest extends BaseAuthRequest {
...
@@ -71,6 +71,16 @@ public class AuthQqRequest extends BaseAuthRequest {
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getQqAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
private
String
getOpenId
(
String
accessToken
)
{
private
String
getOpenId
(
String
accessToken
)
{
HttpResponse
response
=
HttpRequest
.
get
(
UrlBuilder
.
getQqOpenidUrl
(
"https://graph.qq.com/oauth2.0/me"
,
accessToken
))
HttpResponse
response
=
HttpRequest
.
get
(
UrlBuilder
.
getQqOpenidUrl
(
"https://graph.qq.com/oauth2.0/me"
,
accessToken
))
.
execute
();
.
execute
();
...
...
src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
浏览文件 @
bb613010
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.model.AuthUserGender
;
...
@@ -27,15 +27,14 @@ public class AuthTaobaoRequest extends BaseAuthRequest {
...
@@ -27,15 +27,14 @@ public class AuthTaobaoRequest extends BaseAuthRequest {
@Override
@Override
protected
AuthToken
getAccessToken
(
String
code
)
{
protected
AuthToken
getAccessToken
(
String
code
)
{
return
AuthToken
.
builder
()
return
AuthToken
.
builder
().
accessCode
(
code
).
build
();
.
accessCode
(
code
)
.
build
();
}
}
@Override
@Override
protected
AuthUser
getUserInfo
(
AuthToken
authToken
)
{
protected
AuthUser
getUserInfo
(
AuthToken
authToken
)
{
String
accessCode
=
authToken
.
getAccessCode
();
String
accessCode
=
authToken
.
getAccessCode
();
HttpResponse
response
=
HttpRequest
.
post
(
UrlBuilder
.
getTaobaoAccessTokenUrl
(
this
.
config
.
getClientId
(),
this
.
config
.
getClientSecret
(),
accessCode
,
this
.
config
.
getRedirectUri
())).
execute
();
HttpResponse
response
=
HttpRequest
.
post
(
UrlBuilder
.
getTaobaoAccessTokenUrl
(
this
.
config
.
getClientId
(),
this
.
config
.
getClientSecret
(),
accessCode
,
this
.
config
.
getRedirectUri
())).
execute
();
JSONObject
object
=
JSONObject
.
parseObject
(
response
.
body
());
JSONObject
object
=
JSONObject
.
parseObject
(
response
.
body
());
if
(
object
.
containsKey
(
"error"
))
{
if
(
object
.
containsKey
(
"error"
))
{
throw
new
AuthException
(
ResponseStatus
.
FAILURE
+
":"
+
object
.
getString
(
"error_description"
));
throw
new
AuthException
(
ResponseStatus
.
FAILURE
+
":"
+
object
.
getString
(
"error_description"
));
...
@@ -56,4 +55,14 @@ public class AuthTaobaoRequest extends BaseAuthRequest {
...
@@ -56,4 +55,14 @@ public class AuthTaobaoRequest extends BaseAuthRequest {
.
source
(
AuthSource
.
TAOBAO
)
.
source
(
AuthSource
.
TAOBAO
)
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getTaobaoAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
}
src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
浏览文件 @
bb613010
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.model.AuthUserGender
;
...
@@ -32,9 +32,7 @@ public class AuthTencentCloudRequest extends BaseAuthRequest {
...
@@ -32,9 +32,7 @@ public class AuthTencentCloudRequest extends BaseAuthRequest {
if
(
object
.
getIntValue
(
"code"
)
!=
0
)
{
if
(
object
.
getIntValue
(
"code"
)
!=
0
)
{
throw
new
AuthException
(
"Unable to get token from tencent cloud using code ["
+
code
+
"]: "
+
object
.
get
(
"msg"
));
throw
new
AuthException
(
"Unable to get token from tencent cloud using code ["
+
code
+
"]: "
+
object
.
get
(
"msg"
));
}
}
return
AuthToken
.
builder
()
return
AuthToken
.
builder
().
accessToken
(
object
.
getString
(
"access_token"
)).
build
();
.
accessToken
(
object
.
getString
(
"access_token"
))
.
build
();
}
}
@Override
@Override
...
@@ -61,4 +59,14 @@ public class AuthTencentCloudRequest extends BaseAuthRequest {
...
@@ -61,4 +59,14 @@ public class AuthTencentCloudRequest extends BaseAuthRequest {
.
source
(
AuthSource
.
TENCENT_CLOUD
)
.
source
(
AuthSource
.
TENCENT_CLOUD
)
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getTencentCloudAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
}
src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java
浏览文件 @
bb613010
...
@@ -4,6 +4,7 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,6 +4,7 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.utils.UrlBuilder
;
import
me.zhyd.oauth.utils.UrlBuilder
;
...
@@ -64,4 +65,14 @@ public class AuthToutiaoRequest extends BaseAuthRequest {
...
@@ -64,4 +65,14 @@ public class AuthToutiaoRequest extends BaseAuthRequest {
.
source
(
AuthSource
.
TOUTIAO
)
.
source
(
AuthSource
.
TOUTIAO
)
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getToutiaoAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
}
src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
浏览文件 @
bb613010
...
@@ -4,8 +4,12 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,8 +4,12 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.utils.UrlBuilder
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
/**
...
@@ -54,6 +58,16 @@ public class AuthWeChatRequest extends BaseAuthRequest {
...
@@ -54,6 +58,16 @@ public class AuthWeChatRequest extends BaseAuthRequest {
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getWeChatAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
@Override
@Override
public
AuthResponse
refresh
(
AuthToken
oldToken
)
{
public
AuthResponse
refresh
(
AuthToken
oldToken
)
{
String
refreshTokenUrl
=
UrlBuilder
.
getWeChatRefreshUrl
(
config
.
getClientId
(),
oldToken
.
getRefreshToken
());
String
refreshTokenUrl
=
UrlBuilder
.
getWeChatRefreshUrl
(
config
.
getClientId
(),
oldToken
.
getRefreshToken
());
...
@@ -73,6 +87,7 @@ public class AuthWeChatRequest extends BaseAuthRequest {
...
@@ -73,6 +87,7 @@ public class AuthWeChatRequest extends BaseAuthRequest {
throw
new
AuthException
(
object
.
getIntValue
(
"errcode"
),
object
.
getString
(
"errmsg"
));
throw
new
AuthException
(
object
.
getIntValue
(
"errcode"
),
object
.
getString
(
"errmsg"
));
}
}
}
}
/**
/**
* 获取token,适用于获取access_token和刷新token
* 获取token,适用于获取access_token和刷新token
*
*
...
...
src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
浏览文件 @
bb613010
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUserGender
;
import
me.zhyd.oauth.model.AuthUserGender
;
...
@@ -29,7 +29,8 @@ public class AuthWeiboRequest extends BaseAuthRequest {
...
@@ -29,7 +29,8 @@ public class AuthWeiboRequest extends BaseAuthRequest {
@Override
@Override
protected
AuthToken
getAccessToken
(
String
code
)
{
protected
AuthToken
getAccessToken
(
String
code
)
{
String
accessTokenUrl
=
UrlBuilder
.
getWeiboAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
String
accessTokenUrl
=
UrlBuilder
.
getWeiboAccessTokenUrl
(
config
.
getClientId
(),
config
.
getClientSecret
(),
code
,
config
.
getRedirectUri
());
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
HttpResponse
response
=
HttpRequest
.
post
(
accessTokenUrl
).
execute
();
String
accessTokenStr
=
response
.
body
();
String
accessTokenStr
=
response
.
body
();
JSONObject
accessTokenObject
=
JSONObject
.
parseObject
(
accessTokenStr
);
JSONObject
accessTokenObject
=
JSONObject
.
parseObject
(
accessTokenStr
);
...
@@ -61,7 +62,8 @@ public class AuthWeiboRequest extends BaseAuthRequest {
...
@@ -61,7 +62,8 @@ public class AuthWeiboRequest extends BaseAuthRequest {
.
uuid
(
object
.
getString
(
"id"
))
.
uuid
(
object
.
getString
(
"id"
))
.
username
(
object
.
getString
(
"name"
))
.
username
(
object
.
getString
(
"name"
))
.
avatar
(
object
.
getString
(
"profile_image_url"
))
.
avatar
(
object
.
getString
(
"profile_image_url"
))
.
blog
(
StringUtils
.
isEmpty
(
object
.
getString
(
"url"
))
?
"https://weibo.com/"
+
object
.
getString
(
"profile_url"
)
:
object
.
getString
(
"url"
))
.
blog
(
StringUtils
.
isEmpty
(
object
.
getString
(
"url"
))
?
"https://weibo.com/"
+
object
.
getString
(
"profile_url"
)
:
object
.
getString
(
"url"
))
.
nickname
(
object
.
getString
(
"screen_name"
))
.
nickname
(
object
.
getString
(
"screen_name"
))
.
location
(
object
.
getString
(
"location"
))
.
location
(
object
.
getString
(
"location"
))
.
remark
(
object
.
getString
(
"description"
))
.
remark
(
object
.
getString
(
"description"
))
...
@@ -70,4 +72,14 @@ public class AuthWeiboRequest extends BaseAuthRequest {
...
@@ -70,4 +72,14 @@ public class AuthWeiboRequest extends BaseAuthRequest {
.
source
(
AuthSource
.
WEIBO
)
.
source
(
AuthSource
.
WEIBO
)
.
build
();
.
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public
String
authorize
()
{
return
UrlBuilder
.
getWeiboAuthorizeUrl
(
config
.
getClientId
(),
config
.
getRedirectUri
());
}
}
}
src/main/java/me/zhyd/oauth/request/BaseAuthRequest.java
浏览文件 @
bb613010
package
me.zhyd.oauth.request
;
package
me.zhyd.oauth.request
;
import
lombok.Data
;
import
lombok.Data
;
import
me.zhyd.oauth.authorization.AuthorizationFactory
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.utils.AuthConfigChecker
;
import
me.zhyd.oauth.utils.AuthConfigChecker
;
...
@@ -51,8 +50,11 @@ public abstract class BaseAuthRequest implements AuthRequest {
...
@@ -51,8 +50,11 @@ public abstract class BaseAuthRequest implements AuthRequest {
return
AuthResponse
.
builder
().
code
(
errorCode
).
msg
(
e
.
getMessage
()).
build
();
return
AuthResponse
.
builder
().
code
(
errorCode
).
msg
(
e
.
getMessage
()).
build
();
}
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
@Override
public
String
authorize
()
{
public
abstract
String
authorize
();
return
AuthorizationFactory
.
getAuthorize
(
source
).
getAuthorizeUrl
(
config
);
}
}
}
src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
浏览文件 @
bb613010
package
me.zhyd.oauth.utils
;
package
me.zhyd.oauth.utils
;
import
me.zhyd.oauth.con
sts.ApiUrl
;
import
me.zhyd.oauth.con
fig.AuthSource
;
import
java.text.MessageFormat
;
import
java.text.MessageFormat
;
...
@@ -106,7 +106,7 @@ public class UrlBuilder {
...
@@ -106,7 +106,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getGithubAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
public
static
String
getGithubAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
return
MessageFormat
.
format
(
GITHUB_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
GITHUB
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
return
MessageFormat
.
format
(
GITHUB_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
GITHUB
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
}
}
/**
/**
...
@@ -116,7 +116,7 @@ public class UrlBuilder {
...
@@ -116,7 +116,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getGithubUserInfoUrl
(
String
token
)
{
public
static
String
getGithubUserInfoUrl
(
String
token
)
{
return
MessageFormat
.
format
(
GITHUB_USER_INFO_PATTERN
,
A
piUrl
.
GITHUB
.
userInfo
(),
token
);
return
MessageFormat
.
format
(
GITHUB_USER_INFO_PATTERN
,
A
uthSource
.
GITHUB
.
userInfo
(),
token
);
}
}
/**
/**
...
@@ -127,7 +127,7 @@ public class UrlBuilder {
...
@@ -127,7 +127,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getGithubAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getGithubAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
GITHUB_AUTHORIZE_PATTERN
,
A
piUrl
.
GITHUB
.
authorize
(),
clientId
,
redirectUrl
);
return
MessageFormat
.
format
(
GITHUB_AUTHORIZE_PATTERN
,
A
uthSource
.
GITHUB
.
authorize
(),
clientId
,
redirectUrl
);
}
}
/**
/**
...
@@ -140,7 +140,7 @@ public class UrlBuilder {
...
@@ -140,7 +140,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getWeiboAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
public
static
String
getWeiboAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
return
MessageFormat
.
format
(
WEIBO_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
WEIBO
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
return
MessageFormat
.
format
(
WEIBO_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
WEIBO
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
}
}
/**
/**
...
@@ -150,7 +150,7 @@ public class UrlBuilder {
...
@@ -150,7 +150,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getWeiboUserInfoUrl
(
String
token
)
{
public
static
String
getWeiboUserInfoUrl
(
String
token
)
{
return
MessageFormat
.
format
(
WEIBO_USER_INFO_PATTERN
,
A
piUrl
.
WEIBO
.
userInfo
(),
token
);
return
MessageFormat
.
format
(
WEIBO_USER_INFO_PATTERN
,
A
uthSource
.
WEIBO
.
userInfo
(),
token
);
}
}
/**
/**
...
@@ -161,7 +161,7 @@ public class UrlBuilder {
...
@@ -161,7 +161,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getWeiboAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getWeiboAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
WEIBO_AUTHORIZE_PATTERN
,
A
piUrl
.
WEIBO
.
authorize
(),
clientId
,
redirectUrl
);
return
MessageFormat
.
format
(
WEIBO_AUTHORIZE_PATTERN
,
A
uthSource
.
WEIBO
.
authorize
(),
clientId
,
redirectUrl
);
}
}
/**
/**
...
@@ -174,7 +174,7 @@ public class UrlBuilder {
...
@@ -174,7 +174,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getGiteeAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
public
static
String
getGiteeAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
return
MessageFormat
.
format
(
GITEE_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
GITEE
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
return
MessageFormat
.
format
(
GITEE_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
GITEE
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
}
}
/**
/**
...
@@ -184,7 +184,7 @@ public class UrlBuilder {
...
@@ -184,7 +184,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getGiteeUserInfoUrl
(
String
token
)
{
public
static
String
getGiteeUserInfoUrl
(
String
token
)
{
return
MessageFormat
.
format
(
GITEE_USER_INFO_PATTERN
,
A
piUrl
.
GITEE
.
userInfo
(),
token
);
return
MessageFormat
.
format
(
GITEE_USER_INFO_PATTERN
,
A
uthSource
.
GITEE
.
userInfo
(),
token
);
}
}
/**
/**
...
@@ -195,7 +195,7 @@ public class UrlBuilder {
...
@@ -195,7 +195,7 @@ public class UrlBuilder {
* @return json
* @return json
*/
*/
public
static
String
getGiteeAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getGiteeAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
GITEE_AUTHORIZE_PATTERN
,
A
piUrl
.
GITEE
.
authorize
(),
clientId
,
redirectUrl
);
return
MessageFormat
.
format
(
GITEE_AUTHORIZE_PATTERN
,
A
uthSource
.
GITEE
.
authorize
(),
clientId
,
redirectUrl
);
}
}
/**
/**
...
@@ -206,7 +206,7 @@ public class UrlBuilder {
...
@@ -206,7 +206,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getDingTalkQrConnectUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getDingTalkQrConnectUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
DING_TALK_QRCONNECT_PATTERN
,
A
piUrl
.
DINGTALK
.
authorize
(),
clientId
,
redirectUrl
);
return
MessageFormat
.
format
(
DING_TALK_QRCONNECT_PATTERN
,
A
uthSource
.
DINGTALK
.
authorize
(),
clientId
,
redirectUrl
);
}
}
/**
/**
...
@@ -218,7 +218,7 @@ public class UrlBuilder {
...
@@ -218,7 +218,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getDingTalkUserInfoUrl
(
String
signature
,
String
timestamp
,
String
accessKey
)
{
public
static
String
getDingTalkUserInfoUrl
(
String
signature
,
String
timestamp
,
String
accessKey
)
{
return
MessageFormat
.
format
(
DING_TALK_USER_INFO_PATTERN
,
A
piUrl
.
DINGTALK
.
userInfo
(),
signature
,
timestamp
,
accessKey
);
return
MessageFormat
.
format
(
DING_TALK_USER_INFO_PATTERN
,
A
uthSource
.
DINGTALK
.
userInfo
(),
signature
,
timestamp
,
accessKey
);
}
}
/**
/**
...
@@ -231,7 +231,7 @@ public class UrlBuilder {
...
@@ -231,7 +231,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getBaiduAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
public
static
String
getBaiduAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
return
MessageFormat
.
format
(
BAIDU_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
BAIDU
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
return
MessageFormat
.
format
(
BAIDU_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
BAIDU
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
}
}
/**
/**
...
@@ -241,7 +241,7 @@ public class UrlBuilder {
...
@@ -241,7 +241,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getBaiduUserInfoUrl
(
String
token
)
{
public
static
String
getBaiduUserInfoUrl
(
String
token
)
{
return
MessageFormat
.
format
(
BAIDU_USER_INFO_PATTERN
,
A
piUrl
.
BAIDU
.
userInfo
(),
token
);
return
MessageFormat
.
format
(
BAIDU_USER_INFO_PATTERN
,
A
uthSource
.
BAIDU
.
userInfo
(),
token
);
}
}
/**
/**
...
@@ -252,7 +252,7 @@ public class UrlBuilder {
...
@@ -252,7 +252,7 @@ public class UrlBuilder {
* @return json
* @return json
*/
*/
public
static
String
getBaiduAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getBaiduAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
BAIDU_AUTHORIZE_PATTERN
,
A
piUrl
.
BAIDU
.
authorize
(),
clientId
,
redirectUrl
);
return
MessageFormat
.
format
(
BAIDU_AUTHORIZE_PATTERN
,
A
uthSource
.
BAIDU
.
authorize
(),
clientId
,
redirectUrl
);
}
}
/**
/**
...
@@ -262,7 +262,7 @@ public class UrlBuilder {
...
@@ -262,7 +262,7 @@ public class UrlBuilder {
* @return json
* @return json
*/
*/
public
static
String
getBaiduRevokeUrl
(
String
accessToken
)
{
public
static
String
getBaiduRevokeUrl
(
String
accessToken
)
{
return
MessageFormat
.
format
(
BAIDU_REVOKE_PATTERN
,
A
piUrl
.
BAIDU
.
revoke
(),
accessToken
);
return
MessageFormat
.
format
(
BAIDU_REVOKE_PATTERN
,
A
uthSource
.
BAIDU
.
revoke
(),
accessToken
);
}
}
/**
/**
...
@@ -275,7 +275,7 @@ public class UrlBuilder {
...
@@ -275,7 +275,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getCsdnAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
public
static
String
getCsdnAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
return
MessageFormat
.
format
(
CSDN_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
CSDN
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
return
MessageFormat
.
format
(
CSDN_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
CSDN
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
}
}
/**
/**
...
@@ -285,7 +285,7 @@ public class UrlBuilder {
...
@@ -285,7 +285,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getCsdnUserInfoUrl
(
String
token
)
{
public
static
String
getCsdnUserInfoUrl
(
String
token
)
{
return
MessageFormat
.
format
(
CSDN_USER_INFO_PATTERN
,
A
piUrl
.
CSDN
.
userInfo
(),
token
);
return
MessageFormat
.
format
(
CSDN_USER_INFO_PATTERN
,
A
uthSource
.
CSDN
.
userInfo
(),
token
);
}
}
/**
/**
...
@@ -296,7 +296,7 @@ public class UrlBuilder {
...
@@ -296,7 +296,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getCsdnAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getCsdnAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
CSDN_AUTHORIZE_PATTERN
,
A
piUrl
.
CSDN
.
authorize
(),
clientId
,
redirectUrl
);
return
MessageFormat
.
format
(
CSDN_AUTHORIZE_PATTERN
,
A
uthSource
.
CSDN
.
authorize
(),
clientId
,
redirectUrl
);
}
}
/**
/**
...
@@ -308,7 +308,7 @@ public class UrlBuilder {
...
@@ -308,7 +308,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getCodingAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
)
{
public
static
String
getCodingAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
)
{
return
MessageFormat
.
format
(
CODING_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
CODING
.
accessToken
(),
clientId
,
clientSecret
,
code
);
return
MessageFormat
.
format
(
CODING_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
CODING
.
accessToken
(),
clientId
,
clientSecret
,
code
);
}
}
/**
/**
...
@@ -318,7 +318,7 @@ public class UrlBuilder {
...
@@ -318,7 +318,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getCodingUserInfoUrl
(
String
token
)
{
public
static
String
getCodingUserInfoUrl
(
String
token
)
{
return
MessageFormat
.
format
(
CODING_USER_INFO_PATTERN
,
A
piUrl
.
CODING
.
userInfo
(),
token
);
return
MessageFormat
.
format
(
CODING_USER_INFO_PATTERN
,
A
uthSource
.
CODING
.
userInfo
(),
token
);
}
}
/**
/**
...
@@ -329,7 +329,7 @@ public class UrlBuilder {
...
@@ -329,7 +329,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getCodingAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getCodingAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
CODING_AUTHORIZE_PATTERN
,
A
piUrl
.
CODING
.
authorize
(),
clientId
,
redirectUrl
);
return
MessageFormat
.
format
(
CODING_AUTHORIZE_PATTERN
,
A
uthSource
.
CODING
.
authorize
(),
clientId
,
redirectUrl
);
}
}
/**
/**
...
@@ -341,7 +341,7 @@ public class UrlBuilder {
...
@@ -341,7 +341,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getTencentCloudAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
)
{
public
static
String
getTencentCloudAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
)
{
return
MessageFormat
.
format
(
TENCENT_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
TENCENT
CLOUD
.
accessToken
(),
clientId
,
clientSecret
,
code
);
return
MessageFormat
.
format
(
TENCENT_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
TENCENT_
CLOUD
.
accessToken
(),
clientId
,
clientSecret
,
code
);
}
}
/**
/**
...
@@ -351,7 +351,7 @@ public class UrlBuilder {
...
@@ -351,7 +351,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getTencentCloudUserInfoUrl
(
String
token
)
{
public
static
String
getTencentCloudUserInfoUrl
(
String
token
)
{
return
MessageFormat
.
format
(
TENCENT_USER_INFO_PATTERN
,
A
piUrl
.
TENCENT
CLOUD
.
userInfo
(),
token
);
return
MessageFormat
.
format
(
TENCENT_USER_INFO_PATTERN
,
A
uthSource
.
TENCENT_
CLOUD
.
userInfo
(),
token
);
}
}
/**
/**
...
@@ -362,7 +362,7 @@ public class UrlBuilder {
...
@@ -362,7 +362,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getTencentCloudAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getTencentCloudAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
TENCENT_AUTHORIZE_PATTERN
,
A
piUrl
.
TENCENT
CLOUD
.
authorize
(),
clientId
,
redirectUrl
);
return
MessageFormat
.
format
(
TENCENT_AUTHORIZE_PATTERN
,
A
uthSource
.
TENCENT_
CLOUD
.
authorize
(),
clientId
,
redirectUrl
);
}
}
/**
/**
...
@@ -375,7 +375,7 @@ public class UrlBuilder {
...
@@ -375,7 +375,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getOschinaAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
public
static
String
getOschinaAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
return
MessageFormat
.
format
(
OSCHINA_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
OSCHINA
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
return
MessageFormat
.
format
(
OSCHINA_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
OSCHINA
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
}
}
/**
/**
...
@@ -385,7 +385,7 @@ public class UrlBuilder {
...
@@ -385,7 +385,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getOschinaUserInfoUrl
(
String
token
)
{
public
static
String
getOschinaUserInfoUrl
(
String
token
)
{
return
MessageFormat
.
format
(
OSCHINA_USER_INFO_PATTERN
,
A
piUrl
.
OSCHINA
.
userInfo
(),
token
);
return
MessageFormat
.
format
(
OSCHINA_USER_INFO_PATTERN
,
A
uthSource
.
OSCHINA
.
userInfo
(),
token
);
}
}
/**
/**
...
@@ -396,7 +396,7 @@ public class UrlBuilder {
...
@@ -396,7 +396,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getOschinaAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getOschinaAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
OSCHINA_AUTHORIZE_PATTERN
,
A
piUrl
.
OSCHINA
.
authorize
(),
clientId
,
redirectUrl
);
return
MessageFormat
.
format
(
OSCHINA_AUTHORIZE_PATTERN
,
A
uthSource
.
OSCHINA
.
authorize
(),
clientId
,
redirectUrl
);
}
}
/**
/**
...
@@ -409,7 +409,7 @@ public class UrlBuilder {
...
@@ -409,7 +409,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getQqAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
public
static
String
getQqAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
return
MessageFormat
.
format
(
QQ_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
QQ
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
return
MessageFormat
.
format
(
QQ_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
QQ
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
}
}
/**
/**
...
@@ -421,7 +421,7 @@ public class UrlBuilder {
...
@@ -421,7 +421,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getQqUserInfoUrl
(
String
clientId
,
String
token
,
String
openId
)
{
public
static
String
getQqUserInfoUrl
(
String
clientId
,
String
token
,
String
openId
)
{
return
MessageFormat
.
format
(
QQ_USER_INFO_PATTERN
,
A
piUrl
.
QQ
.
userInfo
(),
clientId
,
token
,
openId
);
return
MessageFormat
.
format
(
QQ_USER_INFO_PATTERN
,
A
uthSource
.
QQ
.
userInfo
(),
clientId
,
token
,
openId
);
}
}
/**
/**
...
@@ -432,7 +432,7 @@ public class UrlBuilder {
...
@@ -432,7 +432,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getQqAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getQqAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
QQ_AUTHORIZE_PATTERN
,
A
piUrl
.
QQ
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
return
MessageFormat
.
format
(
QQ_AUTHORIZE_PATTERN
,
A
uthSource
.
QQ
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
}
}
/**
/**
...
@@ -454,7 +454,7 @@ public class UrlBuilder {
...
@@ -454,7 +454,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getAlipayAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getAlipayAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
ALIPAY_AUTHORIZE_PATTERN
,
A
piUrl
.
ALIPAY
.
authorize
(),
clientId
,
redirectUrl
);
return
MessageFormat
.
format
(
ALIPAY_AUTHORIZE_PATTERN
,
A
uthSource
.
ALIPAY
.
authorize
(),
clientId
,
redirectUrl
);
}
}
/**
/**
...
@@ -465,7 +465,8 @@ public class UrlBuilder {
...
@@ -465,7 +465,8 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getWeChatAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getWeChatAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
WECHAT_AUTHORIZE_PATTERN
,
ApiUrl
.
WECHAT
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
return
MessageFormat
.
format
(
WECHAT_AUTHORIZE_PATTERN
,
AuthSource
.
WECHAT
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
}
}
/**
/**
...
@@ -477,7 +478,7 @@ public class UrlBuilder {
...
@@ -477,7 +478,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getWeChatAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
)
{
public
static
String
getWeChatAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
)
{
return
MessageFormat
.
format
(
WECHAT_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
WECHAT
.
accessToken
(),
clientId
,
clientSecret
,
code
);
return
MessageFormat
.
format
(
WECHAT_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
WECHAT
.
accessToken
(),
clientId
,
clientSecret
,
code
);
}
}
/**
/**
...
@@ -488,7 +489,7 @@ public class UrlBuilder {
...
@@ -488,7 +489,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getWeChatUserInfoUrl
(
String
token
,
String
openId
)
{
public
static
String
getWeChatUserInfoUrl
(
String
token
,
String
openId
)
{
return
MessageFormat
.
format
(
WECHAT_USER_INFO_PATTERN
,
A
piUrl
.
WECHAT
.
userInfo
(),
token
,
openId
);
return
MessageFormat
.
format
(
WECHAT_USER_INFO_PATTERN
,
A
uthSource
.
WECHAT
.
userInfo
(),
token
,
openId
);
}
}
/**
/**
...
@@ -499,7 +500,7 @@ public class UrlBuilder {
...
@@ -499,7 +500,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getWeChatRefreshUrl
(
String
clientId
,
String
refreshToken
)
{
public
static
String
getWeChatRefreshUrl
(
String
clientId
,
String
refreshToken
)
{
return
MessageFormat
.
format
(
WECHAT_REFRESH_TOKEN_PATTERN
,
A
piUrl
.
WECHAT
.
refresh
(),
clientId
,
refreshToken
);
return
MessageFormat
.
format
(
WECHAT_REFRESH_TOKEN_PATTERN
,
A
uthSource
.
WECHAT
.
refresh
(),
clientId
,
refreshToken
);
}
}
/**
/**
...
@@ -512,7 +513,7 @@ public class UrlBuilder {
...
@@ -512,7 +513,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getTaobaoAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
public
static
String
getTaobaoAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
return
MessageFormat
.
format
(
TAOBAO_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
TAOBAO
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
return
MessageFormat
.
format
(
TAOBAO_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
TAOBAO
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
}
}
/**
/**
...
@@ -523,7 +524,8 @@ public class UrlBuilder {
...
@@ -523,7 +524,8 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getTaobaoAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getTaobaoAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
TAOBAO_AUTHORIZE_PATTERN
,
ApiUrl
.
TAOBAO
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
return
MessageFormat
.
format
(
TAOBAO_AUTHORIZE_PATTERN
,
AuthSource
.
TAOBAO
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
}
}
/**
/**
...
@@ -534,7 +536,8 @@ public class UrlBuilder {
...
@@ -534,7 +536,8 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getGoogleAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getGoogleAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
GOOGLE_AUTHORIZE_PATTERN
,
ApiUrl
.
GOOGLE
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
return
MessageFormat
.
format
(
GOOGLE_AUTHORIZE_PATTERN
,
AuthSource
.
GOOGLE
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
}
}
/**
/**
...
@@ -547,7 +550,7 @@ public class UrlBuilder {
...
@@ -547,7 +550,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getGoogleAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
public
static
String
getGoogleAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
return
MessageFormat
.
format
(
GOOGLE_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
GOOGLE
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
return
MessageFormat
.
format
(
GOOGLE_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
GOOGLE
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
}
}
/**
/**
...
@@ -557,7 +560,7 @@ public class UrlBuilder {
...
@@ -557,7 +560,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getGoogleUserInfoUrl
(
String
token
)
{
public
static
String
getGoogleUserInfoUrl
(
String
token
)
{
return
MessageFormat
.
format
(
GOOGLE_USER_INFO_PATTERN
,
A
piUrl
.
GOOGLE
.
userInfo
(),
token
);
return
MessageFormat
.
format
(
GOOGLE_USER_INFO_PATTERN
,
A
uthSource
.
GOOGLE
.
userInfo
(),
token
);
}
}
/**
/**
...
@@ -568,7 +571,7 @@ public class UrlBuilder {
...
@@ -568,7 +571,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getFacebookAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getFacebookAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
FACEBOOK_AUTHORIZE_PATTERN
,
A
piUrl
.
FACEBOOK
.
authorize
(),
clientId
,
redirectUrl
,
System
return
MessageFormat
.
format
(
FACEBOOK_AUTHORIZE_PATTERN
,
A
uthSource
.
FACEBOOK
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
.
currentTimeMillis
());
}
}
...
@@ -582,7 +585,7 @@ public class UrlBuilder {
...
@@ -582,7 +585,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getFacebookAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
public
static
String
getFacebookAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUri
)
{
return
MessageFormat
.
format
(
FACEBOOK_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
FACEBOOK
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
return
MessageFormat
.
format
(
FACEBOOK_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
FACEBOOK
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUri
);
}
}
/**
/**
...
@@ -592,7 +595,7 @@ public class UrlBuilder {
...
@@ -592,7 +595,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getFacebookUserInfoUrl
(
String
token
)
{
public
static
String
getFacebookUserInfoUrl
(
String
token
)
{
return
MessageFormat
.
format
(
FACEBOOK_USER_INFO_PATTERN
,
A
piUrl
.
FACEBOOK
.
userInfo
(),
token
);
return
MessageFormat
.
format
(
FACEBOOK_USER_INFO_PATTERN
,
A
uthSource
.
FACEBOOK
.
userInfo
(),
token
);
}
}
/**
/**
...
@@ -603,7 +606,8 @@ public class UrlBuilder {
...
@@ -603,7 +606,8 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getDouyinAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getDouyinAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
DOUYIN_AUTHORIZE_PATTERN
,
ApiUrl
.
DOUYIN
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
return
MessageFormat
.
format
(
DOUYIN_AUTHORIZE_PATTERN
,
AuthSource
.
DOUYIN
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
}
}
/**
/**
...
@@ -615,7 +619,7 @@ public class UrlBuilder {
...
@@ -615,7 +619,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getDouyinAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
)
{
public
static
String
getDouyinAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
)
{
return
MessageFormat
.
format
(
DOUYIN_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
DOUYIN
.
accessToken
(),
clientId
,
clientSecret
,
code
);
return
MessageFormat
.
format
(
DOUYIN_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
DOUYIN
.
accessToken
(),
clientId
,
clientSecret
,
code
);
}
}
/**
/**
...
@@ -626,7 +630,7 @@ public class UrlBuilder {
...
@@ -626,7 +630,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getDouyinUserInfoUrl
(
String
token
,
String
openId
)
{
public
static
String
getDouyinUserInfoUrl
(
String
token
,
String
openId
)
{
return
MessageFormat
.
format
(
DOUYIN_USER_INFO_PATTERN
,
A
piUrl
.
DOUYIN
.
userInfo
(),
token
,
openId
);
return
MessageFormat
.
format
(
DOUYIN_USER_INFO_PATTERN
,
A
uthSource
.
DOUYIN
.
userInfo
(),
token
,
openId
);
}
}
/**
/**
...
@@ -637,7 +641,7 @@ public class UrlBuilder {
...
@@ -637,7 +641,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getDouyinRefreshUrl
(
String
clientId
,
String
refreshToken
)
{
public
static
String
getDouyinRefreshUrl
(
String
clientId
,
String
refreshToken
)
{
return
MessageFormat
.
format
(
DOUYIN_REFRESH_TOKEN_PATTERN
,
A
piUrl
.
DOUYIN
.
refresh
(),
clientId
,
refreshToken
);
return
MessageFormat
.
format
(
DOUYIN_REFRESH_TOKEN_PATTERN
,
A
uthSource
.
DOUYIN
.
refresh
(),
clientId
,
refreshToken
);
}
}
/**
/**
...
@@ -648,7 +652,7 @@ public class UrlBuilder {
...
@@ -648,7 +652,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getLinkedinAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getLinkedinAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
LINKEDIN_AUTHORIZE_PATTERN
,
A
piUrl
.
LINKEDIN
.
authorize
(),
clientId
,
redirectUrl
,
System
return
MessageFormat
.
format
(
LINKEDIN_AUTHORIZE_PATTERN
,
A
uthSource
.
LINKEDIN
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
.
currentTimeMillis
());
}
}
...
@@ -662,7 +666,7 @@ public class UrlBuilder {
...
@@ -662,7 +666,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getLinkedinAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUrl
)
{
public
static
String
getLinkedinAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
LINKEDIN_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
LINKEDIN
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUrl
);
return
MessageFormat
.
format
(
LINKEDIN_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
LINKEDIN
.
accessToken
(),
clientId
,
clientSecret
,
code
,
redirectUrl
);
}
}
/**
/**
...
@@ -671,7 +675,7 @@ public class UrlBuilder {
...
@@ -671,7 +675,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getLinkedinUserInfoUrl
()
{
public
static
String
getLinkedinUserInfoUrl
()
{
return
MessageFormat
.
format
(
LINKEDIN_USER_INFO_PATTERN
,
A
piUrl
.
LINKEDIN
.
userInfo
());
return
MessageFormat
.
format
(
LINKEDIN_USER_INFO_PATTERN
,
A
uthSource
.
LINKEDIN
.
userInfo
());
}
}
/**
/**
...
@@ -683,7 +687,7 @@ public class UrlBuilder {
...
@@ -683,7 +687,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getLinkedinRefreshUrl
(
String
clientId
,
String
clientSecret
,
String
refreshToken
)
{
public
static
String
getLinkedinRefreshUrl
(
String
clientId
,
String
clientSecret
,
String
refreshToken
)
{
return
MessageFormat
.
format
(
LINKEDIN_REFRESH_TOKEN_PATTERN
,
A
piUrl
.
LINKEDIN
.
refresh
(),
clientId
,
clientSecret
,
refreshToken
);
return
MessageFormat
.
format
(
LINKEDIN_REFRESH_TOKEN_PATTERN
,
A
uthSource
.
LINKEDIN
.
refresh
(),
clientId
,
clientSecret
,
refreshToken
);
}
}
/**
/**
...
@@ -694,7 +698,7 @@ public class UrlBuilder {
...
@@ -694,7 +698,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getMicrosoftAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getMicrosoftAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
MICROSOFT_AUTHORIZE_PATTERN
,
A
piUrl
.
MICROSOFT
.
authorize
(),
clientId
,
redirectUrl
,
System
return
MessageFormat
.
format
(
MICROSOFT_AUTHORIZE_PATTERN
,
A
uthSource
.
MICROSOFT
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
.
currentTimeMillis
());
}
}
...
@@ -708,7 +712,7 @@ public class UrlBuilder {
...
@@ -708,7 +712,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getMicrosoftAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
redirectUrl
,
String
code
)
{
public
static
String
getMicrosoftAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
redirectUrl
,
String
code
)
{
return
MessageFormat
.
format
(
MICROSOFT_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
MICROSOFT
.
accessToken
(),
clientId
,
clientSecret
,
redirectUrl
,
code
);
return
MessageFormat
.
format
(
MICROSOFT_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
MICROSOFT
.
accessToken
(),
clientId
,
clientSecret
,
redirectUrl
,
code
);
}
}
/**
/**
...
@@ -717,7 +721,7 @@ public class UrlBuilder {
...
@@ -717,7 +721,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getMicrosoftUserInfoUrl
()
{
public
static
String
getMicrosoftUserInfoUrl
()
{
return
MessageFormat
.
format
(
MICROSOFT_USER_INFO_PATTERN
,
A
piUrl
.
MICROSOFT
.
userInfo
());
return
MessageFormat
.
format
(
MICROSOFT_USER_INFO_PATTERN
,
A
uthSource
.
MICROSOFT
.
userInfo
());
}
}
/**
/**
...
@@ -730,7 +734,7 @@ public class UrlBuilder {
...
@@ -730,7 +734,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getMicrosoftRefreshUrl
(
String
clientId
,
String
clientSecret
,
String
redirectUrl
,
String
refreshToken
)
{
public
static
String
getMicrosoftRefreshUrl
(
String
clientId
,
String
clientSecret
,
String
redirectUrl
,
String
refreshToken
)
{
return
MessageFormat
.
format
(
MICROSOFT_REFRESH_TOKEN_PATTERN
,
A
piUrl
.
MICROSOFT
.
refresh
(),
clientId
,
clientSecret
,
redirectUrl
,
refreshToken
);
return
MessageFormat
.
format
(
MICROSOFT_REFRESH_TOKEN_PATTERN
,
A
uthSource
.
MICROSOFT
.
refresh
(),
clientId
,
clientSecret
,
redirectUrl
,
refreshToken
);
}
}
/**
/**
...
@@ -741,7 +745,7 @@ public class UrlBuilder {
...
@@ -741,7 +745,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getMiAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getMiAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
MI_AUTHORIZE_PATTERN
,
A
piUrl
.
MI
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
return
MessageFormat
.
format
(
MI_AUTHORIZE_PATTERN
,
A
uthSource
.
MI
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
}
}
/**
/**
...
@@ -754,7 +758,7 @@ public class UrlBuilder {
...
@@ -754,7 +758,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getMiAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
redirectUrl
,
String
code
)
{
public
static
String
getMiAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
redirectUrl
,
String
code
)
{
return
MessageFormat
.
format
(
MI_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
MI
.
accessToken
(),
clientId
,
clientSecret
,
redirectUrl
,
code
);
return
MessageFormat
.
format
(
MI_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
MI
.
accessToken
(),
clientId
,
clientSecret
,
redirectUrl
,
code
);
}
}
/**
/**
...
@@ -765,7 +769,7 @@ public class UrlBuilder {
...
@@ -765,7 +769,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getMiUserInfoUrl
(
String
clientId
,
String
token
)
{
public
static
String
getMiUserInfoUrl
(
String
clientId
,
String
token
)
{
return
MessageFormat
.
format
(
MI_USER_INFO_PATTERN
,
A
piUrl
.
MI
.
userInfo
(),
clientId
,
token
);
return
MessageFormat
.
format
(
MI_USER_INFO_PATTERN
,
A
uthSource
.
MI
.
userInfo
(),
clientId
,
token
);
}
}
/**
/**
...
@@ -778,7 +782,7 @@ public class UrlBuilder {
...
@@ -778,7 +782,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getMiRefreshUrl
(
String
clientId
,
String
clientSecret
,
String
redirectUrl
,
String
refreshToken
)
{
public
static
String
getMiRefreshUrl
(
String
clientId
,
String
clientSecret
,
String
redirectUrl
,
String
refreshToken
)
{
return
MessageFormat
.
format
(
MI_REFRESH_TOKEN_PATTERN
,
A
piUrl
.
MI
.
refresh
(),
clientId
,
clientSecret
,
redirectUrl
,
refreshToken
);
return
MessageFormat
.
format
(
MI_REFRESH_TOKEN_PATTERN
,
A
uthSource
.
MI
.
refresh
(),
clientId
,
clientSecret
,
redirectUrl
,
refreshToken
);
}
}
/**
/**
...
@@ -789,7 +793,8 @@ public class UrlBuilder {
...
@@ -789,7 +793,8 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getToutiaoAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
public
static
String
getToutiaoAuthorizeUrl
(
String
clientId
,
String
redirectUrl
)
{
return
MessageFormat
.
format
(
TOUTIAO_AUTHORIZE_PATTERN
,
ApiUrl
.
TOUTIAO
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
return
MessageFormat
.
format
(
TOUTIAO_AUTHORIZE_PATTERN
,
AuthSource
.
TOUTIAO
.
authorize
(),
clientId
,
redirectUrl
,
System
.
currentTimeMillis
());
}
}
/**
/**
...
@@ -801,7 +806,7 @@ public class UrlBuilder {
...
@@ -801,7 +806,7 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getToutiaoAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
)
{
public
static
String
getToutiaoAccessTokenUrl
(
String
clientId
,
String
clientSecret
,
String
code
)
{
return
MessageFormat
.
format
(
TOUTIAO_ACCESS_TOKEN_PATTERN
,
A
piUrl
.
TOUTIAO
.
accessToken
(),
clientId
,
clientSecret
,
code
);
return
MessageFormat
.
format
(
TOUTIAO_ACCESS_TOKEN_PATTERN
,
A
uthSource
.
TOUTIAO
.
accessToken
(),
clientId
,
clientSecret
,
code
);
}
}
/**
/**
...
@@ -812,6 +817,6 @@ public class UrlBuilder {
...
@@ -812,6 +817,6 @@ public class UrlBuilder {
* @return full url
* @return full url
*/
*/
public
static
String
getToutiaoUserInfoUrl
(
String
clientId
,
String
token
)
{
public
static
String
getToutiaoUserInfoUrl
(
String
clientId
,
String
token
)
{
return
MessageFormat
.
format
(
TOUTIAO_USER_INFO_PATTERN
,
A
piUrl
.
TOUTIAO
.
userInfo
(),
clientId
,
token
);
return
MessageFormat
.
format
(
TOUTIAO_USER_INFO_PATTERN
,
A
uthSource
.
TOUTIAO
.
userInfo
(),
clientId
,
token
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录