signeddata.java

来自「《移动Agent技术》一书的所有章节源代码。」· Java 代码 · 共 106 行

JAVA
106
字号
package org.bouncycastle.asn1.pkcs;import java.util.Enumeration;import org.bouncycastle.asn1.*;import org.bouncycastle.asn1.x509.*;/** * a PKCS#7 signed data object. */public class SignedData    implements DEREncodable, PKCSObjectIdentifiers{    private DERInteger              version;    private DERObject               digestAlgorithms;    private ContentInfo             contentInfo;    private DERObject               certificates;    private DERObject               crls;    public SignedData(        DERConstructedSequence  obj)    {        Enumeration     e = obj.getObjects();        version = (DERInteger)e.nextElement();        digestAlgorithms = ((DERSet)e.nextElement()).getSequence();        contentInfo = new ContentInfo((DERConstructedSequence)e.nextElement());        while (e.hasMoreElements())        {            DERObject o = (DERObject)e.nextElement();            //            // an interesting feature of SignedData is that there appear to be varying implementations...            // for the moment we ignore anything which doesn't fit.            //            if (o instanceof DERTaggedObject)            {                DERTaggedObject tagged = (DERTaggedObject)o;                switch (tagged.getTagNo())                {                case 0:                    certificates = tagged.getObject();                    break;                case 1:                    crls = tagged.getObject();                    break;                default:                    throw new IllegalArgumentException("unknown tag value " + tagged.getTagNo());                }            }        }    }    public DERInteger getVersion()    {        return version;    }    public ContentInfo getContentInfo()    {        return contentInfo;    }    public DERObject getCertficates()    {        return certificates;    }    /**     * <pre>     *  SignedData ::= SEQUENCE {     *      version Version,     *      digestAlgorithms DigestAlgorithmIdentifiers,     *      contentInfo ContentInfo,     *      certificates     *          [0] IMPLICIT ExtendedCertificatesAndCertificates     *                   OPTIONAL,     *      crls     *          [1] IMPLICIT CertificateRevocationLists OPTIONAL,     *      signerInfos SignerInfos }     * </pre>     */    public DERObject getDERObject()    {        DERConstructedSequence  seq = new DERConstructedSequence();        seq.addObject(version);        seq.addObject(digestAlgorithms);        seq.addObject(contentInfo);        if (certificates != null)        {            seq.addObject(new DERTaggedObject(false, 0, certificates));        }        if (crls != null)        {            seq.addObject(new DERTaggedObject(false, 1, crls));        }        return seq;    }}

⌨️ 快捷键说明

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