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


Java X509CertificateStructure.getInstance方法代码示例

本文整理汇总了Java中org.bouncycastle.asn1.x509.X509CertificateStructure.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java X509CertificateStructure.getInstance方法的具体用法?Java X509CertificateStructure.getInstance怎么用?Java X509CertificateStructure.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.asn1.x509.X509CertificateStructure的用法示例。


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

示例1: readPKCS7Certificate

import org.bouncycastle.asn1.x509.X509CertificateStructure; //导入方法依赖的package包/类
/**
   * read in a BER encoded PKCS7 certificate.
   */
  private Certificate readPKCS7Certificate(
      InputStream  in)
      throws IOException
  {
      BERInputStream  dIn = new BERInputStream(in);
      ASN1Sequence seq = (ASN1Sequence)dIn.readObject();

if (seq.size() > 1
		&& seq.getObjectAt(0) instanceof DERObjectIdentifier)
{
       if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData))
       {
		sData = new SignedData(ASN1Sequence.getInstance(
						(ASN1TaggedObject)seq.getObjectAt(1), true));
	
		return new X509CertificateObject(
					X509CertificateStructure.getInstance(
							sData.getCertificates().getObjectAt(sDataObjectCount++)));
       }
}

return new X509CertificateObject(
			 X509CertificateStructure.getInstance(seq));
  }
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:28,代码来源:JDKX509CertificateFactory.java

示例2: readDERCertificate

import org.bouncycastle.asn1.x509.X509CertificateStructure; //导入方法依赖的package包/类
private Certificate readDERCertificate(
    InputStream in)
    throws IOException
{
    DERInputStream  dIn = new DERInputStream(in);
    ASN1Sequence    seq = (ASN1Sequence)dIn.readObject();

    if (seq.size() > 1
            && seq.getObjectAt(0) instanceof DERObjectIdentifier)
    {
        if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData))
        {
            sData = new SignedData(ASN1Sequence.getInstance(
                            (ASN1TaggedObject)seq.getObjectAt(1), true));

            return new X509CertificateObject(
                        X509CertificateStructure.getInstance(
                                sData.getCertificates().getObjectAt(sDataObjectCount++)));
        }
    }

    return new X509CertificateObject(
                        X509CertificateStructure.getInstance(seq));
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:25,代码来源:JDKX509CertificateFactory.java

示例3: getExtensions

import org.bouncycastle.asn1.x509.X509CertificateStructure; //导入方法依赖的package包/类
public static X509Extensions getExtensions(X509Certificate cert) 
    throws Exception
{
    ByteArrayInputStream bis = new ByteArrayInputStream(cert.getEncoded());
    ASN1InputStream ais = new ASN1InputStream(bis);
    DERObject o = ais.readObject();
    X509CertificateStructure struct = X509CertificateStructure
            .getInstance(o);

    return struct.getTBSCertificate().getExtensions();
}
 
开发者ID:edeoliveira,项目名称:Mailster,代码行数:12,代码来源:CertificateUtilities.java

示例4: engineGenerateCertificate

import org.bouncycastle.asn1.x509.X509CertificateStructure; //导入方法依赖的package包/类
/**
  * Generates a certificate object and initializes it with the data
  * read from the input stream inStream.
  */
 public Certificate engineGenerateCertificate(
     InputStream in) 
     throws CertificateException
 {
 	if (sData != null && sDataObjectCount != sData.getCertificates().size())
 	{
return new X509CertificateObject(
			X509CertificateStructure.getInstance(
					sData.getCertificates().getObjectAt(sDataObjectCount++)));
 	}
 	
     if (!in.markSupported())
     {
         in = new BufferedInputStream(in);
     }

     try
     {
         in.mark(10);
         int	tag = in.read();
         
         if (tag == -1)
         {
         	return null;
         }
         
         if (tag != 0x30)  // assume ascii PEM encoded.
         {
             in.reset();
             return readPEMCertificate(in);
         }
         else if (in.read() == 0x80)    // assume BER encoded.
         {
             in.reset();
             return readPKCS7Certificate(in);
         }
         else
         {
             in.reset();
             return readDERCertificate(in);
         }
     }
     catch (IOException e)
     {
         throw new CertificateException(e.toString());
     }
 }
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:52,代码来源:JDKX509CertificateFactory.java

