Home  >  Article  >  Database  >  axis2实现HTTPs双向认证的几种方式

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

WBOY
WBOYOriginal
2016-06-07 15:49:371780browse

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;

    }

   

    其他方法空实现....

}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn