| | |
| | | package com.ruoyi.shop.util; |
| | | |
| | | import cn.hutool.http.HttpResponse; |
| | | import com.ruoyi.common.core.utils.uuid.IdUtils; |
| | | import com.wechat.pay.contrib.apache.httpclient.util.PemUtil; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.io.FileInputStream; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.security.KeyFactory; |
| | | import java.security.PrivateKey; |
| | | import java.security.PublicKey; |
| | | import java.security.Signature; |
| | | import java.security.cert.Certificate; |
| | | import java.security.cert.CertificateFactory; |
| | | import java.security.spec.PKCS8EncodedKeySpec; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @date 2020-03-18 11:02 |
| | |
| | | * @param mchPrivateKeyPath 电商平台商户API私钥 |
| | | * @return |
| | | */ |
| | | public static String authorization(String method,String urlSuffix,String mchId,String serialNo,String body,String mchPrivateKeyPath) { |
| | | /*public static String authorization(String method,String urlSuffix,String mchId,String serialNo,String body,String mchPrivateKeyPath) { |
| | | try { |
| | | String mchPrivateKey = CertificateUtils.getPrivateKey(mchPrivateKeyPath); |
| | | //时间戳 |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | *//** |
| | | * Authorization 签名串 |
| | | * @param method |
| | | * @param urlSuffix |
| | |
| | | * @param nonceStr |
| | | * @param body |
| | | * @return |
| | | */ |
| | | *//* |
| | | private static StringBuilder signMessage(String method,String urlSuffix,String timestamp,String nonceStr,String body) { |
| | | return new StringBuilder() |
| | | .append(method) |
| | |
| | | .append("\n"); |
| | | } |
| | | |
| | | /** |
| | | *//** |
| | | * 私钥签名 |
| | | * @param data 需要加密的数据 |
| | | * @param mchPriKey |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | *//* |
| | | public static byte[] v3signRSA(String data, String mchPriKey) throws Exception { |
| | | //签名的类型 |
| | | Signature sign = Signature.getInstance("SHA256withRSA"); |
| | |
| | | logger.info("v3VerifyRSA result:{}","签名验证失败"); |
| | | } |
| | | return result; |
| | | } |
| | | }*/ |
| | | } |