九州仙境 v3.0.0版本的 MD5 值为:7b5ce5daab0f4a38a386ae4309157477
以下内容为反编译后的 RSAAutoCertificateProvider.java 源代码,内容仅作参考
package com.wechat.pay.java.core.certificate;
import com.wechat.pay.java.core.auth.Credential;
import com.wechat.pay.java.core.auth.Validator;
import com.wechat.pay.java.core.auth.WechatPay2Credential;
import com.wechat.pay.java.core.certificate.CertificateDownloader;
import com.wechat.pay.java.core.cipher.AeadAesCipher;
import com.wechat.pay.java.core.cipher.AeadCipher;
import com.wechat.pay.java.core.cipher.RSASigner;
import com.wechat.pay.java.core.http.AbstractHttpClientBuilder;
import com.wechat.pay.java.core.http.DefaultHttpClientBuilder;
import com.wechat.pay.java.core.http.HttpClient;
import com.wechat.pay.java.core.http.HttpHeaders;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.Objects;
public class RSAAutoCertificateProvider implements CertificateProvider {
private static final String ALGORITHM_TYPE = "RSA";
private static final String REQUEST_URL = "https://api.mch.weixin.qq.com/v3/certificates?algorithm_type=RSA";
private static final CertificateHandler rsaCertificateHandler = new RSACertificateHandler();
private final String merchantId;
private RSAAutoCertificateProvider(String str, AeadCipher aeadCipher, HttpClient httpClient) {
this.merchantId = str;
AutoCertificateService.register(str, "RSA", new CertificateDownloader.Builder().certificateHandler(rsaCertificateHandler).downloadUrl(REQUEST_URL).aeadCipher(aeadCipher).httpClient(httpClient).build());
}
@Override
public X509Certificate getCertificate(String str) {
return AutoCertificateService.getCertificate(this.merchantId, "RSA", str);
}
@Override
public X509Certificate getAvailableCertificate() {
return AutoCertificateService.getAvailableCertificate(this.merchantId, "RSA");
}
public static class Builder {
private byte[] apiV3Key;
private Credential credential;
private final Validator emptyValidator = new Validator() {
@Override
public boolean validate(HttpHeaders httpHeaders, String str) {
return true;
}
};
private HttpClient httpClient;
private AbstractHttpClientBuilder<?> httpClientBuilder;
private String merchantId;
private String merchantSerialNumber;
private PrivateKey privateKey;
public Builder merchantId(String str) {
this.merchantId = str;
return this;
}
public Builder apiV3Key(byte[] bArr) {
this.apiV3Key = bArr;
return this;
}
public Builder httpClient(HttpClient httpClient) {
this.httpClient = httpClient;
return this;
}
public Builder credential(Credential credential) {
this.credential = credential;
return this;
}
public Builder privateKey(PrivateKey privateKey) {
this.privateKey = privateKey;
return this;
}
public Builder merchantSerialNumber(String str) {
this.merchantSerialNumber = str;
return this;
}
public Builder httpClientBuilder(AbstractHttpClientBuilder<?> abstractHttpClientBuilder) {
this.httpClientBuilder = abstractHttpClientBuilder.newInstance();
return this;
}
public RSAAutoCertificateProvider build() {
if (this.httpClient == null) {
if (this.httpClientBuilder == null) {
this.httpClientBuilder = new DefaultHttpClientBuilder();
}
if (this.credential == null && this.privateKey != null) {
this.credential = new WechatPay2Credential((String) Objects.requireNonNull(this.merchantId), new RSASigner((String) Objects.requireNonNull(this.merchantSerialNumber), this.privateKey));
}
this.httpClient = this.httpClientBuilder.credential(this.credential).validator(this.emptyValidator).build();
}
return new RSAAutoCertificateProvider(this.merchantId, new AeadAesCipher((byte[]) Objects.requireNonNull(this.apiV3Key)), this.httpClient);
}
}
}