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


Java BasicReason类代码示例

本文整理汇总了Java中java.security.cert.CertPathValidatorException.BasicReason的典型用法代码示例。如果您正苦于以下问题:Java BasicReason类的具体用法?Java BasicReason怎么用?Java BasicReason使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: checkConstraints

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
private void checkConstraints(Set<CryptoPrimitive> primitives,
        CertConstraintParameters cp) throws CertPathValidatorException {

    X509Certificate cert = cp.getCertificate();
    String algorithm = cert.getSigAlgName();

    // Check signature algorithm is not disabled
    if (!permits(primitives, algorithm, null)) {
        throw new CertPathValidatorException(
                "Algorithm constraints check failed on disabled "+
                        "signature algorithm: " + algorithm,
                null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
    }

    // Check key algorithm is not disabled
    if (!permits(primitives, cert.getPublicKey().getAlgorithm(), null)) {
        throw new CertPathValidatorException(
                "Algorithm constraints check failed on disabled "+
                        "public key algorithm: " + algorithm,
                null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
    }

    // Check the certificate and key constraints
    algorithmConstraints.permits(cp);

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:DisabledAlgorithmConstraints.java

示例2: permits

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
public void permits(CertConstraintParameters cp)
        throws CertPathValidatorException {
    if (debug != null) {
        debug.println("jdkCAConstraints.permits(): " + algorithm);
    }

    // Return false if the chain has a trust anchor in cacerts
    if (cp.isTrustedMatch()) {
        if (nextConstraint != null) {
            nextConstraint.permits(cp);
            return;
        }
        throw new CertPathValidatorException(
                "Algorithm constraints check failed on certificate " +
                        "anchor limits",
                null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:DisabledAlgorithmConstraints.java

示例3: main

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    // MD5 is used in this test case, don't disable MD5 algorithm.
    Security.setProperty(
            "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024");

    CertPath path = generateCertificatePath();
    Set<TrustAnchor> anchors = generateTrustAnchors();
    CertStore crls = generateCertificateStore();

    PKIXParameters params = new PKIXParameters(anchors);

    // add the CRL store
    params.addCertStore(crls);

    // Activate certificate revocation checking
    params.setRevocationEnabled(true);

    // set the validation time
    params.setDate(new Date(109, 5, 1));   // 2009-05-01

    // disable OCSP checker
    Security.setProperty("ocsp.enable", "false");

    // enable CRL checker
    System.setProperty("com.sun.security.enableCRLDP", "true");

    CertPathValidator validator = CertPathValidator.getInstance("PKIX");

    try {
        validator.validate(path, params);
    } catch (CertPathValidatorException cpve) {
        if (cpve.getReason() != BasicReason.REVOKED) {
            throw new Exception(
                "unexpect exception, should be a REVOKED CPVE", cpve);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:CircularCRLOneLevel.java

示例4: getCertificateAlert

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
/**
 * When a failure happens during certificate checking from an
 * {@link X509TrustManager}, determine what TLS alert description to use.
 *
 * @param cexc The exception thrown by the {@link X509TrustManager}
 *
 * @return A byte value corresponding to a TLS alert description number.
 */
private byte getCertificateAlert(CertificateException cexc) {
    // The specific reason for the failure will determine how to
    // set the alert description value
    byte alertDesc = Alerts.alert_certificate_unknown;

    Throwable baseCause = cexc.getCause();
    if (baseCause instanceof CertPathValidatorException) {
        CertPathValidatorException cpve =
                (CertPathValidatorException)baseCause;
        Reason reason = cpve.getReason();
        if (reason == BasicReason.REVOKED) {
            alertDesc = staplingActive ?
                    Alerts.alert_bad_certificate_status_response :
                    Alerts.alert_certificate_revoked;
        } else if (reason == BasicReason.UNDETERMINED_REVOCATION_STATUS) {
            alertDesc = staplingActive ?
                    Alerts.alert_bad_certificate_status_response :
                    Alerts.alert_certificate_unknown;
        }
    }

    return alertDesc;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:ClientHandshaker.java

示例5: permits

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
@Override
public void permits(ConstraintsParameters cp)
        throws CertPathValidatorException {
    if (debug != null) {
        debug.println("jdkCAConstraints.permits(): " + algorithm);
    }

    // Check chain has a trust anchor in cacerts
    if (cp.isTrustedMatch()) {
        if (next(cp)) {
            return;
        }
        throw new CertPathValidatorException(
                "Algorithm constraints check failed on certificate " +
                "anchor limits. " + algorithm + extendedMsg(cp),
                null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:DisabledAlgorithmConstraints.java

示例6: main

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    // MD5 is used in this test case, don't disable MD5 algorithm.
    Security.setProperty(
            "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024");

    CertPath path = generateCertificatePath();
    Set<TrustAnchor> anchors = generateTrustAnchors();
    CertStore crls = generateCertificateStore();

    PKIXParameters params = new PKIXParameters(anchors);

    // add the CRL store
    params.addCertStore(crls);

    // Activate certificate revocation checking
    params.setRevocationEnabled(true);

    // Activate OCSP
    Security.setProperty("ocsp.enable", "true");
    System.setProperty("com.sun.security.enableCRLDP", "true");

    // Ensure that the ocsp.responderURL property is not set.
    if (Security.getProperty("ocsp.responderURL") != null) {
        throw new
            Exception("The ocsp.responderURL property must not be set");
    }

    CertPathValidator validator = CertPathValidator.getInstance("PKIX");

    try {
        validator.validate(path, params);
    } catch (CertPathValidatorException cpve) {
        if (cpve.getReason() != BasicReason.REVOKED) {
            throw new Exception(
                "unexpected exception, should be a REVOKED CPVE", cpve);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:FailoverToCRL.java

示例7: checkClientValidationFailure

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
/**
 * Checks a validation failure to see if it failed for the reason we think
 * it should.  This comes in as an SSLException of some sort, but it
 * encapsulates a ValidatorException which in turn encapsulates the
 * CertPathValidatorException we are interested in.
 *
 * @param e the exception thrown at the top level
 * @param reason the underlying CertPathValidatorException BasicReason
 * we are expecting it to have.
 *
 * @return true if the reason matches up, false otherwise.
 */
static boolean checkClientValidationFailure(Exception e,
        BasicReason reason) {
    boolean result = false;

    if (e instanceof SSLException) {
        Throwable valExc = e.getCause();
        if (valExc instanceof sun.security.validator.ValidatorException) {
            Throwable cause = valExc.getCause();
            if (cause instanceof CertPathValidatorException) {
                CertPathValidatorException cpve =
                        (CertPathValidatorException)cause;
                if (cpve.getReason() == reason) {
                    result = true;
                }
            }
        }
    }
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:HttpsUrlConnClient.java

示例8: permits

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
public void permits(CertConstraintParameters cp)
        throws CertPathValidatorException {
    if (debug != null) {
        debug.println("jdkCAConstraints.permits(): " + algorithm);
    }

    // Check chain has a trust anchor in cacerts
    if (cp.isTrustedMatch()) {
        if (next(cp)) {
            return;
        }
        throw new CertPathValidatorException(
                "Algorithm constraints check failed on certificate " +
                        "anchor limits",
                null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:18,代码来源:DisabledAlgorithmConstraints.java

示例9: permits

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
public void permits(ConstraintsParameters cp)
        throws CertPathValidatorException {
    if (debug != null) {
        debug.println("jdkCAConstraints.permits(): " + algorithm);
    }

    // Check chain has a trust anchor in cacerts
    if (cp.isTrustedMatch()) {
        if (next(cp)) {
            return;
        }
        throw new CertPathValidatorException(
                "Algorithm constraints check failed on certificate " +
                "anchor limits. " + algorithm + extendedMsg(cp),
                null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
    }
}
 
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:18,代码来源:DisabledAlgorithmConstraints.java

示例10: check

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
/**
 * Check the signature algorithm with the specified public key.
 *
 * @param key the public key to verify the CRL signature
 * @param crl the target CRL
 */
static void check(PublicKey key, AlgorithmId algorithmId)
                    throws CertPathValidatorException {
    String sigAlgName = algorithmId.getName();
    AlgorithmParameters sigAlgParams = algorithmId.getParameters();

    if (!certPathDefaultConstraints.permits(
            SIGNATURE_PRIMITIVE_SET, sigAlgName, key, sigAlgParams)) {
        throw new CertPathValidatorException(
            "algorithm check failed: " + sigAlgName + " is disabled",
            null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:AlgorithmChecker.java

示例11: isSoftFailException

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
private boolean isSoftFailException(CertPathValidatorException e) {
    if (softFail &&
        e.getReason() == BasicReason.UNDETERMINED_REVOCATION_STATUS)
    {
        // recreate exception with correct index
        CertPathValidatorException e2 = new CertPathValidatorException(
            e.getMessage(), e.getCause(), params.certPath(), certIndex,
            e.getReason());
        softFailExceptions.addFirst(e2);
        return true;
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:RevocationChecker.java

示例12: verifyWithSeparateSigningKey

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
/**
 * We have a cert whose revocation status couldn't be verified by
 * a CRL issued by the cert that issued the CRL. See if we can
 * find a valid CRL issued by a separate key that can verify the
 * revocation status of this certificate.
 * <p>
 * Note that this does not provide support for indirect CRLs,
 * only CRLs signed with a different key (but the same issuer
 * name) as the certificate being checked.
 *
 * @param currCert the <code>X509Certificate</code> to be checked
 * @param prevKey the <code>PublicKey</code> that failed
 * @param signFlag <code>true</code> if that key was trusted to sign CRLs
 * @param stackedCerts a <code>Set</code> of <code>X509Certificate</code>s>
 *                     whose revocation status depends on the
 *                     non-revoked status of this cert. To avoid
 *                     circular dependencies, we assume they're
 *                     revoked while checking the revocation
 *                     status of this cert.
 * @throws CertPathValidatorException if the cert's revocation status
 *         cannot be verified successfully with another key
 */
private void verifyWithSeparateSigningKey(X509Certificate cert,
                                          PublicKey prevKey,
                                          boolean signFlag,
                                          Set<X509Certificate> stackedCerts)
    throws CertPathValidatorException
{
    String msg = "revocation status";
    if (debug != null) {
        debug.println(
            "RevocationChecker.verifyWithSeparateSigningKey()" +
            " ---checking " + msg + "...");
    }

    // reject circular dependencies - RFC 3280 is not explicit on how
    // to handle this, so we feel it is safest to reject them until
    // the issue is resolved in the PKIX WG.
    if ((stackedCerts != null) && stackedCerts.contains(cert)) {
        if (debug != null) {
            debug.println(
                "RevocationChecker.verifyWithSeparateSigningKey()" +
                " circular dependency");
        }
        throw new CertPathValidatorException
            ("Could not determine revocation status", null, null, -1,
             BasicReason.UNDETERMINED_REVOCATION_STATUS);
    }

    // Try to find another key that might be able to sign
    // CRLs vouching for this cert.
    // If prevKey wasn't trusted, maybe we just didn't have the right
    // path to it. Don't rule that key out.
    if (!signFlag) {
        buildToNewKey(cert, null, stackedCerts);
    } else {
        buildToNewKey(cert, prevKey, stackedCerts);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:60,代码来源:RevocationChecker.java

示例13: check

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
/**
 * Check the signature algorithm with the specified public key.
 *
 * @param key the public key to verify the CRL signature
 * @param crl the target CRL
 */
static void check(PublicKey key, AlgorithmId algorithmId)
                    throws CertPathValidatorException {
    String sigAlgName = algorithmId.getName();
    AlgorithmParameters sigAlgParams = algorithmId.getParameters();

    if (!certPathDefaultConstraints.permits(
            SIGNATURE_PRIMITIVE_SET, sigAlgName, key, sigAlgParams)) {
        throw new CertPathValidatorException(
            "Algorithm constraints check failed on signature algorithm: " +
            sigAlgName + " is disabled",
            null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:AlgorithmChecker.java

示例14: main

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    // MD5 is used in this test case, don't disable MD5 algorithm.
    Security.setProperty(
            "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024");

    CertPath path = generateCertificatePath();
    Set<TrustAnchor> anchors = generateTrustAnchors();
    CertStore crls = generateCertificateStore();

    PKIXParameters params = new PKIXParameters(anchors);

    // add the CRL store
    params.addCertStore(crls);

    // Activate certificate revocation checking
    params.setRevocationEnabled(true);

    // set the validation time
    params.setDate(new Date(109, 5, 1));   // 2009-05-01

    // disable OCSP checker
    Security.setProperty("ocsp.enable", "false");

    // enable CRL checker
    System.setProperty("com.sun.security.enableCRLDP", "true");

    CertPathValidator validator = CertPathValidator.getInstance("PKIX");

    try {
        validator.validate(path, params);
        throw new Exception("unexpected status, should be REVOKED");
    } catch (CertPathValidatorException cpve) {
        if (cpve.getReason() != BasicReason.REVOKED) {
            throw new Exception(
                "unexpected exception, should be a REVOKED CPVE", cpve);
        }
    }

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:40,代码来源:CircularCRLOneLevelRevoked.java

示例15: main

import java.security.cert.CertPathValidatorException.BasicReason; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    // MD5 is used in this test case, don't disable MD5 algorithm.
    Security.setProperty(
            "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024");

    CertPath path = generateCertificatePath();
    Set<TrustAnchor> anchors = generateTrustAnchors();
    CertStore crls = generateCertificateStore();

    PKIXParameters params = new PKIXParameters(anchors);

    // add the CRL store
    params.addCertStore(crls);

    // Activate certificate revocation checking
    params.setRevocationEnabled(true);

    // set the validation time
    params.setDate(new Date(109, 5, 1));   // 2009-05-01

    // disable OCSP checker
    Security.setProperty("ocsp.enable", "false");

    // enable CRL checker
    System.setProperty("com.sun.security.enableCRLDP", "true");

    CertPathValidator validator = CertPathValidator.getInstance("PKIX");

    try {
        validator.validate(path, params);
        throw new Exception("unexpected status, should be REVOKED");
    } catch (CertPathValidatorException cpve) {
        if (cpve.getReason() != BasicReason.REVOKED) {
            throw new Exception(
                "unexpect exception, should be a REVOKED CPVE", cpve);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:39,代码来源:CircularCRLTwoLevelRevoked.java


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