阿里jar包引用的内容比较简单都出来

dev_unify
qiuyt 3 months ago
parent 9d8c5ce902
commit 671789bd23

@ -393,13 +393,13 @@
<artifactId>easyexcel</artifactId>
<version>2.2.10</version>
</dependency>
<dependency>
<groupId>com.anthony</groupId>
<artifactId>alicode</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${pom.basedir}/src/main/resources/lib/alicode-1.0.jar</systemPath>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.anthony</groupId>-->
<!-- <artifactId>alicode</artifactId>-->
<!-- <version>1.0</version>-->
<!-- <scope>system</scope>-->
<!-- <systemPath>${pom.basedir}/src/main/resources/lib/alicode-1.0.jar</systemPath>-->
<!-- </dependency>-->
<!-- javassist -->
<dependency>
<groupId>org.javassist</groupId>

@ -0,0 +1,66 @@
package com.glxp.api.constant;
public class AliConstants {
public static final String APP_KEY = "app_key";
public static final String FORMAT = "format";
public static final String METHOD = "method";
public static final String TIMESTAMP = "timestamp";
public static final String VERSION = "v";
public static final String SIGN = "sign";
public static final String SIGN_METHOD = "sign_method";
public static final String PARTNER_ID = "partner_id";
public static final String SESSION = "session";
public static final String SIMPLIFY = "simplify";
public static final String TARGET_APP_KEY = "target_app_key";
public static final String ERROR_RESPONSE = "error_response";
public static final String ERROR_CODE = "code";
public static final String ERROR_MSG = "msg";
public static final String ERROR_SUB_CODE = "sub_code";
public static final String ERROR_SUB_MSG = "sub_msg";
public static final String QIMEN_CLOUD_ERROR_RESPONSE = "response";
public static final String QM_ROOT_TAG = "request";
public static final String QM_CUSTOMER_ID = "customerId";
public static final String QM_CONTENT_TYPE = "text/xml;charset=utf-8";
public static final String QM_CONTENT_TYPE_JSON = "application/json;charset=utf-8";
public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
public static final String DATE_TIMEZONE = "GMT+8";
public static final String CHARSET_UTF8 = "UTF-8";
public static final String METHOD_POST = "POST";
public static final String METHOD_GET = "GET";
public static final String CTYPE_FORM_DATA = "application/x-www-form-urlencoded";
public static final String CTYPE_FILE_UPLOAD = "multipart/form-data";
public static final String CTYPE_TEXT_XML = "text/xml";
public static final String CTYPE_APPLICATION_XML = "application/xml";
public static final String CTYPE_TEXT_PLAIN = "text/plain";
public static final String CTYPE_APP_JSON = "application/json";
public static final String CHARSET_GBK = "GBK";
public static final String FORMAT_JSON = "json";
public static final String FORMAT_XML = "xml";
public static final String FORMAT_JSON2 = "json2";
public static final String FORMAT_XML2 = "xml2";
public static final String SIGN_METHOD_MD5 = "md5";
public static final String SIGN_METHOD_HMAC = "hmac";
public static final String SIGN_METHOD_HMAC_SHA256 = "hmac-sha256";
public static final String SDK_VERSION = "top-sdk-java-20201231";
public static final String SDK_VERSION_CLUSTER = "top-sdk-java-cluster-20201231";
public static final String SDK_VERSION_HTTPDNS = "top-sdk-java-httpdns-20201231";
public static final String QIMEN_SDK_VERSION_HTTPDNS = "top-qimen-sdk-java-httpdns";
public static final String ACCEPT_ENCODING = "Accept-Encoding";
public static final String CONTENT_ENCODING = "Content-Encoding";
public static final String CONTENT_ENCODING_GZIP = "gzip";
public static final String MIME_TYPE_DEFAULT = "application/octet-stream";
public static final int READ_BUFFER_SIZE = 4096;
public static final String TOP_HTTP_DNS_HOST = "TOP_HTTP_DNS_HOST";
public static final String CONTENT_TYPE_XML = "xml";
public static final String CONTENT_TYPE_JSON = "json";
public static final String CONTENT_TYPE_FORM = "form";
public static final String RESPONSE_TYPE_TOP = "top";
public static final String RESPONSE_TYPE_QIMEN = "qimen1";
public static final String RESPONSE_TYPE_QIMEN2 = "qimen2";
public static final String RESPONSE_TYPE_DINGTALK_OAPI = "dingtalk";
public static final String CALL_TYPE_TOP = "top";
public static final String CALL_TYPE_OAPI = "oapi";
public AliConstants() {
}
}

@ -9,10 +9,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.glxp.api.entity.collect.RelCodeBatch;
import com.glxp.api.entity.collect.RelCodeDetail;
import com.glxp.api.util.udi.FilterUdiUtils;
import com.taobao.api.TaobaoObject;
import com.taobao.api.internal.mapping.ApiField;
import com.taobao.api.internal.mapping.ApiListField;
import com.taobao.api.response.AlibabaAlihealthDrugtraceTopLsydQueryRelationResponse;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@ -5,6 +5,7 @@ import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.AliConstants;
import com.glxp.api.entity.thrsys.ThirdAliDrug;
import com.glxp.api.entity.alihealth.AliKytSearchbill;
import com.glxp.api.req.alihealth.AlihealthKytCommonParametersReqeust;
@ -20,7 +21,6 @@ import com.glxp.api.res.alihealth.AlihealthKytSinglerelationResponse;
import com.glxp.api.service.auth.CustomerInfoService;
import com.glxp.api.service.collect.RelCodeBatchService;
import com.glxp.api.service.collect.RelCodeDetailService;
import com.taobao.api.Constants;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@ -39,7 +39,7 @@ import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.*;
import static com.taobao.api.internal.util.TaobaoUtils.byte2hex;
//import static com.taobao.api.internal.util.TaobaoUtils.byte2hex;
@Slf4j
@Component
@ -311,7 +311,7 @@ public class AlihealthUtils {
// 第二步:把所有参数名和参数值串在一起
StringBuilder query = new StringBuilder();
if (Constants.SIGN_METHOD_MD5.equals(signMethod)) { //签名的摘要算法可选值为hmacmd5hmac-sha256
if (AliConstants.SIGN_METHOD_MD5.equals(signMethod)) { //签名的摘要算法可选值为hmacmd5hmac-sha256
query.append(secret);
}
for (String key : keys) {
@ -332,7 +332,7 @@ public class AlihealthUtils {
// 第三步使用MD5/HMAC加密
byte[] bytes;
if (Constants.SIGN_METHOD_HMAC.equals(signMethod)) {
if (AliConstants.SIGN_METHOD_HMAC.equals(signMethod)) {
bytes = encryptHMAC(query.toString(), secret);
} else {
query.append(secret);
@ -342,14 +342,27 @@ public class AlihealthUtils {
// 第四步:把二进制转化为大写的十六进制(正确签名应该为32大写字符串此方法需要时使用)
return byte2hex(bytes);
}
public static String byte2hex(byte[] bytes) {
StringBuilder sign = new StringBuilder();
for(int i = 0; i < bytes.length; ++i) {
String hex = Integer.toHexString(bytes[i] & 255);
if (hex.length() == 1) {
sign.append("0");
}
sign.append(hex.toUpperCase());
}
return sign.toString();
}
public byte[] encryptHMAC(String data, String secret) throws IOException {
byte[] bytes = null;
try {
SecretKey secretKey = new SecretKeySpec(secret.getBytes(Constants.CHARSET_UTF8), "HmacMD5");
SecretKey secretKey = new SecretKeySpec(secret.getBytes(AliConstants.CHARSET_UTF8), "HmacMD5");
Mac mac = Mac.getInstance(secretKey.getAlgorithm());
mac.init(secretKey);
bytes = mac.doFinal(data.getBytes(Constants.CHARSET_UTF8));
bytes = mac.doFinal(data.getBytes(AliConstants.CHARSET_UTF8));
} catch (GeneralSecurityException gse) {
throw new IOException(gse.toString());
}
@ -357,7 +370,7 @@ public class AlihealthUtils {
}
public byte[] encryptMD5(String data) throws IOException {
return encryptMD5(data.getBytes(Constants.CHARSET_UTF8));
return encryptMD5(data.getBytes(AliConstants.CHARSET_UTF8));
}
public byte[] encryptMD5(byte[] data) throws IOException {

Loading…
Cancel
Save