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


Java X509CertSelector.setCertificateValid方法代码示例

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


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

示例1: testCertificateValid

import java.security.cert.X509CertSelector; //导入方法依赖的package包/类
private void testCertificateValid() {
    System.out.println("X.509 Certificate Match on certificateValid");
    // bad match
    X509CertSelector selector = new X509CertSelector();
    Calendar cal = Calendar.getInstance();
    cal.set(1968, 12, 31);
    selector.setCertificateValid(cal.getTime());
    checkMatch(selector, cert, false);

    // good match
    selector.setCertificateValid(cert.getNotBefore());
    checkMatch(selector, cert, true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:X509CertSelectorTest.java

示例2: test_getCertificateValid

import java.security.cert.X509CertSelector; //导入方法依赖的package包/类
/**
 * @tests java.security.cert.X509CertSelector#getCertificateValid()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getCertificateValid",
    args = {}
)
public void test_getCertificateValid() {
    Date date1 = new Date(100);
    Date date2 = new Date(200);
    Date date3 = Calendar.getInstance().getTime();
    X509CertSelector selector = new X509CertSelector();

    assertNull("Selector should return null", selector
            .getCertificateValid());
    selector.setCertificateValid(date1);
    assertTrue("The returned date should be equal to specified", date1
            .equals(selector.getCertificateValid()));
    selector.getCertificateValid().setTime(200);
    assertTrue("The returned date should be equal to specified", date1
            .equals(selector.getCertificateValid()));
    assertFalse("The returned date should differ", date2.equals(selector
            .getCertificateValid()));
    selector.setCertificateValid(date3);
    assertTrue("The returned date should be equal to specified", date3
            .equals(selector.getCertificateValid()));
    selector.setCertificateValid(null);
    assertNull(selector.getCertificateValid());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:32,代码来源:X509CertSelectorTest.java

示例3: test_setCertificateValidLjava_util_Date

import java.security.cert.X509CertSelector; //导入方法依赖的package包/类
/**
 * @tests java.security.cert.X509CertSelector#setCertificateValid(java.util.Date)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "setCertificateValid",
    args = {java.util.Date.class}
)
public void test_setCertificateValidLjava_util_Date()
        throws CertificateException {
    X509CertSelector selector = new X509CertSelector();

    Date date1 = new Date(100);
    Date date2 = new Date(200);
    TestCert cert1 = new TestCert(date1);
    TestCert cert2 = new TestCert(date2);

    selector.setCertificateValid(null);
    assertNull(selector.getCertificateValid());
    selector.setCertificateValid(date1);
    assertTrue("The certificate should match the selection criteria.",
            selector.match(cert1));
    assertFalse("The certificate should not match the selection criteria.",
            selector.match(cert2));
    selector.setCertificateValid(date2);
    date2.setTime(300);
    assertTrue("The certificate should match the selection criteria.",
            selector.match(cert2));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:31,代码来源:X509CertSelectorTest.java

示例4: if

import java.security.cert.X509CertSelector; //导入方法依赖的package包/类
private Collection<X509Certificate> getMatchingEECerts
    (ReverseState currentState, List<CertStore> certStores)
    throws CertStoreException, CertificateException, IOException {

    /*
     * Compose a CertSelector to filter out
     * certs which do not satisfy requirements.
     *
     * First, retrieve clone of current target cert constraints, and
     * then add more selection criteria based on current validation state.
     */
    X509CertSelector sel = (X509CertSelector) targetCertConstraints.clone();

    /*
     * Match on issuer (subject of previous cert)
     */
    sel.setIssuer(currentState.subjectDN);

    /*
     * Match on certificate validity date.
     */
    sel.setCertificateValid(buildParams.date());

    /*
     * Policy processing optimizations
     */
    if (currentState.explicitPolicy == 0)
        sel.setPolicy(getMatchingPolicies());

    /*
     * If previous cert has a subject key identifier extension,
     * use it to match on authority key identifier extension.
     */
    /*if (currentState.subjKeyId != null) {
      AuthorityKeyIdentifierExtension authKeyId = new AuthorityKeyIdentifierExtension(
            (KeyIdentifier) currentState.subjKeyId.get(SubjectKeyIdentifierExtension.KEY_ID),
            null, null);
    sel.setAuthorityKeyIdentifier(authKeyId.getExtensionValue());
    }*/

    /*
     * Require EE certs
     */
    sel.setBasicConstraints(-2);

    /* Retrieve matching certs from CertStores */
    HashSet<X509Certificate> eeCerts = new HashSet<>();
    addMatchingCerts(sel, certStores, eeCerts, true);

    if (debug != null) {
        debug.println("ReverseBuilder.getMatchingEECerts got "
                      + eeCerts.size() + " certs.");
    }
    return eeCerts;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:56,代码来源:ReverseBuilder.java

示例5: X509CertSelector

import java.security.cert.X509CertSelector; //导入方法依赖的package包/类
private Collection<X509Certificate> getMatchingCACerts
    (ReverseState currentState, List<CertStore> certStores)
    throws CertificateException, CertStoreException, IOException {

    /*
     * Compose a CertSelector to filter out
     * certs which do not satisfy requirements.
     */
    X509CertSelector sel = new X509CertSelector();

    /*
     * Match on issuer (subject of previous cert)
     */
    sel.setIssuer(currentState.subjectDN);

    /*
     * Match on certificate validity date.
     */
    sel.setCertificateValid(buildParams.date());

    /*
     * Match on target subject name (checks that current cert's
     * name constraints permit it to certify target).
     * (4 is the integer type for DIRECTORY name).
     */
    byte[] subject = targetCertConstraints.getSubjectAsBytes();
    if (subject != null) {
        sel.addPathToName(4, subject);
    } else {
        X509Certificate cert = targetCertConstraints.getCertificate();
        if (cert != null) {
            sel.addPathToName(4,
                              cert.getSubjectX500Principal().getEncoded());
        }
    }

    /*
     * Policy processing optimizations
     */
    if (currentState.explicitPolicy == 0)
        sel.setPolicy(getMatchingPolicies());

    /*
     * If previous cert has a subject key identifier extension,
     * use it to match on authority key identifier extension.
     */
    /*if (currentState.subjKeyId != null) {
      AuthorityKeyIdentifierExtension authKeyId = new AuthorityKeyIdentifierExtension(
            (KeyIdentifier) currentState.subjKeyId.get(SubjectKeyIdentifierExtension.KEY_ID),
                            null, null);
      sel.setAuthorityKeyIdentifier(authKeyId.getExtensionValue());
    }*/

    /*
     * Require CA certs
     */
    sel.setBasicConstraints(0);

    /* Retrieve matching certs from CertStores */
    ArrayList<X509Certificate> reverseCerts = new ArrayList<>();
    addMatchingCerts(sel, certStores, reverseCerts, true);

    /* Sort remaining certs using name constraints */
    Collections.sort(reverseCerts, new PKIXCertComparator());

    if (debug != null)
        debug.println("ReverseBuilder.getMatchingCACerts got " +
                      reverseCerts.size() + " certs.");
    return reverseCerts;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:71,代码来源:ReverseBuilder.java

示例6: if

import java.security.cert.X509CertSelector; //导入方法依赖的package包/类
private Collection<X509Certificate> getMatchingEECerts
    (ReverseState currentState, List<CertStore> certStores)
    throws CertStoreException, CertificateException, IOException {

  /*
   * Compose a CertSelector to filter out
   * certs which do not satisfy requirements.
   *
   * First, retrieve clone of current target cert constraints,
   * and then add more selection criteria based on current validation state.
   */
  X509CertSelector sel = (X509CertSelector) targetCertConstraints.clone();

  /*
   * Match on issuer (subject of previous cert)
   */
  sel.setIssuer(currentState.subjectDN);

  /*
   * Match on certificate validity date.
   */
  sel.setCertificateValid(date);

  /*
   * Policy processing optimizations
   */
  if (currentState.explicitPolicy == 0)
      sel.setPolicy(getMatchingPolicies());

  /*
   * If previous cert has a subject key identifier extension,
   * use it to match on authority key identifier extension.
   */
  /*if (currentState.subjKeyId != null) {
    AuthorityKeyIdentifierExtension authKeyId = new AuthorityKeyIdentifierExtension(
            (KeyIdentifier) currentState.subjKeyId.get(SubjectKeyIdentifierExtension.KEY_ID),
            null, null);
    sel.setAuthorityKeyIdentifier(authKeyId.getExtensionValue());
  }*/

  /*
   * Require EE certs
   */
  sel.setBasicConstraints(-2);

  /* Retrieve matching certs from CertStores */
  HashSet<X509Certificate> eeCerts = new HashSet<X509Certificate>();
  addMatchingCerts(sel, certStores, eeCerts, true);

  if (debug != null) {
    debug.println("ReverseBuilder.getMatchingEECerts got " + eeCerts.size()
                + " certs.");
  }
  return eeCerts;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:56,代码来源:ReverseBuilder.java

示例7: X509CertSelector

import java.security.cert.X509CertSelector; //导入方法依赖的package包/类
private Collection<X509Certificate> getMatchingCACerts
    (ReverseState currentState, List<CertStore> certStores)
    throws CertificateException, CertStoreException, IOException {

  /*
   * Compose a CertSelector to filter out
   * certs which do not satisfy requirements.
   */
  X509CertSelector sel = new X509CertSelector();

  /*
   * Match on issuer (subject of previous cert)
   */
  sel.setIssuer(currentState.subjectDN);

  /*
   * Match on certificate validity date.
   */
  sel.setCertificateValid(date);

  /*
   * Match on target subject name (checks that current cert's
   * name constraints permit it to certify target).
   * (4 is the integer type for DIRECTORY name).
   */
  sel.addPathToName(4, targetCertConstraints.getSubjectAsBytes());

  /*
   * Policy processing optimizations
   */
  if (currentState.explicitPolicy == 0)
      sel.setPolicy(getMatchingPolicies());

  /*
   * If previous cert has a subject key identifier extension,
   * use it to match on authority key identifier extension.
   */
  /*if (currentState.subjKeyId != null) {
    AuthorityKeyIdentifierExtension authKeyId = new AuthorityKeyIdentifierExtension(
            (KeyIdentifier) currentState.subjKeyId.get(SubjectKeyIdentifierExtension.KEY_ID),
                            null, null);
    sel.setAuthorityKeyIdentifier(authKeyId.getExtensionValue());
  }*/

  /*
   * Require CA certs
   */
  sel.setBasicConstraints(0);

  /* Retrieve matching certs from CertStores */
  ArrayList<X509Certificate> reverseCerts =
      new ArrayList<X509Certificate>();
  addMatchingCerts(sel, certStores, reverseCerts, true);

  /* Sort remaining certs using name constraints */
  Collections.sort(reverseCerts, new PKIXCertComparator());

  if (debug != null)
    debug.println("ReverseBuilder.getMatchingCACerts got " +
                reverseCerts.size() + " certs.");
  return reverseCerts;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:63,代码来源:ReverseBuilder.java


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