Java 8 X509CRL - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 X509CRL class.

This code example shows how to use the following methods:getIssuerDN, getNextUpdate, getThisUpdate
 
    protected void checkCRLDateValidity(X509CRL crl)
            throws CertPathValidatorException { 
 
        Date now = new Date();
        boolean valid = crl.getThisUpdate().before(now) && ((crl.getNextUpdate() != null)
                && (crl.getNextUpdate().after(now)));
        if (!valid) {
            throw new CertPathValidatorException("CRL issued by " + crl.getIssuerDN() + " has expired");
        } 
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:isRevoked, verify
            X509Certificate userCert2 = (X509Certificate)cf.generateCertificate(new ByteArrayInputStream(userCert2Bin));
            X509CRL crl = (X509CRL)cf.generateCRL(new ByteArrayInputStream(crlBin));
            rootCert.verify(rootCert.getPublicKey(), "BC");
            userCert1.verify(rootCert.getPublicKey(), "BC");
 
            crl.verify(rootCert.getPublicKey(), "BC");
 
            if (!crl.isRevoked(userCert1))
            { 
                return new SimpleTestResult(false, this.getName() + ": usercert1 not revoked.");
            } 
 
            if (crl.isRevoked(userCert2))
            { 
                return new SimpleTestResult(false, this.getName() + ": usercert2 revoked.");
            } 
 
        } 
        catch (Exception e)
        { 
6
CodeRank
This code example shows how to use the following methods:isRevoked, getIssuerX500Principal, getNextUpdate, getThisUpdate
	 */ 
	public boolean verify(X509CRL crl, X509Certificate signCert, X509Certificate issuerCert, Date signDate) throws GeneralSecurityException {
		if (crl == null || signDate == null)
			return false; 
		// We only check CRLs valid on the signing date for which the issuer matches 
		if (crl.getIssuerX500Principal().equals(signCert.getIssuerX500Principal())
			&& signDate.after(crl.getThisUpdate()) && signDate.before(crl.getNextUpdate())) {
			// the signing certificate may not be revoked 
			if (isSignatureValid(crl, issuerCert) && crl.isRevoked(signCert)) {
				throw new VerificationException(signCert, "The certificate has been revoked.");
			} 
			return true; 
		} 
		return false; 
	} 
	 
	/** 
	 * Fetches a CRL for a specific certificate online (without further checking). 
	 * @param signCert	the certificate 
	 * @param issuerCert	its issuer 
5
CodeRank
This code example shows how to use the following methods:getIssuerDN, getNextUpdate, getThisUpdate
 
 
	public void setCRL(X509CRL crl) {
		clearCRL(); 
		this.crl = crl;
		this.getIssuer().setText(crl.getIssuerDN().getName());
		this.getIssued().setText(crl.getThisUpdate().toString());
		this.getNextUpdate().setText(crl.getNextUpdate().toString());
		((CRLTable) getCrlTable()).addCRL(crl);
	} 
 
 
	public X509CRL getCRL() {
		return this.crl;
	} 
 
 
	/** 
	 * This method initializes jScrollPane 
	 *  
5
CodeRank
This code example shows how to use the following methods:getEncoded
     * @throws CRLException if there is a problem extracting the CRL information. 
     */ 
    public JcaX509CRLHolder(X509CRL crl)
        throws CRLException 
    { 
        super(CertificateList.getInstance(crl.getEncoded()));
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getIssuerDN, getNextUpdate, getThisUpdate
 
    protected void checkCRLDateValidity(X509CRL crl)
            throws CertPathValidatorException {
 
        Date now = new Date();
        boolean valid = crl.getThisUpdate().before(now) && ((crl.getNextUpdate() != null)
                && (crl.getNextUpdate().after(now)));
        if (!valid) {
            throw new CertPathValidatorException("CRL issued by " + crl.getIssuerDN() + " has expired");
        } 
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:getTBSCertList
        throws CRLException 
    { 
        try 
        { 
            TBSCertList tbsCertList = TBSCertList.getInstance(
                ASN1Primitive.fromByteArray(crl.getTBSCertList()));
 
            return new X509Principal(X509Name.getInstance(tbsCertList.getIssuer()));
        } 
        catch (IOException e)
        { 
            throw new CRLException(e.toString());
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getIssuerX500Principal, getRevokedCertificate, verify
        CertificateFactory   fact = CertificateFactory.getInstance("X.509", "BC");
         
        crl = (X509CRL)fact.generateCRL(bIn);
         
        // verify the CRL 
        crl.verify(caCert.getPublicKey(), "BC");
         
        // check if the CRL revokes certificate number 2 
        X509CRLEntry entry = crl.getRevokedCertificate(revokedSerialNumber);
        System.out.println("Revocation Details:");
        System.out.println("  Certificate number: " + entry.getSerialNumber());
        System.out.println("  Issuer            : " + crl.getIssuerX500Principal());
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getEncoded
import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder; 
import org.bouncycastle.jce.PKCS10CertificationRequest; 
import org.bouncycastle.openssl.MiscPEMGenerator; 
import org.bouncycastle.openssl.PEMEncryptor; 
import org.bouncycastle.x509.X509AttributeCertificate; 
import org.bouncycastle.x509.X509V2AttributeCertificate; 
 
/** 
 * PEM generator for the original set of PEM objects used in Open SSL. 
 */ 
public class JcaMiscPEMGenerator 
    extends MiscPEMGenerator 
{ 
    private Object obj;
    private String algorithm;
    private char[] password;
    private SecureRandom random;
    private Provider provider;
 
    public JcaMiscPEMGenerator(Object o)
5
CodeRank
This code example shows how to use the following methods:getRevokedCertificate, getRevokedCertificates
 
    public void testSupportIndirectCRLs() throws Exception { 
        X509CRL crl = (X509CRL)
            CertificateFactory.getInstance("X.509").generateCRL(
                    new ByteArrayInputStream(encoding));
        Set rcerts = crl.getRevokedCertificates();
        System.out.println(">> rcerts:"+rcerts);
 
        System.out.println("}>> "+ rcerts.toArray()[0]);
        System.out.println("}>> "+((X509CRLEntry) rcerts.toArray()[0]).getCertificateIssuer());
        System.out.println("}>> "+((X509CRLEntry) rcerts.toArray()[1]).getCertificateIssuer());
        System.out.println("}>> "+((X509CRLEntry) rcerts.toArray()[2]).getCertificateIssuer());
        System.out.println(">> "+crl.getRevokedCertificate(
                    BigInteger.valueOf(555)).getCertificateIssuer());
    } 
 
    public static Test suite() {
        return new TestSuite(CertificateListTest.class);
    } 
 
5
CodeRank
See Code Examples for Java 8 X509CRL Methods: