Commit bfb54064 by ping.wu

Merge branches 'feature/20220112_银行周周惠_wuping' and 'qa' of…

Merge branches 'feature/20220112_银行周周惠_wuping' and 'qa' of http://gitlab.freemud.com/order-group-application/order-group into qa
parents c1109ac2 e69c769c
......@@ -45,8 +45,4 @@ public class HMacSHA256 {
return hs.toString().toLowerCase();
}
String buildMessage(String apply_mchid, String sign_mchid, String store_id) {
return "apply_mchid="+apply_mchid+"&sign_mchid="+sign_mchid+"&store_id="+store_id;
}
}
package cn.freemud.utils;
//import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
//import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier;
//import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
//import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials;
//import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator;
//import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.junit.After;
import org.junit.Before;
import javax.crypto.Cipher;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.*;
import java.security.interfaces.RSAPrivateKey;
......@@ -26,9 +15,6 @@ import java.security.spec.X509EncodedKeySpec;
import java.util.HashMap;
import java.util.Map;
//import java.security.Signature;
//import java.util.Base64;
public class RSAUtils {
public static final String CHARSET = "UTF-8";
......@@ -200,87 +186,6 @@ public class RSAUtils {
return resultDatas;
}
// String privateKey = "";
//
// String mchId = "";
//
// String mchSerialNo = "";
//
// String apiV3Key = "";
//
// CloseableHttpClient httpClient;
//
// @Before
// public void setup() throws IOException {
// // 加载商户私钥(privateKey:私钥字符串)
// PrivateKey merchantPrivateKey = PemUtil
// .loadPrivateKey(new ByteArrayInputStream(privateKey.getBytes("utf-8")));
//
// // 加载平台证书(mchId:商户号,mchSerialNo:商户证书序列号,apiV3Key:V3密钥)
// AutoUpdateCertificatesVerifier verifier = new AutoUpdateCertificatesVerifier(
// new WechatPay2Credentials(mchId, new PrivateKeySigner(mchSerialNo, merchantPrivateKey)),apiV3Key.getBytes("utf-8"));
//
// // 初始化httpClient
// CloseableHttpClient httpClient = WechatPayHttpClientBuilder.create()
// .withMerchant(mchId, mchSerialNo, merchantPrivateKey)
// .withValidator(new WechatPay2Validator(verifier)).build();
// }
//
// @After
// public void after() throws IOException {
// httpClient.close();
// }
//
//
//
// String url = "https://api.mch.weixin.qq.com/v3/certificates";
//
// // Authorization: <schema> <token>
//// GET - getToken("GET", httpurl, "")
//// POST - getToken("POST", httpurl, json)
// String schema = "WECHATPAY2-SHA256-RSA2048";
// HttpUrl httpurl = HttpUrl.parse(url);
//
// String getToken(String method, HttpUrl url, String body) throws UnsupportedEncodingException, SignatureException, NoSuchAlgorithmException, InvalidKeyException {
// String nonceStr = "your nonce string";
// String yourMerchantId = "your nonce string";
// String yourCertificateSerialNo = "your nonce string";
//
// long timestamp = System.currentTimeMillis() / 1000;
// String message = buildMessage(method, url, timestamp, nonceStr, body);
// String signature = sign(message.getBytes("utf-8"));
//
// return "mchid=\"" + yourMerchantId + "\","
// + "nonce_str=\"" + nonceStr + "\","
// + "timestamp=\"" + timestamp + "\","
// + "serial_no=\"" + yourCertificateSerialNo + "\","
// + "signature=\"" + signature + "\"";
// }
//
// String sign(byte[] message) throws NoSuchAlgorithmException, SignatureException, UnsupportedEncodingException, InvalidKeyException {
// PrivateKey yourPrivateKey = PemUtil
// .loadPrivateKey(new ByteArrayInputStream(privateKey.getBytes("utf-8")));
//
// Signature sign = Signature.getInstance("SHA256withRSA");
// sign.initSign(yourPrivateKey);
// sign.update(message);
//
// return java.util.Base64.getEncoder().encodeToString(sign.sign());
//
//
// }
//
// String buildMessage(String method, HttpUrl url, long timestamp, String nonceStr, String body) {
// String canonicalUrl = url.encodedPath();
// if (url.encodedQuery() != null) {
// canonicalUrl += "?" + url.encodedQuery();
// }
//
// return method + "\n"
// + canonicalUrl + "\n"
// + timestamp + "\n"
// + nonceStr + "\n"
// + body + "\n";
// }
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment