package org.yeshi.utils.alipay;
|
|
|
import com.alipay.api.*;
|
|
import java.security.cert.X509Certificate;
|
import java.util.concurrent.ConcurrentHashMap;
|
|
public class CertAlipayClient extends MyAbstractAlipayClient {
|
private String privateKey;
|
private String encryptKey;
|
private String alipayPublicKey;
|
private Signer signer;
|
private SignChecker signChecker;
|
private Encryptor encryptor;
|
private Decryptor decryptor;
|
private X509Certificate cert;
|
private ConcurrentHashMap<String, X509Certificate> alipayPublicCertMap;
|
|
|
public CertAlipayClient(MyCertAlipayRequest certAlipayRequest) throws AlipayApiException {
|
super(certAlipayRequest.getServerUrl(), certAlipayRequest.getAppId(), certAlipayRequest.getFormat(),
|
certAlipayRequest.getCharset(), certAlipayRequest.getSignType(), certAlipayRequest.getCertStream(),
|
certAlipayRequest.getAlipayPublicCertStream(), certAlipayRequest.getRootCertStream(),
|
certAlipayRequest.getProxyHost(), certAlipayRequest.getProxyPort(), certAlipayRequest.getEncryptType());
|
this.privateKey = certAlipayRequest.getPrivateKey();
|
this.signer = new DefaultSigner(certAlipayRequest.getPrivateKey());
|
this.encryptor = new DefaultEncryptor(certAlipayRequest.getEncryptor());
|
this.decryptor = new DefaultDecryptor(certAlipayRequest.getEncryptor());
|
}
|
|
public Signer getSigner() {
|
return signer;
|
}
|
|
public SignChecker getSignChecker() {
|
return signChecker;
|
}
|
|
public Encryptor getEncryptor() {
|
return encryptor;
|
}
|
|
public Decryptor getDecryptor() {
|
return decryptor;
|
}
|
|
public X509Certificate getCert() {
|
return cert;
|
}
|
|
public ConcurrentHashMap<String, X509Certificate> getAlipayPublicCertMap() {
|
return alipayPublicCertMap;
|
}
|
|
public void setPrivateKey(String privateKey) {
|
this.privateKey = privateKey;
|
if (this.signer == null) {
|
this.signer = new DefaultSigner(privateKey);
|
}
|
}
|
|
public void setEncryptKey(String encryptKey) {
|
this.encryptKey = encryptKey;
|
if (this.encryptor == null) {
|
this.encryptor = new DefaultEncryptor(encryptKey);
|
}
|
if (this.decryptor == null) {
|
this.decryptor = new DefaultDecryptor(encryptKey);
|
}
|
}
|
|
public void setAlipayPublicKey(String alipayPublicKey) {
|
this.alipayPublicKey = alipayPublicKey;
|
if (this.signChecker == null) {
|
this.signChecker = new DefaultSignChecker(alipayPublicKey);
|
}
|
}
|
}
|