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


Java PKIXParameters类代码示例

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


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

示例1: X509TrustManagerWrapper

import java.security.cert.PKIXParameters; //导入依赖的package包/类
public X509TrustManagerWrapper(X509TrustManager tm, boolean verifyServerCertificate) throws CertificateException {
    this.origTm = tm;
    this.verifyServerCert = verifyServerCertificate;

    if (verifyServerCertificate) {
        try {
            Set<TrustAnchor> anch = new HashSet<TrustAnchor>();
            for (X509Certificate cert : tm.getAcceptedIssuers()) {
                anch.add(new TrustAnchor(cert, null));
            }
            this.validatorParams = new PKIXParameters(anch);
            this.validatorParams.setRevocationEnabled(false);
            this.validator = CertPathValidator.getInstance("PKIX");
            this.certFactory = CertificateFactory.getInstance("X.509");
        } catch (Exception e) {
            throw new CertificateException(e);
        }
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:20,代码来源:ExportControlled.java

示例2: validateNoCache

import java.security.cert.PKIXParameters; //导入依赖的package包/类
private void validateNoCache(List<? extends X509Certificate> certs)
    throws SignatureException {
  try {
    CertPathValidator validator = CertPathValidator.getInstance(
        VALIDATOR_TYPE);
    PKIXParameters params = new PKIXParameters(trustRoots);
    params.addCertPathChecker(WAVE_OID_CHECKER);
    params.setDate(timeSource.now());

    // turn off default revocation-checking mechanism
    params.setRevocationEnabled(false);

    // TODO: add a way for clients to add certificate revocation checks,
    // perhaps by letting them pass in PKIXCertPathCheckers. This can also be
    // useful to check for Wave-specific certificate extensions.

    CertificateFactory certFactory = CertificateFactory.getInstance(
        CERTIFICATE_TYPE);
    CertPath certPath = certFactory.generateCertPath(certs);
    validator.validate(certPath, params);
  } catch (GeneralSecurityException e) {
    throw new SignatureException("Certificate validation failure", e);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:25,代码来源:CachedCertPathValidator.java

示例3: getInstance

import java.security.cert.PKIXParameters; //导入依赖的package包/类
/**
 * Returns an instance with the parameters of a given
 * <code>PKIXParameters</code> object.
 * 
 * @param pkixParams The given <code>PKIXParameters</code>
 * @return an extended PKIX params object
 */
public static ExtendedPKIXParameters getInstance(PKIXParameters pkixParams)
{
    ExtendedPKIXParameters params;
    try
    {
        params = new ExtendedPKIXParameters(pkixParams.getTrustAnchors());
    }
    catch (Exception e)
    {
        // cannot happen
        throw new RuntimeException(e.getMessage());
    }
    params.setParams(pkixParams);
    return params;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:23,代码来源:ExtendedPKIXParameters.java

示例4: getInstance

import java.security.cert.PKIXParameters; //导入依赖的package包/类
/**
 * Returns an instance of <code>ExtendedPKIXParameters</code> which can be
 * safely casted to <code>ExtendedPKIXBuilderParameters</code>.
 * <p>
 * This method can be used to get a copy from other
 * <code>PKIXBuilderParameters</code>, <code>PKIXParameters</code>,
 * and <code>ExtendedPKIXParameters</code> instances.
 * 
 * @param pkixParams The PKIX parameters to create a copy of.
 * @return An <code>ExtendedPKIXBuilderParameters</code> instance.
 */
public static ExtendedPKIXParameters getInstance(PKIXParameters pkixParams)
{
    ExtendedPKIXBuilderParameters params;
    try
    {
        params = new ExtendedPKIXBuilderParameters(pkixParams
                .getTrustAnchors(), X509CertStoreSelector
                .getInstance((X509CertSelector) pkixParams
                        .getTargetCertConstraints()));
    }
    catch (Exception e)
    {
        // cannot happen
        throw new RuntimeException(e.getMessage());
    }
    params.setParams(pkixParams);
    return params;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:30,代码来源:ExtendedPKIXBuilderParameters.java

示例5: findCRLs

import java.security.cert.PKIXParameters; //导入依赖的package包/类
public Set findCRLs(X509CRLStoreSelector crlselect, PKIXParameters paramsPKIX)
    throws AnnotatedException
{
    Set completeSet = new HashSet();

    // get complete CRL(s)
    try
    {
        completeSet.addAll(findCRLs(crlselect, paramsPKIX.getCertStores()));
    }
    catch (AnnotatedException e)
    {
        throw new AnnotatedException("Exception obtaining complete CRLs.", e);
    }

    return completeSet;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:PKIXCRLUtil.java

示例6: createPath

import java.security.cert.PKIXParameters; //导入依赖的package包/类
public static void createPath(String[] certs) throws Exception {
    TrustAnchor anchor = new TrustAnchor(getCertFromFile(certs[0]), null);
    List list = new ArrayList();
    for (int i = 1; i < certs.length; i++) {
        list.add(0, getCertFromFile(certs[i]));
    }
    CertificateFactory cf = CertificateFactory.getInstance("X509");
    path = cf.generateCertPath(list);

    Set anchors = Collections.singleton(anchor);
    params = new PKIXParameters(anchors);
    params.setRevocationEnabled(false);
    X509CertSelector sel = new X509CertSelector();
    sel.setSerialNumber(new BigInteger("1427"));
    params.setTargetCertConstraints(sel);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:ValidateTargetConstraints.java

示例7: createPath

import java.security.cert.PKIXParameters; //导入依赖的package包/类
public static void createPath(String[] certs) throws Exception {

        X509Certificate anchorCert = getCertFromFile(certs[0]);
        byte [] nameConstraints = anchorCert.getExtensionValue("2.5.29.30");
        if (nameConstraints != null) {
            DerInputStream in = new DerInputStream(nameConstraints);
            nameConstraints = in.getOctetString();
        }
        TrustAnchor anchor = new TrustAnchor(anchorCert, nameConstraints);
        List list = new ArrayList();
        for (int i = 1; i < certs.length; i++) {
            list.add(0, getCertFromFile(certs[i]));
        }
        CertificateFactory cf = CertificateFactory.getInstance("X509");
        path = cf.generateCertPath(list);

        anchors = Collections.singleton(anchor);
        params = new PKIXParameters(anchors);
        params.setRevocationEnabled(false);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:ValidateNC.java

示例8: runTest

import java.security.cert.PKIXParameters; //导入依赖的package包/类
private static void runTest(CertificateFactory cf,
        List<X509Certificate> certList, TrustAnchor anchor)
        throws Exception {
    CertPath path = cf.generateCertPath(certList);
    CertPathValidator validator = CertPathValidator.getInstance("PKIX");

    System.out.println(anchor);

    // Attach the OCSP responses to a PKIXParameters object
    PKIXRevocationChecker pkrev =
            (PKIXRevocationChecker)validator.getRevocationChecker();
    Map<X509Certificate, byte[]> responseMap = new HashMap<>();
    responseMap.put(certList.get(0), DECODER.decode(EE_OCSP_RESP));
    responseMap.put(certList.get(1), DECODER.decode(INT_CA_OCSP_RESP));
    pkrev.setOcspResponses(responseMap);
    PKIXParameters params =
            new PKIXParameters(Collections.singleton(anchor));
    params.addCertPathChecker(pkrev);
    params.setDate(EVAL_DATE);

    validator.validate(path, params);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:ValWithAnchorByName.java

示例9: checkServerTrusted

import java.security.cert.PKIXParameters; //导入依赖的package包/类
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
    try {
        this.mOriginalX509TrustManager.checkServerTrusted(chain, authType);
    } catch (CertificateException e1) {
        try {
            X509Certificate[] ex = this.reorderCertificateChain(chain);
            CertPathValidator validator = CertPathValidator.getInstance("PKIX");
            CertificateFactory factory = CertificateFactory.getInstance("X509");
            CertPath certPath = factory.generateCertPath(Arrays.asList(ex));
            PKIXParameters params = new PKIXParameters(this.mTrustStore);
            params.setRevocationEnabled(false);
            validator.validate(certPath, params);
        } catch (Exception e) {
            throw e1;
        }
    }

}
 
开发者ID:pinguo-sunjianfei,项目名称:Android-Application-ZJB,代码行数:19,代码来源:GenericX509TrustManager.java

示例10: createPKIXParms

import java.security.cert.PKIXParameters; //导入依赖的package包/类
private PKIXParameters createPKIXParms(
		Collection<X509Certificate> trustAnchorColl, Date dtDate)
		throws InvalidAlgorithmParameterException {
	// TODO Auto-generated method stub
	Set tmpTA = new HashSet();
	Iterator<X509Certificate> itLast = trustAnchorColl.iterator();
	while (itLast.hasNext()) {
		X509Certificate certOnPath = itLast.next();
		TrustAnchor trustAnchor = new TrustAnchor(certOnPath, null);
		tmpTA.add(trustAnchor);
	}

	PKIXParameters params = new PKIXParameters(tmpTA);
	params.setDate(dtDate);
	return params;

}
 
开发者ID:bluecrystalsign,项目名称:signer-source,代码行数:18,代码来源:CertificateService.java

示例11: validate

import java.security.cert.PKIXParameters; //导入依赖的package包/类
public RuleCheckResult validate(CACCertAuthParamParser pp) {
    CertPath cp = getCertPath(pp);
    if (cp == null) {
        logger.printToConsole("Can't load user certificate, please check " + pp.getUserCert());
        return RuleCheckResult.FALSE;
    }

    // Load the root CA certificate
    Set<TrustAnchor> trustedCerts = getTrustedCerts(pp);
    if (trustedCerts == null) {
        logger.printToConsole("Can't parse the trusted CA certificates, please check " + pp.getRootCerts());
        return RuleCheckResult.FALSE;
    }

    PKIXParameters params = initPKIXParams(trustedCerts, new ArrayList(), pp);
    RuleCheckResult result = validate(cp, params);

    return result;
}
 
开发者ID:lizwjiang,项目名称:cgv,代码行数:20,代码来源:DisableCRLRule.java

示例12: TrustManagerImpl

import java.security.cert.PKIXParameters; //导入依赖的package包/类
/**
 * Creates trust manager implementation
 *
 * @param ks
 */
public TrustManagerImpl(KeyStore ks) {
    try {
        validator = CertPathValidator.getInstance("PKIX");
        factory = CertificateFactory.getInstance("X509");
        byte[] nameConstrains = null;
        Set<TrustAnchor> trusted = new HashSet<TrustAnchor>();
        for (Enumeration<String> en = ks.aliases(); en.hasMoreElements();) {
            final String alias = en.nextElement();
            final X509Certificate cert = (X509Certificate) ks.getCertificate(alias);
            if (cert != null) {
                trusted.add(new TrustAnchor(cert, nameConstrains));
            }
        }
        params = new PKIXParameters(trusted);
        params.setRevocationEnabled(false);
    } catch (Exception e) {
        err = e;
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:25,代码来源:TrustManagerImpl.java

示例13: testPKIXBuilderParametersSetCertSelector01

import java.security.cert.PKIXParameters; //导入依赖的package包/类
/**
 * Test #1 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
 * constructor<br>
 * Assertion: creates an instance of <code>PKIXBuilderParameters</code>
 * @throws InvalidAlgorithmParameterException
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies positive case.",
    method = "PKIXBuilderParameters",
    args = {java.util.Set.class, java.security.cert.CertSelector.class}
)
public final void testPKIXBuilderParametersSetCertSelector01()
    throws InvalidAlgorithmParameterException {
    Set<TrustAnchor> taSet = TestUtils.getTrustAnchorSet();
    if (taSet == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor set)");
    }
    // both parameters are valid and non-null
    PKIXParameters p =
        new PKIXBuilderParameters(taSet, new X509CertSelector());
    assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
    assertNotNull("certSelector", p.getTargetCertConstraints());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:25,代码来源:PKIXBuilderParametersTest.java

示例14: testPKIXBuilderParametersSetCertSelector02

import java.security.cert.PKIXParameters; //导入依赖的package包/类
/**
 * Test #2 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
 * constructor<br>
 * Assertion: creates an instance of <code>PKIXBuilderParameters</code>
 * @throws InvalidAlgorithmParameterException
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies null as a CertSelector parameter.",
    method = "PKIXBuilderParameters",
    args = {java.util.Set.class, java.security.cert.CertSelector.class}
)
public final void testPKIXBuilderParametersSetCertSelector02()
    throws InvalidAlgorithmParameterException {
    Set<TrustAnchor> taSet = TestUtils.getTrustAnchorSet();
    if (taSet == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor set)");
    }
    // both parameters are valid but CertSelector is null
    PKIXParameters p = new PKIXBuilderParameters(taSet, null);
    assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
    assertNull("certSelector", p.getTargetCertConstraints());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:24,代码来源:PKIXBuilderParametersTest.java

示例15: getInstance

import java.security.cert.PKIXParameters; //导入依赖的package包/类
public static CertFilesTrustManager getInstance(String pathToCertsFiles) throws Exception {
	certificateFactory = CertificateFactory.getInstance("X.509");
	Set<TrustAnchor> trustAnchors = new HashSet<TrustAnchor>();

	File[] files = new File(pathToCertsFiles).listFiles();

	for (File file : files) {
		if (!file.isFile()) {
			continue;
		}
		try {
			X509Certificate cert = loadCertificate(file);
			TrustAnchor ta = new TrustAnchor(cert, null);
			trustAnchors.add(ta);
		} catch (CertificateParsingException e) {}
	}

	CertPathValidator val = CertPathValidator.getInstance(CertPathValidator.getDefaultType());

	PKIXParameters cpp = new PKIXParameters(trustAnchors);
	cpp.setRevocationEnabled(false);
	CertFilesTrustManager tm = new CertFilesTrustManager(val, cpp);
	return tm;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:25,代码来源:CertFilesTrustManager.java


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