欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

axis2实现HTTPs双向认证的几种方式

程序员文章站 2022-03-23 23:01:21
...

public class CustomizableCrypto implements Crypto { /** * 构造 X509 式证书的工厂变量 */ private CertificateFactory certFact ; /** * 获取构造 X509 式证书的工厂变量(单例模式) * * @return 证书工厂变量 */ public synchronized CertificateFacto

publicclass CustomizableCrypto implements Crypto

{

/**

* 构造X509格式证书的工厂变量

*/

private CertificateFactory certFact;

/**

* 获取构造X509格式证书的工厂变量(单例模式)

*

* @return证书工厂变量

*/

publicsynchronizedCertificateFactory getCertificateFactory()

{

if (certFact == null)

{

try

{

certFact =CertificateFactory.getInstance("X.509");

}

catch(CertificateException e)

{

if (logger.isErrorEnable())

{

logger.error("Fail to get CertificateFactory");

}

}

returncertFact;

}

returncertFact;

}

public PrivateKeygetPrivateKey(String keyName, String passwrod)

{

PEMReader pemIn;

ByteArrayInputStreampemByteIn = new ByteArrayInputStream(getprivatekey(keyName));

pemIn = new PEMReader(newInputStreamReader(pemByteIn));

return ((KeyPair) pemIn.readObject()).getPrivate();

}

public X509Certificate[]getCertificates(String keyName)

{

X509Certificate[] certList= new X509Certificate[1];

// psql中取出证书并转换为X509格式证书

CertificateFactory cf = null;

X509Certificate cert = null;

cf = getCertificateFactory();

ByteArrayInputStream bais =new ByteArrayInputStream(getCertificate(keyName));

cert = (X509Certificate)cf.generateCertificate(bais);

certList[0] = cert;

return certList;

}

其他方法空实现....

}