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


Java SignerInfo.getInstance方法代码示例

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


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

示例1: init

import org.bouncycastle.asn1.cms.SignerInfo; //导入方法依赖的package包/类
@Before
public void init() throws Exception {
	DSSDocument signedDocument = getSignedDocument();

	ASN1InputStream asn1sInput = new ASN1InputStream(signedDocument.openStream());
	ASN1Sequence asn1Seq = (ASN1Sequence) asn1sInput.readObject();
	assertEquals(2, asn1Seq.size());
	ASN1ObjectIdentifier oid = ASN1ObjectIdentifier.getInstance(asn1Seq.getObjectAt(0));
	assertEquals(PKCSObjectIdentifiers.signedData, oid);

	ASN1TaggedObject taggedObj = DERTaggedObject.getInstance(asn1Seq.getObjectAt(1));
	signedData = SignedData.getInstance(taggedObj.getObject());

	ASN1Set signerInfosAsn1 = signedData.getSignerInfos();
	assertEquals(1, signerInfosAsn1.size());

	signerInfo = SignerInfo.getInstance(ASN1Sequence.getInstance(signerInfosAsn1.getObjectAt(0)));

	Utils.closeQuietly(asn1sInput);
}
 
开发者ID:esig,项目名称:dss,代码行数:21,代码来源:AbstractRequirementChecks.java

示例2: getSignerInfos

import org.bouncycastle.asn1.cms.SignerInfo; //导入方法依赖的package包/类
/**
 * return the collection of signers that are associated with the
 * signatures for the message.
 */
public SignerInformationStore getSignerInfos()
{
    if (signerInfoStore == null)
    {
        ASN1Set         s = signedData.getSignerInfos();
        List            signerInfos = new ArrayList();
        SignatureAlgorithmIdentifierFinder sigAlgFinder = new DefaultSignatureAlgorithmIdentifierFinder();

        for (int i = 0; i != s.size(); i++)
        {
            SignerInfo info = SignerInfo.getInstance(s.getObjectAt(i));
            ASN1ObjectIdentifier contentType = signedData.getEncapContentInfo().getContentType();

            if (hashes == null)
            {
                signerInfos.add(new SignerInformation(info, contentType, signedContent, null));
            }
            else
            {
                Object obj = hashes.keySet().iterator().next();
                byte[] hash = (obj instanceof String) ? (byte[])hashes.get(info.getDigestAlgorithm().getAlgorithm().getId()) : (byte[])hashes.get(info.getDigestAlgorithm().getAlgorithm());

                signerInfos.add(new SignerInformation(info, contentType, null, hash));
            }
        }

        signerInfoStore = new SignerInformationStore(signerInfos);
    }

    return signerInfoStore;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:36,代码来源:CMSSignedData.java

示例3: getSignerInfos

import org.bouncycastle.asn1.cms.SignerInfo; //导入方法依赖的package包/类
/**
 * return the collection of signers that are associated with the
 * signatures for the message.
 */
public SignerInformationStore getSignerInfos()
{
    if (signerInfoStore == null)
    {
        ASN1Set         s = signedData.getSignerInfos();
        List            signerInfos = new ArrayList();

        for (int i = 0; i != s.size(); i++)
        {
            SignerInfo info = SignerInfo.getInstance(s.getObjectAt(i));
            ASN1ObjectIdentifier contentType = signedData.getEncapContentInfo().getContentType();

            if (hashes == null)
            {
                signerInfos.add(new SignerInformation(info, contentType, signedContent, null));
            }
            else
            {
                Object obj = hashes.keySet().iterator().next();
                byte[] hash = (obj instanceof String) ? (byte[])hashes.get(info.getDigestAlgorithm().getAlgorithm().getId()) : (byte[])hashes.get(info.getDigestAlgorithm().getAlgorithm());

                signerInfos.add(new SignerInformation(info, contentType, null, hash));
            }
        }

        signerInfoStore = new SignerInformationStore(signerInfos);
    }

    return signerInfoStore;
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:35,代码来源:CMSSignedData.java

示例4: getSignerInfos

import org.bouncycastle.asn1.cms.SignerInfo; //导入方法依赖的package包/类
/**
 * return the collection of signers that are associated with the
 * signatures for the message.
 * @throws CMSException 
 */
public SignerInformationStore getSignerInfos() 
    throws CMSException
{
    if (_signerInfoStore == null)
    {
        populateCertCrlSets();
        
        List      signerInfos = new ArrayList();
        Map       hashes = new HashMap();
        
        Iterator  it = digests.keySet().iterator();
        while (it.hasNext())
        {
            Object digestKey = it.next();

            hashes.put(digestKey, ((DigestCalculator)digests.get(digestKey)).getDigest());
        }
        
        try
        {
            ASN1SetParser     s = _signedData.getSignerInfos();
            ASN1Encodable      o;

            while ((o = s.readObject()) != null)
            {
                SignerInfo info = SignerInfo.getInstance(o.toASN1Primitive());

                byte[] hash = (byte[])hashes.get(info.getDigestAlgorithm().getAlgorithm());

                signerInfos.add(new SignerInformation(info, _signedContentType, null, hash));
            }
        }
        catch (IOException e)
        {
            throw new CMSException("io exception: " + e.getMessage(), e);
        }

        _signerInfoStore = new SignerInformationStore(signerInfos);
    }

    return _signerInfoStore;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:48,代码来源:CMSSignedDataParser.java

示例5: getCounterSignatures

import org.bouncycastle.asn1.cms.SignerInfo; //导入方法依赖的package包/类
/**
 * Return a SignerInformationStore containing the counter signatures attached to this
 * signer. If no counter signatures are present an empty store is returned.
 */
public SignerInformationStore getCounterSignatures()
{
    // TODO There are several checks implied by the RFC3852 comments that are missing

    /*
    The countersignature attribute MUST be an unsigned attribute; it MUST
    NOT be a signed attribute, an authenticated attribute, an
    unauthenticated attribute, or an unprotected attribute.
    */        
    AttributeTable unsignedAttributeTable = getUnsignedAttributes();
    if (unsignedAttributeTable == null)
    {
        return new SignerInformationStore(new ArrayList(0));
    }

    List counterSignatures = new ArrayList();

    /*
    The UnsignedAttributes syntax is defined as a SET OF Attributes.  The
    UnsignedAttributes in a signerInfo may include multiple instances of
    the countersignature attribute.
    */
    ASN1EncodableVector allCSAttrs = unsignedAttributeTable.getAll(CMSAttributes.counterSignature);

    for (int i = 0; i < allCSAttrs.size(); ++i)
    {
        Attribute counterSignatureAttribute = (Attribute)allCSAttrs.get(i);            

        /*
        A countersignature attribute can have multiple attribute values.  The
        syntax is defined as a SET OF AttributeValue, and there MUST be one
        or more instances of AttributeValue present.
        */
        ASN1Set values = counterSignatureAttribute.getAttrValues();
        if (values.size() < 1)
        {
            // TODO Throw an appropriate exception?
        }

        for (Enumeration en = values.getObjects(); en.hasMoreElements();)
        {
            /*
            Countersignature values have the same meaning as SignerInfo values
            for ordinary signatures, except that:

               1. The signedAttributes field MUST NOT contain a content-type
                  attribute; there is no content type for countersignatures.

               2. The signedAttributes field MUST contain a message-digest
                  attribute if it contains any other attributes.

               3. The input to the message-digesting process is the contents
                  octets of the DER encoding of the signatureValue field of the
                  SignerInfo value with which the attribute is associated.
            */
            SignerInfo si = SignerInfo.getInstance(en.nextElement());

            counterSignatures.add(new SignerInformation(si, null, new CMSProcessableByteArray(getSignature()), null));
        }
    }

    return new SignerInformationStore(counterSignatures);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:68,代码来源:SignerInformation.java

示例6: testContentTimeStamp

import org.bouncycastle.asn1.cms.SignerInfo; //导入方法依赖的package包/类
@Test
public void testContentTimeStamp() throws IOException {
	File file = new File("src/test/resources/plugtest/cades/CAdES-BES/Sample_Set_11/Signature-C-BES-4.p7m");

	FileInputStream fis = new FileInputStream(file);
	ASN1InputStream asn1sInput = new ASN1InputStream(Utils.toByteArray(fis));
	ASN1Sequence asn1Seq = (ASN1Sequence) asn1sInput.readObject();

	ASN1TaggedObject taggedObj = DERTaggedObject.getInstance(asn1Seq.getObjectAt(1));
	ASN1Primitive object = taggedObj.getObject();
	SignedData signedData = SignedData.getInstance(object);

	ASN1Set signerInfosAsn1 = signedData.getSignerInfos();
	ASN1Sequence seqSignedInfo = ASN1Sequence.getInstance(signerInfosAsn1.getObjectAt(0));

	SignerInfo signedInfo = SignerInfo.getInstance(seqSignedInfo);
	ASN1Set authenticatedAttributes = signedInfo.getAuthenticatedAttributes();

	boolean found = false;
	for (int i = 0; i < authenticatedAttributes.size(); i++) {
		ASN1Sequence authAttrSeq = ASN1Sequence.getInstance(authenticatedAttributes.getObjectAt(i));
		ASN1ObjectIdentifier attrOid = ASN1ObjectIdentifier.getInstance(authAttrSeq.getObjectAt(0));
		if (PKCSObjectIdentifiers.id_aa_ets_contentTimestamp.equals(attrOid)) {
			found = true;
		}
	}
	assertTrue(found);

	SignedDocumentValidator validator = SignedDocumentValidator.fromDocument(new FileDocument(file));
	validator.setCertificateVerifier(new CommonCertificateVerifier());

	Reports reports = validator.validateDocument();
	// reports.print();

	DiagnosticData diagnosticData = reports.getDiagnosticData();
	List<String> timestampIdList = diagnosticData.getTimestampIdList(diagnosticData.getFirstSignatureId());
	assertTrue(Utils.isCollectionNotEmpty(timestampIdList));

	boolean foundContentTimestamp = false;
	for (String timestampId : timestampIdList) {
		String timestampType = diagnosticData.getTimestampType(timestampId);
		if (TimestampType.CONTENT_TIMESTAMP.name().equals(timestampType)) {
			foundContentTimestamp = true;
		}
	}
	assertTrue(foundContentTimestamp);

	Utils.closeQuietly(asn1sInput);
	Utils.closeQuietly(fis);
}
 
开发者ID:esig,项目名称:dss,代码行数:51,代码来源:CAdESWithContentTimestampTest.java


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