⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x509crlobject.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   X509CRLObject.java

package org.bouncycastle.jce.provider;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.security.*;
import java.security.cert.*;
import java.util.*;
import javax.security.auth.x500.X500Principal;
import org.bouncycastle.asn1.*;
import org.bouncycastle.asn1.x509.*;
import org.bouncycastle.jce.X509Principal;

// Referenced classes of package org.bouncycastle.jce.provider:
//			X509CRLEntryObject

public class X509CRLObject extends X509CRL
{

	private CertificateList c;

	public X509CRLObject(CertificateList c)
	{
		this.c = c;
	}

	public boolean hasUnsupportedCriticalExtension()
	{
		Set extns = getCriticalExtensionOIDs();
		return extns != null && !extns.isEmpty();
	}

	private Set getExtensionOIDs(boolean critical)
	{
		if (getVersion() == 2)
		{
			HashSet set = new HashSet();
			X509Extensions extensions = c.getTBSCertList().getExtensions();
			Enumeration e = extensions.oids();
			do
			{
				if (!e.hasMoreElements())
					break;
				DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
				X509Extension ext = extensions.getExtension(oid);
				if (critical == ext.isCritical())
					set.add(oid.getId());
			} while (true);
			return set;
		} else
		{
			return null;
		}
	}

	public Set getCriticalExtensionOIDs()
	{
		return getExtensionOIDs(true);
	}

	public Set getNonCriticalExtensionOIDs()
	{
		return getExtensionOIDs(false);
	}

	public byte[] getExtensionValue(String oid)
	{
		X509Extension ext;
		ByteArrayOutputStream bOut;
		DEROutputStream dOut;
		X509Extensions exts = c.getTBSCertList().getExtensions();
		if (exts == null)
			break MISSING_BLOCK_LABEL_100;
		ext = exts.getExtension(new DERObjectIdentifier(oid));
		if (ext == null)
			break MISSING_BLOCK_LABEL_100;
		bOut = new ByteArrayOutputStream();
		dOut = new DEROutputStream(bOut);
		dOut.writeObject(ext.getValue());
		return bOut.toByteArray();
		Exception e;
		e;
		throw new RuntimeException((new StringBuilder()).append("error encoding ").append(e.toString()).toString());
		return null;
	}

	public byte[] getEncoded()
		throws CRLException
	{
		ByteArrayOutputStream bOut;
		DEROutputStream dOut;
		bOut = new ByteArrayOutputStream();
		dOut = new DEROutputStream(bOut);
		dOut.writeObject(c);
		return bOut.toByteArray();
		IOException e;
		e;
		throw new CRLException(e.toString());
	}

	public void verify(PublicKey key)
		throws CRLException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
	{
		verify(key, "BC");
	}

	public void verify(PublicKey key, String sigProvider)
		throws CRLException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
	{
		if (!c.getSignatureAlgorithm().equals(c.getTBSCertList().getSignature()))
			throw new CRLException("Signature algorithm on CertifcateList does not match TBSCertList.");
		Signature sig = Signature.getInstance(getSigAlgName(), sigProvider);
		sig.initVerify(key);
		sig.update(getTBSCertList());
		if (!sig.verify(getSignature()))
			throw new SignatureException("CRL does not verify with supplied public key.");
		else
			return;
	}

	public int getVersion()
	{
		return c.getVersion();
	}

	public Principal getIssuerDN()
	{
		return new X509Principal(c.getIssuer());
	}

	public X500Principal getIssuerX500Principal()
	{
		ByteArrayOutputStream bOut;
		bOut = new ByteArrayOutputStream();
		ASN1OutputStream aOut = new ASN1OutputStream(bOut);
		aOut.writeObject(c.getIssuer());
		return new X500Principal(bOut.toByteArray());
		IOException e;
		e;
		throw new IllegalStateException("can't encode issuer DN");
	}

	public Date getThisUpdate()
	{
		return c.getThisUpdate().getDate();
	}

	public Date getNextUpdate()
	{
		if (c.getNextUpdate() != null)
			return c.getNextUpdate().getDate();
		else
			return null;
	}

	public X509CRLEntry getRevokedCertificate(BigInteger serialNumber)
	{
		org.bouncycastle.asn1.x509.TBSCertList.CRLEntry certs[] = c.getRevokedCertificates();
		if (certs != null)
		{
			for (int i = 0; i < certs.length; i++)
				if (certs[i].getUserCertificate().getValue().equals(serialNumber))
					return new X509CRLEntryObject(certs[i]);

		}
		return null;
	}

	public Set getRevokedCertificates()
	{
		org.bouncycastle.asn1.x509.TBSCertList.CRLEntry certs[] = c.getRevokedCertificates();
		if (certs != null)
		{
			HashSet set = new HashSet();
			for (int i = 0; i < certs.length; i++)
				set.add(new X509CRLEntryObject(certs[i]));

			return set;
		} else
		{
			return null;
		}
	}

	public byte[] getTBSCertList()
		throws CRLException
	{
		ByteArrayOutputStream bOut;
		DEROutputStream dOut;
		bOut = new ByteArrayOutputStream();
		dOut = new DEROutputStream(bOut);
		dOut.writeObject(c.getTBSCertList());
		return bOut.toByteArray();
		IOException e;
		e;
		throw new CRLException(e.toString());
	}

	public byte[] getSignature()
	{
		return c.getSignature().getBytes();
	}

	public String getSigAlgName()
	{
		Provider prov = Security.getProvider("BC");
		String algName = prov.getProperty((new StringBuilder()).append("Alg.Alias.Signature.").append(getSigAlgOID()).toString());
		if (algName != null)
			return algName;
		Provider provs[] = Security.getProviders();
		for (int i = 0; i != provs.length; i++)
		{
			algName = provs[i].getProperty((new StringBuilder()).append("Alg.Alias.Signature.").append(getSigAlgOID()).toString());
			if (algName != null)
				return algName;
		}

		return getSigAlgOID();
	}

	public String getSigAlgOID()
	{
		return c.getSignatureAlgorithm().getObjectId().getId();
	}

	public byte[] getSigAlgParams()
	{
		ByteArrayOutputStream bOut = new ByteArrayOutputStream();
		if (c.getSignatureAlgorithm().getParameters() != null)
		{
			try
			{
				DEROutputStream dOut = new DEROutputStream(bOut);
				dOut.writeObject(c.getSignatureAlgorithm().getParameters());
			}
			catch (Exception e)
			{
				throw new RuntimeException((new StringBuilder()).append("exception getting sig parameters ").append(e).toString());
			}
			return bOut.toByteArray();
		} else
		{
			return null;
		}
	}

	public String toString()
	{
		return "X.509 CRL";
	}

	public boolean isRevoked(Certificate cert)
	{
		if (!cert.getType().equals("X.509"))
			throw new RuntimeException("X.509 CRL used with non X.509 Cert");
		org.bouncycastle.asn1.x509.TBSCertList.CRLEntry certs[] = c.getRevokedCertificates();
		if (certs != null)
		{
			BigInteger serial = ((X509Certificate)cert).getSerialNumber();
			for (int i = 0; i < certs.length; i++)
				if (certs[i].getUserCertificate().getValue().equals(serial))
					return true;

		}
		return false;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -