Merge remote-tracking branch 'origin/dev/dev' into dev/dev
This commit is contained in:
@@ -12,16 +12,16 @@ public class MQConfig {
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-test";
|
||||
// ==================================================================
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-local";
|
||||
public static final String GENERATE_QUEUE = "generate-queue-prod";
|
||||
public static final String GENERATE_QUEUE = "generate-queue-dev";
|
||||
|
||||
// public static final String SR_QUEUE = "SR-queue-local";
|
||||
public static final String SR_QUEUE = "SR-queue-prod";
|
||||
public static final String SR_QUEUE = "SR-queue-dev";
|
||||
|
||||
// public static final String SR_RESULT_QUEUE = "SuperResolution-local";
|
||||
public static final String SR_RESULT_QUEUE = "SuperResolution-prod";
|
||||
public static final String SR_RESULT_QUEUE = "SuperResolution-dev";
|
||||
|
||||
// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-local";
|
||||
public static final String GENERATE_RESULT_QUEUE = "GenerateImage-prod";
|
||||
public static final String GENERATE_RESULT_QUEUE = "GenerateImage-dev";
|
||||
|
||||
public static final String TO_PRODUCT_IMAGE_RESULT_QUEUE = "ToProductImage-local";
|
||||
public MQConfig() {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ai.da.common.constant;
|
||||
|
||||
public class AlipayHKConstant {
|
||||
|
||||
// 服务名
|
||||
public static final String CREATE_ORDER = "create_order";
|
||||
public static final String ORDER_DETAILS = "order_details";
|
||||
public static final String TRANSACTION_DETAILS = "transaction_details";
|
||||
public static final String GET_FILE = "get_file";
|
||||
public static final String CREATE_AUTO_DEBIT = "create_auto_debit";
|
||||
public static final String REFRESH_TRANSACTION_STATUS = "refresh_transaction_status";
|
||||
public static final String REFUND_TRANSACTION = "refund_transaction";
|
||||
|
||||
// 订单状态
|
||||
public static final String STATUS_NEW = "new";
|
||||
public static final String STATUS_WAIT = "wait";
|
||||
public static final String STATUS_PAID = "paid";
|
||||
public static final String STATUS_EXPIRED = "expired";
|
||||
public static final String STATUS_LIQUIDATED = "liquidated";
|
||||
}
|
||||
@@ -19,7 +19,12 @@ public enum PayTypeEnum {
|
||||
/**
|
||||
* PayPal
|
||||
*/
|
||||
PAYPAL("PayPal");
|
||||
PAYPAL("PayPal"),
|
||||
|
||||
/**
|
||||
* 香港支付宝
|
||||
*/
|
||||
ALIPAY_HK("Alipay-HK");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
|
||||
@@ -49,7 +49,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
||||
"/api/third/party/addNoLoginRequiredNew","/api/third/party/deleteNoLoginRequiredNew",
|
||||
"/api/third/party/existNoLoginRequired","/api/third/party/getRedirectUrl",
|
||||
// "/api/python/chatStream",
|
||||
"/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back"
|
||||
"/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify"
|
||||
);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,9 +6,16 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
|
||||
import org.bouncycastle.crypto.digests.SHA256Digest;
|
||||
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
|
||||
import org.bouncycastle.crypto.signers.RSADigestSigner;
|
||||
import org.bouncycastle.crypto.util.PublicKeyFactory;
|
||||
import org.bouncycastle.openssl.PEMParser;
|
||||
import org.bouncycastle.util.io.pem.PemObject;
|
||||
import org.bouncycastle.util.io.pem.PemReader;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
@@ -25,22 +32,24 @@ import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AlipayHKEncryptionUtil {
|
||||
|
||||
@Value("${alipay.hk.merchant-id}")
|
||||
private static String merchantId;
|
||||
@Value("${alipayHK.merchantId}")
|
||||
private String merchantId;
|
||||
|
||||
@Value("${alipay.hk.segment-id}")
|
||||
private static String segmentId;
|
||||
@Value("${alipayHK.segmentId}")
|
||||
private String segmentId;
|
||||
|
||||
@Value("${alipay.hk.AESKey}")
|
||||
private static String aesKey;
|
||||
@Value("${alipayHK.AESKey}")
|
||||
private String aesKey;
|
||||
|
||||
@Value("${alipay.hk.rsaPrivateKey}")
|
||||
private static String privateKeyPath;
|
||||
@Value("${alipayHK.rsaPrivateKey}")
|
||||
private String privateKeyPath;
|
||||
|
||||
@Value("${alipayHK.rsaPublicKey}")
|
||||
private String publicKeyPath;
|
||||
|
||||
@Value("${alipay.hk.rsaPublicKey}")
|
||||
private static String publicKeyPath;
|
||||
|
||||
/**
|
||||
* 加密
|
||||
@@ -55,7 +64,7 @@ public class AlipayHKEncryptionUtil {
|
||||
* @throws BadPaddingException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static AlipayHKRequestDTO AESCBCWithRSA(HashMap<String, Object> param, String serviceName) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException {
|
||||
public AlipayHKRequestDTO AESCBCWithRSA(HashMap<String, Object> param, String serviceName) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException {
|
||||
// Pre-shared secret key, DO NOT hardcode this key
|
||||
String key = aesKey;
|
||||
// The path to the rsa private key file, DO NOT save this key to a publicly accessible location
|
||||
@@ -187,7 +196,7 @@ public class AlipayHKEncryptionUtil {
|
||||
/**
|
||||
* 使用 AES 密钥和随机向量进行解密
|
||||
*/
|
||||
public static String decryptAES(String encryptedText, String iv) throws Exception {
|
||||
public String decryptAES(String encryptedText, String iv) throws Exception {
|
||||
byte[] encryptedBytes = Base64.getDecoder().decode(encryptedText);
|
||||
byte[] ivBytes = Base64.getDecoder().decode(iv);
|
||||
|
||||
@@ -201,7 +210,7 @@ public class AlipayHKEncryptionUtil {
|
||||
return new String(decryptedBytes, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static void test() throws Exception {
|
||||
public void test() throws Exception {
|
||||
// 加密数据
|
||||
AlipayHKParametersDTO requestMessage = new AlipayHKParametersDTO();
|
||||
requestMessage.setService("create_order");
|
||||
@@ -326,4 +335,29 @@ public class AlipayHKEncryptionUtil {
|
||||
random.nextBytes(iv);
|
||||
return iv;
|
||||
}
|
||||
|
||||
public Boolean signatureVerification(String data, String signatureBase64){
|
||||
|
||||
Base64.Decoder decoder = Base64.getDecoder();
|
||||
// Verify key
|
||||
try {
|
||||
// PublicKey publicKey = readPublicKey(new File(publicKeyPath));
|
||||
InputStreamReader isrPub = new InputStreamReader(new FileInputStream(publicKeyPath));
|
||||
PEMParser pemParserPub = new PEMParser(isrPub);
|
||||
SubjectPublicKeyInfo pubInfo = (SubjectPublicKeyInfo) pemParserPub.readObject();
|
||||
AsymmetricKeyParameter pubKey = PublicKeyFactory.createKey(pubInfo);
|
||||
// Verifying
|
||||
RSADigestSigner verifier = new RSADigestSigner(new SHA256Digest());
|
||||
verifier.init(false, pubKey);
|
||||
byte[] signMessageForVerifing = data.getBytes();
|
||||
byte[] signatureBase64ForVerifing = decoder.decode(signatureBase64);
|
||||
verifier.update(signMessageForVerifing, 0, signMessageForVerifing.length);
|
||||
Boolean verifyResult = verifier.verifySignature(signatureBase64ForVerifing);
|
||||
return verifyResult;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,11 +11,13 @@ import java.time.Instant;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AlipayHKRequestUtil {
|
||||
|
||||
public static String createOrder(AlipayHKRequestDTO alipayHKRequestDTO) throws IOException {
|
||||
public String createOrder(AlipayHKRequestDTO alipayHKRequestDTO) throws IOException {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||
@@ -32,22 +34,29 @@ public class AlipayHKRequestUtil {
|
||||
RequestBody body = RequestBody.create(mediaType, jsonString);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
// .url("https://aqs-api.sandbox-codpayment.com")
|
||||
.url("https://aqs-api.sandbox-codpayment.com/v1/service")
|
||||
// .url("https://aqs-api.sandbox-codpayment.com/v1/service")
|
||||
.url("https://aqs-api.codpayment.com/v1/service")
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json;charset=utf-8")
|
||||
.build();
|
||||
Response response = null;
|
||||
Response response;
|
||||
String bodyString;
|
||||
try {
|
||||
// log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(alipayHKRequestDTO, SerializerFeature.WriteMapNullValue));
|
||||
response = client.newCall(request).execute();
|
||||
assert response.body() != null;
|
||||
bodyString = response.body().string();
|
||||
} catch (Exception e) {
|
||||
// log.error("PythonService##generateSketchOrPrint异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||
// throw new BusinessException("generate.interface.error");
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
return response.body().string();
|
||||
JSONObject jsonObject = JSONObject.parseObject(bodyString);
|
||||
boolean success = (boolean) jsonObject.get("success");
|
||||
if (success){
|
||||
return bodyString;
|
||||
} else {
|
||||
String message = jsonObject.get("error_code").toString() + ":" + jsonObject.get("error");
|
||||
log.error("Alipay return message : {}", message);
|
||||
throw new BusinessException("Alipay return message : " + message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user