示例5: testNullDerNullCert

import org.bouncycastle.asn1.x509.X509CertificateStructure; //导入方法依赖的package包/类
private void testNullDerNullCert()
    throws Exception
{
    KeyPair pair = generateLongFixedKeys();
    PublicKey pubKey = pair.getPublic();
    PrivateKey privKey = pair.getPrivate();

    X509V3CertificateGenerator  certGen = new X509V3CertificateGenerator();

    certGen.setSerialNumber(BigInteger.valueOf(1));
    certGen.setIssuerDN(new X509Principal("CN=Test"));
    certGen.setNotBefore(new Date(System.currentTimeMillis() - 50000));
    certGen.setNotAfter(new Date(System.currentTimeMillis() + 50000));
    certGen.setSubjectDN(new X509Principal("CN=Test"));
    certGen.setPublicKey(pubKey);
    certGen.setSignatureAlgorithm("MD5WithRSAEncryption");
    X509Certificate cert = certGen.generate(privKey, "BC");

    X509CertificateStructure struct = X509CertificateStructure.getInstance(ASN1Primitive.fromByteArray(cert.getEncoded()));

    ASN1Encodable tbsCertificate = struct.getTBSCertificate();
    AlgorithmIdentifier sig = struct.getSignatureAlgorithm();

    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(tbsCertificate);
    v.add(new AlgorithmIdentifier(sig.getObjectId()));
    v.add(struct.getSignature());

    // verify
    ByteArrayInputStream    bIn;
    String                  dump = "";

    try
    {
        bIn = new ByteArrayInputStream(new DERSequence(v).getEncoded());

        CertificateFactory  fact = CertificateFactory.getInstance("X.509", "BC");

        cert = (X509Certificate)fact.generateCertificate(bIn);

        cert.verify(cert.getPublicKey());
    }
    catch (Exception e)
    {
        fail(dump + System.getProperty("line.separator") + getName() + ": testNullDerNull failed - exception " + e.toString(), e);
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:49,代码来源:CertTest.java

示例6: testNullDerNullCert

import org.bouncycastle.asn1.x509.X509CertificateStructure; //导入方法依赖的package包/类
private void testNullDerNullCert()
    throws Exception
{
    KeyPair pair = generateLongFixedKeys();
    PublicKey pubKey = pair.getPublic();
    PrivateKey privKey = pair.getPrivate();

    ContentSigner sigGen = new JcaContentSignerBuilder("MD5WithRSAEncryption").setProvider(BC).build(privKey);
    JcaX509v3CertificateBuilder  certGen = new JcaX509v3CertificateBuilder(new X500Name("CN=Test"),BigInteger.valueOf(1),new Date(System.currentTimeMillis() - 50000),new Date(System.currentTimeMillis() + 50000),new X500Name("CN=Test"),pubKey);
    X509Certificate cert = new JcaX509CertificateConverter().setProvider(BC).getCertificate(certGen.build(sigGen));

    X509CertificateStructure struct = X509CertificateStructure.getInstance(ASN1Primitive.fromByteArray(cert.getEncoded()));

    ASN1Encodable tbsCertificate = struct.getTBSCertificate();
    AlgorithmIdentifier sig = struct.getSignatureAlgorithm();

    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(tbsCertificate);
    v.add(new AlgorithmIdentifier(sig.getAlgorithm()));
    v.add(struct.getSignature());

    // verify
    ByteArrayInputStream    bIn;
    String                  dump = "";

    try
    {
        bIn = new ByteArrayInputStream(new DERSequence(v).getEncoded());

        CertificateFactory  fact = CertificateFactory.getInstance("X.509", BC);

        cert = (X509Certificate)fact.generateCertificate(bIn);

        cert.verify(cert.getPublicKey());
    }
    catch (Exception e)
    {
        fail(dump + System.getProperty("line.separator") + getName() + ": testNullDerNull failed - exception " + e.toString(), e);
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:42,代码来源:CertTest.java


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