1
0
mirror of synced 2026-04-25 11:08:49 +08:00
This commit is contained in:
yadong.zhang
2020-12-20 17:14:06 +08:00
parent dce2bd1e1e
commit e84bd7cdb5
9 changed files with 46 additions and 14 deletions

View File

@@ -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;
}

View File

@@ -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<String, String> 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"));
}

View File

@@ -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;
}

View File

@@ -227,6 +227,7 @@ public class GlobalAuthUtils {
* @param params 加密参数
* @param clientSecret 平台应用的授权key
* @return Signature
* @since 1.15.9
*/
public static String generateXmlySignature(Map<String, String> params, String clientSecret) {
TreeMap<String, String> map = new TreeMap<>(params);