com.mizhousoft.weixin.certificate.impl.CertificateProviderImpl Maven / Gradle / Ivy
The newest version!
package com.mizhousoft.weixin.certificate.impl;
import java.math.BigInteger;
import java.security.cert.X509Certificate;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import com.mizhousoft.weixin.certificate.CertificateProvider;
/**
* 根据序列号获取证书
*
*/
public class CertificateProviderImpl implements CertificateProvider
{
private final ConcurrentHashMap certificates = new ConcurrentHashMap<>(10);
public CertificateProviderImpl(List certificates)
{
for (X509Certificate item : certificates)
{
this.certificates.put(item.getSerialNumber(), item);
}
}
/**
* {@inheritDoc}
*/
@Override
public X509Certificate getCertificate(String serialNumber)
{
BigInteger key = new BigInteger(serialNumber, 16);
return certificates.get(key);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy