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


Java X509CRL类代码示例

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


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

示例1: CRLDistributionPointRevocationCheckerTests

import java.security.cert.X509CRL; //导入依赖的package包/类
/**
 * Creates a new test instance with given parameters.
 *
 * @param checker Revocation checker instance.
 * @param expiredCRLPolicy Policy instance for handling expired CRL data.
 * @param certFiles File names of certificates to check.
 * @param crlFile File name of CRL file to serve out.
 * @param expected Expected result of check; null to indicate expected success.
 */
public CRLDistributionPointRevocationCheckerTests(
        final CRLDistributionPointRevocationChecker checker,
        final RevocationPolicy<X509CRL> expiredCRLPolicy,
        final String[] certFiles,
        final String crlFile,
        final GeneralSecurityException expected) throws Exception {

    super(certFiles, expected);

    final File file = new File(System.getProperty("java.io.tmpdir"), "ca.crl");
    if (file.exists()) {
        file.delete();
    }
    final OutputStream out = new FileOutputStream(file);
    IOUtils.copy(new ClassPathResource(crlFile).getInputStream(), out);

    this.checker = checker;
    this.checker.setExpiredCRLPolicy(expiredCRLPolicy);
    this.webServer = new MockWebServer(8085, new FileSystemResource(file), "text/plain");
    logger.debug("Web server listening on port 8085 serving file {}", crlFile);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:31,代码来源:CRLDistributionPointRevocationCheckerTests.java

示例2: addCRL

import java.security.cert.X509CRL; //导入依赖的package包/类
@Override
protected boolean addCRL(final Object id, final X509CRL crl) {
    try {
        if (crl == null) {
            logger.debug("No CRL was passed. Removing {} from cache...", id);
            return this.crlCache.remove(id);
        }

        this.crlCache.put(new Element(id, crl.getEncoded()));
        return this.crlCache.get(id) != null;

    } catch (final Exception e) {
        logger.warn("Failed to add the crl entry [{}] to the cache", crl);
        throw new RuntimeException(e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:CRLDistributionPointRevocationChecker.java

示例3: getIssuerX509Principal

import java.security.cert.X509CRL; //导入依赖的package包/类
/**
 * return the issuer of the given CRL as an X509PrincipalObject.
 */
public static X509Principal getIssuerX509Principal(
	X509CRL crl)
	throws CRLException
{
	try
	{
		ByteArrayInputStream    bIn = new ByteArrayInputStream(
			crl.getTBSCertList());
		ASN1InputStream         aIn = new ASN1InputStream(bIn);
		TBSCertList tbsCertList = new TBSCertList(
										(ASN1Sequence)aIn.readObject());

		return new X509Principal(tbsCertList.getIssuer());
	}
	catch (IOException e)
	{
		throw new CRLException(e.toString());
	}
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:23,代码来源:PrincipalUtil.java

示例4: CRLDistributionPointRevocationCheckerTests

import java.security.cert.X509CRL; //导入依赖的package包/类
/**
 * Creates a new test instance with given parameters.
 *
 * @param checker Revocation checker instance.
 * @param expiredCRLPolicy Policy instance for handling expired CRL data.
 * @param certFiles File names of certificates to check.
 * @param crlFile File name of CRL file to serve out.
 * @param expected Expected result of check; null to indicate expected success.
 */
public CRLDistributionPointRevocationCheckerTests(
        final CRLDistributionPointRevocationChecker checker,
        final RevocationPolicy<X509CRL> expiredCRLPolicy,
        final String[] certFiles,
        final String crlFile,
        final GeneralSecurityException expected) throws Exception {

    super(certFiles, expected);

    final File file = new File(System.getProperty("java.io.tmpdir"), "ca.crl");
    if (file.exists()) {
        file.delete();
    }
    final OutputStream out = new FileOutputStream(file);
    IOUtils.copy(new ClassPathResource(crlFile).getInputStream(), out);

    this.checker = checker;
    this.checker.setExpiredCRLPolicy(expiredCRLPolicy);
    this.checker.init();
    this.webServer = new MockWebServer(8085, new FileSystemResource(file), "text/plain");
    logger.debug("Web server listening on port 8085 serving file {}", crlFile);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:32,代码来源:CRLDistributionPointRevocationCheckerTests.java

示例5: ResourceCRLRevocationCheckerTests

import java.security.cert.X509CRL; //导入依赖的package包/类
/**
 * Creates a new test instance with given parameters.
 *
 * @param checker Revocation checker instance.
 * @param expiredCRLPolicy Policy instance for handling expired CRL data.
 * @param certFiles File names of certificates to check.
 * @param expected Expected result of check; null to indicate expected success.
 */
public ResourceCRLRevocationCheckerTests(
        final ResourceCRLRevocationChecker checker,
        final RevocationPolicy<X509CRL> expiredCRLPolicy,
        final String[] certFiles,
        final GeneralSecurityException expected) {

    super(certFiles, expected);

    this.checker = checker;
    this.checker.setExpiredCRLPolicy(expiredCRLPolicy);
    try {
        this.checker.init();
    } catch (final Exception e) {
        throw new RuntimeException("ResourceCRLRevocationChecker initialization failed", e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:25,代码来源:ResourceCRLRevocationCheckerTests.java

示例6: printCRL

import java.security.cert.X509CRL; //导入依赖的package包/类
private void printCRL(CRL crl, PrintStream out)
        throws Exception {
    X509CRL xcrl = (X509CRL)crl;
    if (rfc) {
        out.println("-----BEGIN X509 CRL-----");
        out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(xcrl.getEncoded()));
        out.println("-----END X509 CRL-----");
    } else {
        String s;
        if (crl instanceof X509CRLImpl) {
            X509CRLImpl x509crl = (X509CRLImpl) crl;
            s = x509crl.toStringWithAlgName(withWeak("" + x509crl.getSigAlgId()));
        } else {
            s = crl.toString();
        }
        out.println(s);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Main.java

示例7: fetch

import java.security.cert.X509CRL; //导入依赖的package包/类
@Override
public X509CRL fetch(final Object crl) throws Exception {
    final Set<X509CRL> results = fetch(Collections.singleton(crl));
    if (!results.isEmpty()) {
        return results.iterator().next();
    }
    logger.warn("Unable to fetch {}", crl);
    return null;
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:10,代码来源:ResourceCRLFetcher.java

示例8: apply

import java.security.cert.X509CRL; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * The CRL next update time is compared against the current time with the threshold
 * applied and rejected if and only if the next update time is in the past.
 *
 * @param crl CRL instance to evaluate.
 *
 * @throws GeneralSecurityException On expired CRL data. Check the exception type for exact details
 *
 * @see org.jasig.cas.adaptors.x509.authentication.handler.support.RevocationPolicy#apply(java.lang.Object)
 */
@Override
public void apply(final X509CRL crl) throws GeneralSecurityException {
    final Calendar cutoff = Calendar.getInstance();
    if (CertUtils.isExpired(crl, cutoff.getTime())) {
        cutoff.add(Calendar.SECOND, -this.threshold);
        if (CertUtils.isExpired(crl, cutoff.getTime())) {
            throw new ExpiredCRLException(crl.toString(), cutoff.getTime(), this.threshold);
        }
        logger.info(String.format("CRL expired on %s but is within threshold period, %s seconds.",
                    crl.getNextUpdate(), this.threshold));
    }
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:24,代码来源:ThresholdExpiredCRLRevocationPolicy.java

示例9: ThresholdExpiredCRLRevocationPolicyTests

import java.security.cert.X509CRL; //导入依赖的package包/类
/**
 * Creates a new test instance with given parameters.
 *
 * @param policy Policy to test.
 * @param crl CRL instance to apply policy to.
 * @param expected Expected result of policy application; null to indicate expected success.
 */
public ThresholdExpiredCRLRevocationPolicyTests(
        final ThresholdExpiredCRLRevocationPolicy policy,
        final X509CRL crl,
        final GeneralSecurityException expected) {

    this.policy = policy;
    this.expected = expected;
    this.crl = crl;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:ThresholdExpiredCRLRevocationPolicyTests.java

示例10: ResourceCRLRevocationCheckerTests

import java.security.cert.X509CRL; //导入依赖的package包/类
/**
 * Creates a new test instance with given parameters.
 *
 * @param checker Revocation checker instance.
 * @param expiredCRLPolicy Policy instance for handling expired CRL data.
 * @param certFiles File names of certificates to check.
 * @param expected Expected result of check; null to indicate expected success.
 */
public ResourceCRLRevocationCheckerTests(
        final ResourceCRLRevocationChecker checker,
        final RevocationPolicy<X509CRL> expiredCRLPolicy,
        final String[] certFiles,
        final GeneralSecurityException expected) {

    super(certFiles, expected);

    this.checker = checker;
    this.checker.setExpiredCRLPolicy(expiredCRLPolicy);
    try {
        this.checker.afterPropertiesSet();
    } catch (final Exception e) {
        throw new RuntimeException("ResourceCRLRevocationChecker initialization failed", e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:25,代码来源:ResourceCRLRevocationCheckerTests.java

示例11: addCRL

import java.security.cert.X509CRL; //导入依赖的package包/类
@Override
protected boolean addCRL(final Object id, final X509CRL crl) {
    try {
        if (crl == null) {
            LOGGER.debug("No CRL was passed. Removing [{}] from cache...", id);
            return this.crlCache.remove(id);
        }

        this.crlCache.put(new Element(id, crl.getEncoded()));
        return this.crlCache.get(id) != null;

    } catch (final Exception e) {
        LOGGER.warn("Failed to add the crl entry [{}] to the cache", crl);
        throw Throwables.propagate(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:17,代码来源:CRLDistributionPointRevocationChecker.java

示例12: readCRL

import java.security.cert.X509CRL; //导入依赖的package包/类
/**
 * Reads in a X509CRL.
 *
 * @return the X509Certificate
 * @throws IOException if an I/O error occured
 */
private X509CRL readCRL(
    String  endMarker)
    throws IOException
{
    ByteArrayInputStream    bIn = new ByteArrayInputStream(readBytes(endMarker));

    try
    {
        CertificateFactory certFact
                = CertificateFactory.getInstance("X.509", provider);

        return (X509CRL)certFact.generateCRL(bIn);
    }
    catch (Exception e)
    {
        throw new IOException("problem parsing cert: " + e.toString());
    }
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:25,代码来源:PEMReader.java

示例13: getIssuerX500Principal

import java.security.cert.X509CRL; //导入依赖的package包/类
/**
 * Extract the issuer X500Principal from an X509CRL. Parses the encoded
 * form of the CRL to preserve the principal's ASN.1 encoding.
 *
 * Called by java.security.cert.X509CRL.getIssuerX500Principal().
 */
public static X500Principal getIssuerX500Principal(X509CRL crl) {
    try {
        byte[] encoded = crl.getEncoded();
        DerInputStream derIn = new DerInputStream(encoded);
        DerValue tbsCert = derIn.getSequence(3)[0];
        DerInputStream tbsIn = tbsCert.data;

        DerValue tmp;
        // skip version number if present
        byte nextByte = (byte)tbsIn.peekByte();
        if (nextByte == DerValue.tag_Integer) {
            tmp = tbsIn.getDerValue();
        }

        tmp = tbsIn.getDerValue();  // skip signature
        tmp = tbsIn.getDerValue();  // issuer
        byte[] principalBytes = tmp.toByteArray();
        return new X500Principal(principalBytes);
    } catch (Exception e) {
        throw new RuntimeException("Could not parse issuer", e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:X509CRLImpl.java

示例14: test_create_signature_x509_crt_crl

import java.security.cert.X509CRL; //导入依赖的package包/类
static void test_create_signature_x509_crt_crl() throws Exception {
    System.out.println("* Generating signature-x509-crt-crl.xml");
    List<Object> xds = new ArrayList<>();
    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    xds.add(signingCert);
    FileInputStream fis = new FileInputStream(CRL);
    X509CRL crl = (X509CRL) cf.generateCRL(fis);
    fis.close();
    xds.add(crl);
    KeyInfo crt_crl = kifac.newKeyInfo(Collections.singletonList
        (kifac.newX509Data(xds)));

    test_create_signature_external(dsaSha1, crt_crl, signingKey,
        new X509KeySelector(ks), false);
    System.out.println();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:GenerationTests.java

示例15: addCRL

import java.security.cert.X509CRL; //导入依赖的package包/类
/**
 * Add the CRLEntry objects contained in a previous CRL.
 * 
 * @param other the X509CRL to source the other entries from. 
 */
public void addCRL(X509CRL other)
    throws CRLException
{
    Set revocations = other.getRevokedCertificates();

    if (revocations != null)
    {
        Iterator it = revocations.iterator();
        while (it.hasNext())
        {
            X509CRLEntry entry = (X509CRLEntry)it.next();

            ASN1InputStream aIn = new ASN1InputStream(entry.getEncoded());

            try
            {
                tbsGen.addCRLEntry(ASN1Sequence.getInstance(aIn.readObject()));
            }
            catch (IOException e)
            {
                throw new CRLException("exception processing encoding of CRL: " + e.toString());
            }
        }
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:31,代码来源:X509V2CRLGenerator.java


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