提交 67c668b7 编写于 作者: 智布道's avatar 智布道 👁

authorize方法提到父类中

上级 7fe8a4d4
......@@ -15,7 +15,6 @@ import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.AlipayUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.utils.StringUtils;
/**
......@@ -86,16 +85,4 @@ public class AuthAlipayRequest extends BaseAuthRequest {
.source(AuthSource.ALIPAY)
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
......@@ -10,7 +10,6 @@ import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;
import me.zhyd.oauth.url.BaiduUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthRevokeEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
......@@ -69,18 +68,6 @@ public class AuthBaiduRequest extends BaseAuthRequest {
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
@Override
public AuthResponse revoke(AuthToken authToken) {
String accessToken = authToken.getAccessToken();
......
......@@ -12,7 +12,6 @@ import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.CodingUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
/**
......@@ -73,16 +72,4 @@ public class AuthCodingRequest extends BaseAuthRequest {
.source(AuthSource.CODING)
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
......@@ -12,7 +12,6 @@ import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.CsdnUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
/**
......@@ -63,16 +62,4 @@ public class AuthCsdnRequest extends BaseAuthRequest {
.source(AuthSource.CSDN)
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
......@@ -13,7 +13,6 @@ import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.DingtalkUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
import me.zhyd.oauth.utils.GlobalAuthUtil;
......@@ -69,16 +68,4 @@ public class AuthDingTalkRequest extends BaseAuthRequest {
.token(token)
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
......@@ -9,7 +9,6 @@ import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;
import me.zhyd.oauth.url.DouyinUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthRefreshTokenEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
......@@ -61,18 +60,6 @@ public class AuthDouyinRequest extends BaseAuthRequest {
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
@Override
public AuthResponse refresh(AuthToken oldToken) {
String refreshTokenUrl = this.urlBuilder.getRefreshUrl(AuthRefreshTokenEntity.builder()
......
......@@ -12,7 +12,6 @@ import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.FacebookUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
/**
......@@ -79,16 +78,4 @@ public class AuthFacebookRequest extends BaseAuthRequest {
.source(AuthSource.FACEBOOK)
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
......@@ -12,7 +12,6 @@ import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.GiteeUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
/**
......@@ -65,16 +64,4 @@ public class AuthGiteeRequest extends BaseAuthRequest {
.source(AuthSource.GITEE)
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
......@@ -12,7 +12,6 @@ import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.GithubUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
import me.zhyd.oauth.utils.GlobalAuthUtil;
......@@ -68,16 +67,4 @@ public class AuthGithubRequest extends BaseAuthRequest {
.source(AuthSource.GITHUB)
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
......@@ -12,7 +12,6 @@ import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.GoogleUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
/**
......@@ -71,16 +70,4 @@ public class AuthGoogleRequest extends BaseAuthRequest {
.source(AuthSource.GOOGLE)
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
......@@ -10,7 +10,6 @@ import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;
import me.zhyd.oauth.url.LinkedinUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthRefreshTokenEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
import me.zhyd.oauth.utils.StringUtils;
......@@ -92,18 +91,6 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
private String getUserEmail(String accessToken) {
String email = null;
HttpResponse emailResponse = HttpRequest.get("https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))")
......
......@@ -10,7 +10,6 @@ import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;
import me.zhyd.oauth.url.MiUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthRefreshTokenEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
......@@ -101,18 +100,6 @@ public class AuthMiRequest extends BaseAuthRequest {
return authUser;
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
/**
* 刷新access token (续期)
*
......
......@@ -10,7 +10,6 @@ import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;
import me.zhyd.oauth.url.MicrosoftUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthRefreshTokenEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
......@@ -95,18 +94,6 @@ public class AuthMicrosoftRequest extends BaseAuthRequest {
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
/**
* 刷新access token (续期)
*
......
......@@ -12,7 +12,6 @@ import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.OschinaUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
/**
......@@ -70,16 +69,4 @@ public class AuthOschinaRequest extends BaseAuthRequest {
.source(AuthSource.OSCHINA)
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
......@@ -13,7 +13,6 @@ import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.QqUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
import me.zhyd.oauth.utils.GlobalAuthUtil;
import me.zhyd.oauth.utils.StringUtils;
......@@ -83,18 +82,6 @@ public class AuthQqRequest extends BaseAuthRequest {
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
private String getOpenId(AuthToken authToken) {
String accessToken = authToken.getAccessToken();
HttpResponse response = HttpRequest.get(this.urlBuilder.getOpenIdUrl(accessToken, config.isUnionId())).execute();
......
......@@ -12,7 +12,6 @@ import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.TaobaoUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.utils.GlobalAuthUtil;
/**
......@@ -60,16 +59,4 @@ public class AuthTaobaoRequest extends BaseAuthRequest {
.source(AuthSource.TAOBAO)
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
......@@ -12,7 +12,6 @@ import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.TencentCloudUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
/**
......@@ -72,16 +71,4 @@ public class AuthTencentCloudRequest extends BaseAuthRequest {
.source(AuthSource.TENCENT_CLOUD)
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
......@@ -13,7 +13,6 @@ import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.ToutiaoUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
/**
......@@ -78,16 +77,4 @@ public class AuthToutiaoRequest extends BaseAuthRequest {
.source(AuthSource.TOUTIAO)
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
......@@ -9,7 +9,6 @@ import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;
import me.zhyd.oauth.url.WechatUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthRefreshTokenEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
......@@ -66,18 +65,6 @@ public class AuthWeChatRequest extends BaseAuthRequest {
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
@Override
public AuthResponse refresh(AuthToken oldToken) {
String refreshTokenUrl = this.urlBuilder.getRefreshUrl(AuthRefreshTokenEntity.builder()
......
......@@ -12,7 +12,6 @@ import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.url.WeiboUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAccessTokenEntity;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
import me.zhyd.oauth.utils.IpUtils;
import me.zhyd.oauth.utils.StringUtils;
......@@ -81,16 +80,4 @@ public class AuthWeiboRequest extends BaseAuthRequest {
.source(AuthSource.WEIBO)
.build();
}
/**
* 返回认证url,可自行跳转页面
*
* @return 返回授权地址
*/
@Override
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
......@@ -9,6 +9,7 @@ import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.url.AbstractUrlBuilder;
import me.zhyd.oauth.url.entity.AuthAuthorizeEntity;
import me.zhyd.oauth.utils.AuthChecker;
/**
......@@ -69,5 +70,9 @@ public abstract class BaseAuthRequest implements AuthRequest {
* @return 返回授权地址
*/
@Override
public abstract String authorize();
public String authorize() {
return this.urlBuilder.getAuthorizeUrl(AuthAuthorizeEntity.builder()
.config(config)
.build());
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册