本文整理匯總了Java中org.bouncycastle.asn1.x509.Certificate類的典型用法代碼示例。如果您正苦於以下問題:Java Certificate類的具體用法?Java Certificate怎麽用?Java Certificate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Certificate類屬於org.bouncycastle.asn1.x509包,在下文中一共展示了Certificate類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generateJcaObject
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
private X509Certificate generateJcaObject(TBSCertificate tbsCert, byte[] signature)
throws CertificateEncodingException
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(tbsCert);
v.add(sigAlgId);
v.add(new DERBitString(signature));
try
{
return new X509CertificateObject(Certificate.getInstance(new DERSequence(v)));
}
catch (CertificateParsingException e)
{
throw new ExtCertificateEncodingException("exception producing certificate object", e);
}
}
示例2: copyAndAddExtension
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
/**
* Add a given extension field for the standard extensions tag (tag 3)
* copying the extension value from another certificate.
*
* @param oid the OID defining the extension type.
* @param isCritical true if the copied extension is to be marked as critical, false otherwise.
* @param certHolder the holder for the certificate that the extension is to be copied from.
* @return this builder object.
*/
public X509v3CertificateBuilder copyAndAddExtension(
ASN1ObjectIdentifier oid,
boolean isCritical,
X509CertificateHolder certHolder)
{
Certificate cert = certHolder.toASN1Structure();
Extension extension = cert.getTBSCertificate().getExtensions().getExtension(oid);
if (extension == null)
{
throw new NullPointerException("extension " + oid + " not present");
}
extGenerator.addExtension(oid, isCritical, extension.getExtnValue().getOctets());
return this;
}
示例3: CscaMasterList
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
private CscaMasterList(
ASN1Sequence seq)
{
if (seq == null || seq.size() == 0)
{
throw new IllegalArgumentException(
"null or empty sequence passed.");
}
if (seq.size() != 2)
{
throw new IllegalArgumentException(
"Incorrect sequence size: " + seq.size());
}
version = ASN1Integer.getInstance(seq.getObjectAt(0));
ASN1Set certSet = ASN1Set.getInstance(seq.getObjectAt(1));
certList = new Certificate[certSet.size()];
for (int i = 0; i < certList.length; i++)
{
certList[i]
= Certificate.getInstance(certSet.getObjectAt(i));
}
}
示例4: getInstance
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
public static RequestedCertificate getInstance(Object obj)
{
if (obj == null || obj instanceof RequestedCertificate)
{
return (RequestedCertificate)obj;
}
if (obj instanceof ASN1Sequence)
{
return new RequestedCertificate(Certificate.getInstance(obj));
}
if (obj instanceof ASN1TaggedObject)
{
return new RequestedCertificate((ASN1TaggedObject)obj);
}
throw new IllegalArgumentException("illegal object in getInstance: "
+ obj.getClass().getName());
}
示例5: getInstance
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
public static CMPCertificate getInstance(Object o)
{
if (o == null || o instanceof CMPCertificate)
{
return (CMPCertificate)o;
}
if (o instanceof ASN1Sequence || o instanceof byte[])
{
return new CMPCertificate(Certificate.getInstance(o));
}
if (o instanceof ASN1TaggedObject)
{
return new CMPCertificate(AttributeCertificate.getInstance(((ASN1TaggedObject)o).getObject()));
}
throw new IllegalArgumentException("Invalid object: " + o.getClass().getName());
}
示例6: readDERCertificate
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
private java.security.cert.Certificate readDERCertificate(
ASN1InputStream dIn)
throws IOException, CertificateParsingException
{
ASN1Sequence seq = (ASN1Sequence)dIn.readObject();
if (seq.size() > 1
&& seq.getObjectAt(0) instanceof ASN1ObjectIdentifier)
{
if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData))
{
sData = SignedData.getInstance(ASN1Sequence.getInstance(
(ASN1TaggedObject)seq.getObjectAt(1), true)).getCertificates();
return getCertificate();
}
}
return new X509CertificateObject(
Certificate.getInstance(seq));
}
示例7: getCertificate
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
private java.security.cert.Certificate getCertificate()
throws CertificateParsingException
{
if (sData != null)
{
while (sDataObjectCount < sData.size())
{
Object obj = sData.getObjectAt(sDataObjectCount++);
if (obj instanceof ASN1Sequence)
{
return new X509CertificateObject(
Certificate.getInstance(obj));
}
}
}
return null;
}
示例8: getCertificates
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
Store getCertificates(ASN1Set certSet)
{
if (certSet != null)
{
List certList = new ArrayList(certSet.size());
for (Enumeration en = certSet.getObjects(); en.hasMoreElements();)
{
ASN1Primitive obj = ((ASN1Encodable)en.nextElement()).toASN1Primitive();
if (obj instanceof ASN1Sequence)
{
certList.add(new X509CertificateHolder(Certificate.getInstance(obj)));
}
}
return new CollectionStore(certList);
}
return new CollectionStore(new ArrayList());
}
示例9: getCertificates
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
/**
* Return the certificates stored in the underlying OriginatorInfo object.
*
* @return a Store of X509CertificateHolder objects.
*/
public Store getCertificates()
{
ASN1Set certSet = originatorInfo.getCertificates();
if (certSet != null)
{
List certList = new ArrayList(certSet.size());
for (Enumeration en = certSet.getObjects(); en.hasMoreElements();)
{
ASN1Primitive obj = ((ASN1Encodable)en.nextElement()).toASN1Primitive();
if (obj instanceof ASN1Sequence)
{
certList.add(new X509CertificateHolder(Certificate.getInstance(obj)));
}
}
return new CollectionStore(certList);
}
return new CollectionStore(new ArrayList());
}
示例10: execute0
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
@Override
protected Object execute0() throws Exception {
Certificate cert = Certificate.getInstance(IoUtil.read(inFile));
if (serial != null && serial) {
return getNumber(cert.getSerialNumber().getPositiveValue());
} else if (subject != null && subject) {
return cert.getSubject().toString();
} else if (issuer != null && issuer) {
return cert.getIssuer().toString();
} else if (notBefore != null && notBefore) {
return toUtcTimeyyyyMMddhhmmssZ(cert.getStartDate().getDate());
} else if (notAfter != null && notAfter) {
return toUtcTimeyyyyMMddhhmmssZ(cert.getEndDate().getDate());
} else if (fingerprint != null && fingerprint) {
byte[] encoded = cert.getEncoded();
return HashAlgoType.getHashAlgoType(hashAlgo).hexHash(encoded);
}
return null;
}
示例11: checkConstruction
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
private void checkConstruction(
RequestedCertificate requested,
int type,
byte[] certOctets,
Certificate cert)
throws IOException
{
checkValues(requested, type, certOctets, cert);
requested = RequestedCertificate.getInstance(requested);
checkValues(requested, type, certOctets, cert);
ASN1InputStream aIn = new ASN1InputStream(requested.toASN1Primitive().getEncoded());
Object obj = aIn.readObject();
requested = RequestedCertificate.getInstance(obj);
checkValues(requested, type, certOctets, cert);
}
示例12: checkValues
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
private void checkValues(
RequestedCertificate requested,
int type,
byte[] certOctets,
Certificate cert)
throws IOException
{
checkMandatoryField("certType", type, requested.getType());
if (requested.getType() == RequestedCertificate.certificate)
{
checkMandatoryField("certificate", cert.getEncoded(), requested.getCertificateBytes());
}
else
{
checkMandatoryField("certificateOctets", certOctets, requested.getCertificateBytes());
}
}
示例13: buildCRT
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
private static byte[] buildCRT(TBSCertificate tbs, AlgorithmIdentifier aid, byte[] sig) {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(tbs);
v.add(aid);
v.add(new DERBitString(sig));
byte [] crt = null;
try {
Certificate c = Certificate.getInstance(new DERSequence(v));
crt = c.getEncoded();
Base64.encode(crt, System.out);
System.out.println("");
} catch (Exception ex) {
ex.printStackTrace(System.out);
Assert.fail();
}
return crt;
}
示例14: readDERCertificate
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
private java.security.cert.Certificate readDERCertificate(
ASN1InputStream dIn)
throws IOException, CertificateParsingException
{
ASN1Sequence seq = (ASN1Sequence)dIn.readObject();
if (seq.size() > 1
&& seq.getObjectAt(0) instanceof ASN1ObjectIdentifier)
{
if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData))
{
sData = SignedData.getInstance(ASN1Sequence.getInstance(
(ASN1TaggedObject)seq.getObjectAt(1), true)).getCertificates();
return getCertificate();
}
}
return new X509CertificateObject(bcHelper,
Certificate.getInstance(seq));
}
示例15: getCertificate
import org.bouncycastle.asn1.x509.Certificate; //導入依賴的package包/類
private java.security.cert.Certificate getCertificate()
throws CertificateParsingException
{
if (sData != null)
{
while (sDataObjectCount < sData.size())
{
Object obj = sData.getObjectAt(sDataObjectCount++);
if (obj instanceof ASN1Sequence)
{
return new X509CertificateObject(bcHelper,
Certificate.getInstance(obj));
}
}
}
return null;
}