From e84bd7cdb580b98503614fd816ccd376f61ab551 Mon Sep 17 00:00:00 2001
From: "yadong.zhang"
Date: Sun, 20 Dec 2020 17:14:06 +0800
Subject: [PATCH] :bookmark: merge #101
---
CHANGELOGS.md | 11 +++++++++++
README.en-US.md | 6 +++---
README.md | 6 +++---
bin/version.txt | 2 +-
pom.xml | 8 ++++++--
src/main/java/me/zhyd/oauth/config/AuthConfig.java | 11 +++++++++--
.../java/me/zhyd/oauth/request/AuthXmlyRequest.java | 9 ++++++---
src/main/java/me/zhyd/oauth/utils/AuthChecker.java | 6 ++++++
.../java/me/zhyd/oauth/utils/GlobalAuthUtils.java | 1 +
9 files changed, 46 insertions(+), 14 deletions(-)
diff --git a/CHANGELOGS.md b/CHANGELOGS.md
index 88161d1..ace41ca 100644
--- a/CHANGELOGS.md
+++ b/CHANGELOGS.md
@@ -1,3 +1,14 @@
+## 1.15.9
+
+### 2020/12/20
+
+- 发布 v1.15.9
+- PR
+ - 合并 [Github#101](https://gitee.com/yadong.zhang/JustAuth/pulls/101)
+- 修改
+ - 修改喜马拉雅配置参数,将`ClientOsType`参数提到 AuthConfig 中
+ - AuthChecker 中增加对喜马拉雅平台的校验
+
## 1.15.8
### 2020/10/25
diff --git a/README.en-US.md b/README.en-US.md
index 087a3c7..4d18425 100644
--- a/README.en-US.md
+++ b/README.en-US.md
@@ -6,7 +6,7 @@
-
+
@@ -15,7 +15,7 @@
-
+
@@ -97,7 +97,7 @@ These artifacts are available from Maven Central:
me.zhyd.oauth
JustAuth
- 1.15.8-beta.2
+ 1.15.9
```
- Using JustAuth
diff --git a/README.md b/README.md
index 95d1ded..aff22d7 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
-
+
@@ -15,7 +15,7 @@
-
+
@@ -107,7 +107,7 @@ JustAuth 集成了诸如:Github、Gitee、支付宝、新浪微博、微信、
me.zhyd.oauth
JustAuth
- 1.15.8
+ 1.15.9
```
- 调用api
diff --git a/bin/version.txt b/bin/version.txt
index 98e863c..30a88ea 100644
--- a/bin/version.txt
+++ b/bin/version.txt
@@ -1 +1 @@
-1.15.8
+1.15.9
diff --git a/pom.xml b/pom.xml
index e7e37cf..c7d7477 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.zhyd.oauth
JustAuth
- 1.15.8
+ 1.15.9
JustAuth
https://gitee.com/yadong.zhang/JustAuth
@@ -52,7 +52,7 @@
1.8
2.2.1
3.8.1
- 3.1.0
+ 2.9.1
2.7
2.20
1.6
@@ -133,6 +133,10 @@
jar
+
+
+ -Xdoclint:none
+
diff --git a/src/main/java/me/zhyd/oauth/config/AuthConfig.java b/src/main/java/me/zhyd/oauth/config/AuthConfig.java
index a153c78..339d6fa 100644
--- a/src/main/java/me/zhyd/oauth/config/AuthConfig.java
+++ b/src/main/java/me/zhyd/oauth/config/AuthConfig.java
@@ -119,9 +119,16 @@ public class AuthConfig {
private String deviceId;
/**
- * 喜马拉雅:客户端包名,如果client_os_type为1或2时必填。对Android客户端是包名,对IOS客户端是Bundle ID
+ * 喜马拉雅:客户端操作系统类型,1-iOS系统,2-Android系统,3-Web
*
- * @since 1.15.8
+ * @since 1.15.9
+ */
+ private Integer clientOsType;
+
+ /**
+ * 喜马拉雅:客户端包名,如果 {@link AuthConfig#clientOsType} 为1或2时必填。对Android客户端是包名,对IOS客户端是Bundle ID
+ *
+ * @since 1.15.9
*/
private String packId;
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthXmlyRequest.java b/src/main/java/me/zhyd/oauth/request/AuthXmlyRequest.java
index 877c77a..9c6e1cf 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthXmlyRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthXmlyRequest.java
@@ -12,14 +12,17 @@ import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.utils.GlobalAuthUtils;
import me.zhyd.oauth.utils.UrlBuilder;
+
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
import java.util.TreeMap;
+
/**
* 喜马拉雅登录
*
* @author zwzch (zwzch4j@gmail.com)
- * @since 1.15.8
+ * @since 1.15.9
*/
public class AuthXmlyRequest extends AuthDefaultRequest {
@@ -89,7 +92,7 @@ public class AuthXmlyRequest extends AuthDefaultRequest {
public AuthUser getUserInfo(AuthToken authToken) {
Map map = new TreeMap<>();
map.put("app_key", config.getClientId());
- map.put("client_os_type", "2");
+ map.put("client_os_type", Optional.ofNullable(config.getClientOsType()).orElse(3).toString());
map.put("device_id", config.getDeviceId());
map.put("pack_id", config.getPackId());
map.put("access_token", authToken.getAccessToken());
@@ -113,7 +116,7 @@ public class AuthXmlyRequest extends AuthDefaultRequest {
*
* @param object 接口返回的结果
*/
- private void checkResponse(JSONObject object){
+ private void checkResponse(JSONObject object) {
if (object.containsKey("errcode")) {
throw new AuthException(object.getIntValue("error_no"), object.getString("error_desc"));
}
diff --git a/src/main/java/me/zhyd/oauth/utils/AuthChecker.java b/src/main/java/me/zhyd/oauth/utils/AuthChecker.java
index 703729e..13a292a 100644
--- a/src/main/java/me/zhyd/oauth/utils/AuthChecker.java
+++ b/src/main/java/me/zhyd/oauth/utils/AuthChecker.java
@@ -38,6 +38,12 @@ public class AuthChecker {
if (isSupported && AuthDefaultSource.CODING == source) {
isSupported = StringUtils.isNotEmpty(config.getCodingGroupName());
}
+ if (isSupported && AuthDefaultSource.XMLY == source) {
+ isSupported = StringUtils.isNotEmpty(config.getDeviceId()) && null != config.getClientOsType();
+ if (isSupported) {
+ isSupported = config.getClientOsType() == 3 || StringUtils.isNotEmpty(config.getPackId());
+ }
+ }
return isSupported;
}
diff --git a/src/main/java/me/zhyd/oauth/utils/GlobalAuthUtils.java b/src/main/java/me/zhyd/oauth/utils/GlobalAuthUtils.java
index f6dbf80..af3c4ca 100644
--- a/src/main/java/me/zhyd/oauth/utils/GlobalAuthUtils.java
+++ b/src/main/java/me/zhyd/oauth/utils/GlobalAuthUtils.java
@@ -227,6 +227,7 @@ public class GlobalAuthUtils {
* @param params 加密参数
* @param clientSecret 平台应用的授权key
* @return Signature
+ * @since 1.15.9
*/
public static String generateXmlySignature(Map params, String clientSecret) {
TreeMap map = new TreeMap<>(params);
--
GitLab