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


Java ContentInfo类代码示例

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


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

示例1: PKCS12SafeBagFactory

import org.bouncycastle.asn1.pkcs.ContentInfo; //导入依赖的package包/类
public PKCS12SafeBagFactory(ContentInfo info, InputDecryptorProvider inputDecryptorProvider)
    throws PKCSException
{
    if (info.getContentType().equals(PKCSObjectIdentifiers.encryptedData))
    {
        CMSEncryptedData encData = new CMSEncryptedData(org.bouncycastle.asn1.cms.ContentInfo.getInstance(info));

        try
        {
            this.safeBagSeq = ASN1Sequence.getInstance(encData.getContent(inputDecryptorProvider));
        }
        catch (CMSException e)
        {
            throw new PKCSException("unable to extract data: " + e.getMessage(), e);
        }
        return;
    }

    throw new IllegalArgumentException("encryptedData requires constructor with decryptor.");
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:PKCS12SafeBagFactory.java

示例2: addData

import org.bouncycastle.asn1.pkcs.ContentInfo; //导入依赖的package包/类
/**
 * Add a SafeBag that is to be included as is.
 *
 * @param data the SafeBag to add.
 * @return this builder.
 * @throws IOException
 */
public PKCS12PfxPduBuilder addData(PKCS12SafeBag data)
    throws IOException
{
    dataVector.add(new ContentInfo(PKCSObjectIdentifiers.data, new DEROctetString(new DLSequence(data.toASN1Structure()).getEncoded())));

    return this;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:PKCS12PfxPduBuilder.java

示例3: build

import org.bouncycastle.asn1.pkcs.ContentInfo; //导入依赖的package包/类
/**
 * Build the Pfx structure, protecting it with a MAC calculated against the passed in password.
 *
 * @param macCalcBuilder a builder for a PKCS12 mac calculator.
 * @param password the password to use.
 * @return a Pfx object.
 * @throws PKCSException on a encoding or processing error.
 */
public PKCS12PfxPdu build(PKCS12MacCalculatorBuilder macCalcBuilder, char[] password)
    throws PKCSException
{
    AuthenticatedSafe auth = AuthenticatedSafe.getInstance(new DLSequence(dataVector));
    byte[]            encAuth;

    try
    {
        encAuth = auth.getEncoded();
    }
    catch (IOException e)
    {
        throw new PKCSException("unable to encode AuthenticatedSafe: " + e.getMessage(), e);
    }

    ContentInfo       mainInfo = new ContentInfo(PKCSObjectIdentifiers.data, new DEROctetString(encAuth));
    MacData           mData = null;

    if (macCalcBuilder != null)
    {
        MacDataGenerator mdGen = new MacDataGenerator(macCalcBuilder);

        mData = mdGen.build(password, encAuth);
    }

    //
    // output the Pfx
    //
    Pfx pfx = new Pfx(mainInfo, mData);

    return new PKCS12PfxPdu(pfx);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:41,代码来源:PKCS12PfxPduBuilder.java

示例4: getContentInfos

import org.bouncycastle.asn1.pkcs.ContentInfo; //导入依赖的package包/类
/**
 * Return the content infos in the AuthenticatedSafe contained in this Pfx.
 *
 * @return an array of ContentInfo.
 */
public ContentInfo[] getContentInfos()
{
    ASN1Sequence seq = ASN1Sequence.getInstance(ASN1OctetString.getInstance(this.pfx.getAuthSafe().getContent()).getOctets());
    ContentInfo[] content = new ContentInfo[seq.size()];

    for (int i = 0; i != seq.size(); i++)
    {
        content[i] = ContentInfo.getInstance(seq.getObjectAt(i));
    }

    return content;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:PKCS12PfxPdu.java

示例5: obtenirDadesCertificatNoPdf

import org.bouncycastle.asn1.pkcs.ContentInfo; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "resource" })
private List<DadesCertificat> obtenirDadesCertificatNoPdf(
		byte[] signatura) throws Exception {
	X509Certificate[] certificats = null;
	byte[] pkcs7Bytes = signatura;
	ASN1InputStream asn1is = new ASN1InputStream(new ByteArrayInputStream(pkcs7Bytes));
	ContentInfo pkcs7Info = ContentInfo.getInstance(asn1is.readObject());
	SignedData signedData = SignedData.getInstance(pkcs7Info.getContent());
	ASN1Set signerInfos = signedData.getSignerInfos();
	int numSignatures = signerInfos.size();
	if (numSignatures > 0) {
		afegirProveidorBouncyCastle();
		CMSSignedData cmsSignedData = new CMSSignedData(pkcs7Bytes);
		SignerInformationStore signers = cmsSignedData.getSignerInfos();
		CertStore certStore = cmsSignedData.getCertificatesAndCRLs("Collection", "BC");
		List<X509Certificate> certs = new ArrayList<X509Certificate>();
		for (SignerInformation signer: (Collection<SignerInformation>)signers.getSigners()) {
			for (Certificate cert: certStore.getCertificates(signer.getSID())) {
				if (cert instanceof X509Certificate)
					certs.add((X509Certificate)cert);
			}
		}
		certificats = certs.toArray(new X509Certificate[certs.size()]);
		if (certificats.length != 1)
			throw new SignaturaPluginException("Aquesta signatura conté més d'un certificat");
		//resposta.setInfoCertificat(getInfoCertificat(certificats[0]));
		List<DadesCertificat> dadesCertificats = new ArrayList<DadesCertificat>();
		dadesCertificats.add(getDadesCertificat(certificats[0]));
		return dadesCertificats;
	}
	return null;
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:33,代码来源:SignaturaPluginTest.java

示例6: bytesToPkcs7SignedData

import org.bouncycastle.asn1.pkcs.ContentInfo; //导入依赖的package包/类
/**
 * Convert a byte array to a PKCS7 SignedData object
 * @param bytes byte array
 * @return PKCS7 SignedData object
 */
public static SignedData bytesToPkcs7SignedData(byte[] bytes) {

    if(bytes == null) {
        throw new IllegalArgumentException("null bytes");
    }

    ASN1InputStream ais = new ASN1InputStream(bytes);
    ASN1Object     asn1 = null;
    try {
        asn1 = ais.readObject();
    } catch(IOException ioe) {
        throw new IllegalArgumentException("not a pkcs7 signature");
    } finally {
        try {
            ais.close();
        } catch (IOException e) {
            // Ignore
        }
    }

    ContentInfo ci = ContentInfo.getInstance(asn1);

    ASN1ObjectIdentifier typeId = ci.getContentType();
    if( ! typeId.equals(PKCSObjectIdentifiers.signedData)) {
        throw new IllegalArgumentException("not a pkcs7 signature");
    }

    return SignedData.getInstance(ci.getContent());
}
 
开发者ID:laverca,项目名称:laverca,代码行数:35,代码来源:CmsSignature.java

示例7: getSafeBagFactory

import org.bouncycastle.asn1.pkcs.ContentInfo; //导入依赖的package包/类
private static PKCS12SafeBagFactory getSafeBagFactory(ContentInfo contentInfo) {
	return new PKCS12SafeBagFactory(contentInfo);
}
 
开发者ID:hdecarne,项目名称:certmgr,代码行数:4,代码来源:PKCS12CertReaderWriter.java

示例8: testKeyBag

import org.bouncycastle.asn1.pkcs.ContentInfo; //导入依赖的package包/类
public void testKeyBag()
    throws Exception
{
    OutputEncryptor encOut = new BcPKCS12PBEOutputEncryptorBuilder(PKCSObjectIdentifiers.pbeWithSHAAnd3_KeyTripleDES_CBC, new CBCBlockCipher(new DESedeEngine())).build(passwd);
    InputDecryptorProvider inputDecryptorProvider = new BcPKCS12PBEInputDecryptorProviderBuilder().build(passwd);
    KeyFactory fact = KeyFactory.getInstance("RSA", BC);
    PrivateKey privKey = fact.generatePrivate(privKeySpec);
    PKCS12SafeBagBuilder keyBagBuilder = new JcaPKCS12SafeBagBuilder(privKey);

    keyBagBuilder.addBagAttribute(PKCSObjectIdentifiers.pkcs_9_at_friendlyName, new DERBMPString("Eric's Key"));

    PKCS12PfxPduBuilder builder = new PKCS12PfxPduBuilder();

    builder.addEncryptedData(encOut, keyBagBuilder.build());

    PKCS12PfxPdu pfx = builder.build(new BcPKCS12MacCalculatorBuilder(), passwd);
    assertTrue(pfx.hasMac());
    assertTrue(pfx.isMacValid(new BcPKCS12MacCalculatorBuilderProvider(BcDefaultDigestProvider.INSTANCE), passwd));

    ContentInfo[] infos = pfx.getContentInfos();

    for (int i = 0; i != infos.length; i++)
    {
        if (infos[i].getContentType().equals(PKCSObjectIdentifiers.encryptedData))
        {
            PKCS12SafeBagFactory dataFact = new PKCS12SafeBagFactory(infos[i], inputDecryptorProvider);

            PKCS12SafeBag[] bags = dataFact.getSafeBags();

            assertEquals(1, bags.length);
            assertEquals(PKCSObjectIdentifiers.keyBag, bags[0].getType());

            assertTrue(Arrays.areEqual(privKey.getEncoded(), ((PrivateKeyInfo)bags[0].getBagValue()).getEncoded()));

            Attribute[] attributes = bags[0].getAttributes();

            assertEquals(1, attributes.length);

            assertEquals(PKCSObjectIdentifiers.pkcs_9_at_friendlyName, attributes[0].getAttrType());

            ASN1Encodable[] attrValues = attributes[0].getAttributeValues();

            assertEquals(1, attrValues.length);
            assertEquals(new DERBMPString("Eric's Key"), attrValues[0]);
        }
        else
        {
            fail("unknown bag encountered");
        }
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:52,代码来源:PfxPduTest.java


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