当前位置: 首页>>代码示例>>Java>>正文


Java X509CertificateStructure.getSubjectPublicKeyInfo方法代码示例

本文整理汇总了Java中org.bouncycastle.asn1.x509.X509CertificateStructure.getSubjectPublicKeyInfo方法的典型用法代码示例。如果您正苦于以下问题:Java X509CertificateStructure.getSubjectPublicKeyInfo方法的具体用法?Java X509CertificateStructure.getSubjectPublicKeyInfo怎么用?Java X509CertificateStructure.getSubjectPublicKeyInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.asn1.x509.X509CertificateStructure的用法示例。


在下文中一共展示了X509CertificateStructure.getSubjectPublicKeyInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processServerCertificate

import org.bouncycastle.asn1.x509.X509CertificateStructure; //导入方法依赖的package包/类
public void processServerCertificate(Certificate serverCertificate) throws IOException
{
    X509CertificateStructure x509Cert = serverCertificate.certs[0];
    SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();

    try
    {
        this.serverPublicKey = PublicKeyFactory.createKey(keyInfo);
    }
    catch (RuntimeException e)
    {
        handler.failWithError(TlsProtocolHandler.AL_fatal,
            TlsProtocolHandler.AP_unsupported_certificate);
    }

    // Sanity check the PublicKeyFactory
    if (this.serverPublicKey.isPrivate())
    {
        handler.failWithError(TlsProtocolHandler.AL_fatal, TlsProtocolHandler.AP_internal_error);
    }

    // TODO 
    /*
     * Perform various checks per RFC2246 7.4.2: "Unless otherwise specified, the
     * signing algorithm for the certificate must be the same as the algorithm for the
     * certificate key."
     */

    // TODO Should the 'instanceof' tests be replaces with stricter checks on keyInfo.getAlgorithmId()?

    if (!(this.serverPublicKey instanceof RSAKeyParameters))
    {
        handler.failWithError(TlsProtocolHandler.AL_fatal,
            TlsProtocolHandler.AP_certificate_unknown);
    }
    validateKeyUsage(x509Cert, KeyUsage.keyEncipherment);
    this.rsaServerPublicKey = validateRSAPublicKey((RSAKeyParameters)this.serverPublicKey);

    /*
     * Verify them.
     */
    if (!this.verifyer.isValid(serverCertificate.getCerts()))
    {
        handler.failWithError(TlsProtocolHandler.AL_fatal, TlsProtocolHandler.AP_user_canceled);
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:47,代码来源:TlsRSAKeyExchange.java

示例2: processServerCertificate

import org.bouncycastle.asn1.x509.X509CertificateStructure; //导入方法依赖的package包/类
public void processServerCertificate(Certificate serverCertificate) throws IOException
    {
        X509CertificateStructure x509Cert = serverCertificate.certs[0];
        SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();

        try
        {
            this.serverPublicKey = PublicKeyFactory.createKey(keyInfo);
        }
        catch (RuntimeException e)
        {
            handler.failWithError(TlsProtocolHandler.AL_fatal,
                TlsProtocolHandler.AP_unsupported_certificate);
        }

        // Sanity check the PublicKeyFactory
        if (this.serverPublicKey.isPrivate())
        {
            handler.failWithError(TlsProtocolHandler.AL_fatal, TlsProtocolHandler.AP_internal_error);
        }

        // TODO 
        /*
         * Perform various checks per RFC2246 7.4.2: "Unless otherwise specified, the
         * signing algorithm for the certificate must be the same as the algorithm for the
         * certificate key."
         */

        // TODO Should the 'instanceof' tests be replaces with stricter checks on keyInfo.getAlgorithmId()?

        switch (this.keyExchange)
        {
            case TlsKeyExchange.KE_DH_DSS:
                if (!(this.serverPublicKey instanceof DHPublicKeyParameters))
                {
                    handler.failWithError(TlsProtocolHandler.AL_fatal,
                        TlsProtocolHandler.AP_certificate_unknown);
                }
                // TODO The algorithm used to sign the certificate should be DSS.
//                x509Cert.getSignatureAlgorithm();
                this.dhAgreeServerPublicKey = validateDHPublicKey((DHPublicKeyParameters)this.serverPublicKey);
                break;
            case TlsKeyExchange.KE_DH_RSA:
                if (!(this.serverPublicKey instanceof DHPublicKeyParameters))
                {
                    handler.failWithError(TlsProtocolHandler.AL_fatal,
                        TlsProtocolHandler.AP_certificate_unknown);
                }
                // TODO The algorithm used to sign the certificate should be RSA.
//              x509Cert.getSignatureAlgorithm();
                this.dhAgreeServerPublicKey = validateDHPublicKey((DHPublicKeyParameters)this.serverPublicKey);
                break;
            case TlsKeyExchange.KE_DHE_RSA:
                if (!(this.serverPublicKey instanceof RSAKeyParameters))
                {
                    handler.failWithError(TlsProtocolHandler.AL_fatal,
                        TlsProtocolHandler.AP_certificate_unknown);
                }
                validateKeyUsage(x509Cert, KeyUsage.digitalSignature);
                break;
            case TlsKeyExchange.KE_DHE_DSS:
                if (!(this.serverPublicKey instanceof DSAPublicKeyParameters))
                {
                    handler.failWithError(TlsProtocolHandler.AL_fatal,
                        TlsProtocolHandler.AP_certificate_unknown);
                }
                break;
            default:
                handler.failWithError(TlsProtocolHandler.AL_fatal,
                    TlsProtocolHandler.AP_unsupported_certificate);
        }

        /*
         * Verify them.
         */
        if (!this.verifyer.isValid(serverCertificate.getCerts()))
        {
            handler.failWithError(TlsProtocolHandler.AL_fatal, TlsProtocolHandler.AP_user_canceled);
        }
    }
 
开发者ID:coova,项目名称:jradius,代码行数:81,代码来源:TlsDHKeyExchange.java

示例3: processServerCertificate

import org.bouncycastle.asn1.x509.X509CertificateStructure; //导入方法依赖的package包/类
public void processServerCertificate(Certificate serverCertificate) throws IOException
{
    if (tlsSigner == null)
    {
        handler.failWithError(TlsProtocolHandler.AL_fatal,
            TlsProtocolHandler.AP_unexpected_message);
    }

    X509CertificateStructure x509Cert = serverCertificate.certs[0];
    SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();

    try
    {
        this.serverPublicKey = PublicKeyFactory.createKey(keyInfo);
    }
    catch (RuntimeException e)
    {
        handler.failWithError(TlsProtocolHandler.AL_fatal,
            TlsProtocolHandler.AP_unsupported_certificate);
    }

    // Sanity check the PublicKeyFactory
    if (this.serverPublicKey.isPrivate())
    {
        handler.failWithError(TlsProtocolHandler.AL_fatal, TlsProtocolHandler.AP_internal_error);
    }

    // TODO 
    /*
     * Perform various checks per RFC2246 7.4.2: "Unless otherwise specified, the
     * signing algorithm for the certificate must be the same as the algorithm for the
     * certificate key."
     */
    switch (this.keyExchange)
    {
        case TlsKeyExchange.KE_SRP_RSA:
            if (!(this.serverPublicKey instanceof RSAKeyParameters))
            {
                handler.failWithError(TlsProtocolHandler.AL_fatal,
                    TlsProtocolHandler.AP_certificate_unknown);
            }
            validateKeyUsage(x509Cert, KeyUsage.digitalSignature);
            break;
        case TlsKeyExchange.KE_SRP_DSS:
            if (!(this.serverPublicKey instanceof DSAPublicKeyParameters))
            {
                handler.failWithError(TlsProtocolHandler.AL_fatal,
                    TlsProtocolHandler.AP_certificate_unknown);
            }
            break;
        default:
            handler.failWithError(TlsProtocolHandler.AL_fatal,
                TlsProtocolHandler.AP_unsupported_certificate);
    }

    /*
     * Verify them.
     */
    if (!this.verifyer.isValid(serverCertificate.getCerts()))
    {
        handler.failWithError(TlsProtocolHandler.AL_fatal, TlsProtocolHandler.AP_user_canceled);
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:64,代码来源:TlsSRPKeyExchange.java


注:本文中的org.bouncycastle.asn1.x509.X509CertificateStructure.getSubjectPublicKeyInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。