Java 类org.bouncycastle.asn1.cms.ContentInfoParser 实例源码

项目:ipack    文件:CMSCompressedDataParser.java   
/**
 * @deprecated  use getContent(InputExpandedProvider)
 */
public CMSTypedStream  getContent()
    throws CMSException
{
    try
    {
        CompressedDataParser  comData = new CompressedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));
        ContentInfoParser     content = comData.getEncapContentInfo();

        ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(BERTags.OCTET_STRING);

        return new CMSTypedStream(content.getContentType().toString(), new InflaterInputStream(bytes.getOctetStream()));
    }
    catch (IOException e)
    {
        throw new CMSException("IOException reading compressed content.", e);
    }
}
项目:ipack    文件:CMSCompressedDataParser.java   
/**
 * Return a typed stream which will allow the reading of the compressed content in
 * expanded form.
 *
 * @param expanderProvider a provider of expander algorithm implementations.
 * @return a type stream which will yield the un-compressed content.
 * @throws CMSException if there is an exception parsing the CompressedData object.
 */
public CMSTypedStream  getContent(InputExpanderProvider expanderProvider)
    throws CMSException
{
    try
    {
        CompressedDataParser  comData = new CompressedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));
        ContentInfoParser     content = comData.getEncapContentInfo();
        InputExpander expander = expanderProvider.get(comData.getCompressionAlgorithmIdentifier());

        ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(BERTags.OCTET_STRING);

        return new CMSTypedStream(content.getContentType().getId(), expander.getInputStream(bytes.getOctetStream()));
    }
    catch (IOException e)
    {
        throw new CMSException("IOException reading compressed content.", e);
    }
}
项目:ipack    文件:CMSTimeStampedDataParser.java   
private void initialize(ContentInfoParser contentInfo)
    throws CMSException
{
    try
    {
        if (CMSObjectIdentifiers.timestampedData.equals(contentInfo.getContentType()))
        {
            this.timeStampedData = TimeStampedDataParser.getInstance(contentInfo.getContent(BERTags.SEQUENCE));
        }
        else
        {
            throw new IllegalArgumentException("Malformed content - type must be " + CMSObjectIdentifiers.timestampedData.getId());
        }
    }
    catch (IOException e)
    {
        throw new CMSException("parsing exception: " + e.getMessage(), e);
    }
}
项目:gwt-crypto    文件:CMSCompressedDataParser.java   
/**
 * Return a typed stream which will allow the reading of the compressed content in
 * expanded form.
 *
 * @param expanderProvider a provider of expander algorithm implementations.
 * @return a type stream which will yield the un-compressed content.
 * @throws CMSException if there is an exception parsing the CompressedData object.
 */
public CMSTypedStream  getContent(InputExpanderProvider expanderProvider)
    throws CMSException
{
    try
    {
        CompressedDataParser  comData = new CompressedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));
        ContentInfoParser     content = comData.getEncapContentInfo();
        InputExpander expander = expanderProvider.get(comData.getCompressionAlgorithmIdentifier());

        ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(BERTags.OCTET_STRING);

        return new CMSTypedStream(content.getContentType().getId(), expander.getInputStream(bytes.getOctetStream()));
    }
    catch (IOException e)
    {
        throw new CMSException("IOException reading compressed content.", e);
    }
}
项目:gwt-crypto    文件:CMSTimeStampedDataParser.java   
private void initialize(ContentInfoParser contentInfo)
    throws CMSException
{
    try
    {
        if (CMSObjectIdentifiers.timestampedData.equals(contentInfo.getContentType()))
        {
            this.timeStampedData = TimeStampedDataParser.getInstance(contentInfo.getContent(BERTags.SEQUENCE));
        }
        else
        {
            throw new IllegalArgumentException("Malformed content - type must be " + CMSObjectIdentifiers.timestampedData.getId());
        }
    }
    catch (IOException e)
    {
        throw new CMSException("parsing exception: " + e.getMessage(), e);
    }
}
项目:Aki-SSL    文件:CMSCompressedDataParser.java   
/**
 * Return a typed stream which will allow the reading of the compressed content in
 * expanded form.
 *
 * @param expanderProvider a provider of expander algorithm implementations.
 * @return a type stream which will yield the un-compressed content.
 * @throws CMSException if there is an exception parsing the CompressedData object.
 */
public CMSTypedStream  getContent(InputExpanderProvider expanderProvider)
    throws CMSException
{
    try
    {
        CompressedDataParser  comData = new CompressedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));
        ContentInfoParser     content = comData.getEncapContentInfo();
        InputExpander expander = expanderProvider.get(comData.getCompressionAlgorithmIdentifier());

        ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(BERTags.OCTET_STRING);

        return new CMSTypedStream(content.getContentType().getId(), expander.getInputStream(bytes.getOctetStream()));
    }
    catch (IOException e)
    {
        throw new CMSException("IOException reading compressed content.", e);
    }
}
项目:Aki-SSL    文件:CMSTimeStampedDataParser.java   
private void initialize(ContentInfoParser contentInfo)
    throws CMSException
{
    try
    {
        if (CMSObjectIdentifiers.timestampedData.equals(contentInfo.getContentType()))
        {
            this.timeStampedData = TimeStampedDataParser.getInstance(contentInfo.getContent(BERTags.SEQUENCE));
        }
        else
        {
            throw new IllegalArgumentException("Malformed content - type must be " + CMSObjectIdentifiers.timestampedData.getId());
        }
    }
    catch (IOException e)
    {
        throw new CMSException("parsing exception: " + e.getMessage(), e);
    }
}
项目:irma_future_id    文件:CMSTimeStampedDataParser.java   
private void initialize(ContentInfoParser contentInfo)
    throws CMSException
{
    try
    {
        if (CMSObjectIdentifiers.timestampedData.equals(contentInfo.getContentType()))
        {
            this.timeStampedData = TimeStampedDataParser.getInstance(contentInfo.getContent(BERTags.SEQUENCE));
        }
        else
        {
            throw new IllegalArgumentException("Malformed content - type must be " + CMSObjectIdentifiers.timestampedData.getId());
        }
    }
    catch (IOException e)
    {
        throw new CMSException("parsing exception: " + e.getMessage(), e);
    }
}
项目:irma_future_id    文件:CMSCompressedDataParser.java   
/**
 * @deprecated  use getContent(InputExpandedProvider)
 */
public CMSTypedStream  getContent()
    throws CMSException
{
    try
    {
        CompressedDataParser  comData = new CompressedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));
        ContentInfoParser     content = comData.getEncapContentInfo();

        ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(BERTags.OCTET_STRING);

        return new CMSTypedStream(content.getContentType().toString(), new InflaterInputStream(bytes.getOctetStream()));
    }
    catch (IOException e)
    {
        throw new CMSException("IOException reading compressed content.", e);
    }
}
项目:irma_future_id    文件:CMSCompressedDataParser.java   
/**
 * Return a typed stream which will allow the reading of the compressed content in
 * expanded form.
 *
 * @param expanderProvider a provider of expander algorithm implementations.
 * @return a type stream which will yield the un-compressed content.
 * @throws CMSException if there is an exception parsing the CompressedData object.
 */
public CMSTypedStream  getContent(InputExpanderProvider expanderProvider)
    throws CMSException
{
    try
    {
        CompressedDataParser  comData = new CompressedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));
        ContentInfoParser     content = comData.getEncapContentInfo();
        InputExpander expander = expanderProvider.get(comData.getCompressionAlgorithmIdentifier());

        ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(BERTags.OCTET_STRING);

        return new CMSTypedStream(content.getContentType().getId(), expander.getInputStream(bytes.getOctetStream()));
    }
    catch (IOException e)
    {
        throw new CMSException("IOException reading compressed content.", e);
    }
}
项目:irma_future_id    文件:CMSTimeStampedDataParser.java   
private void initialize(ContentInfoParser contentInfo)
    throws CMSException
{
    try
    {
        if (CMSObjectIdentifiers.timestampedData.equals(contentInfo.getContentType()))
        {
            this.timeStampedData = TimeStampedDataParser.getInstance(contentInfo.getContent(BERTags.SEQUENCE));
        }
        else
        {
            throw new IllegalArgumentException("Malformed content - type must be " + CMSObjectIdentifiers.timestampedData.getId());
        }
    }
    catch (IOException e)
    {
        throw new CMSException("parsing exception: " + e.getMessage(), e);
    }
}
项目:irma_future_id    文件:CMSTimeStampedDataParser.java   
private void initialize(ContentInfoParser contentInfo)
    throws CMSException
{
    try
    {
        if (CMSObjectIdentifiers.timestampedData.equals(contentInfo.getContentType()))
        {
            this.timeStampedData = TimeStampedDataParser.getInstance(contentInfo.getContent(BERTags.SEQUENCE));
        }
        else
        {
            throw new IllegalArgumentException("Malformed content - type must be " + CMSObjectIdentifiers.timestampedData.getId());
        }
    }
    catch (IOException e)
    {
        throw new CMSException("parsing exception: " + e.getMessage(), e);
    }
}
项目:bc-java    文件:CMSTimeStampedDataParser.java   
private void initialize(ContentInfoParser contentInfo)
    throws CMSException
{
    try
    {
        if (CMSObjectIdentifiers.timestampedData.equals(contentInfo.getContentType()))
        {
            this.timeStampedData = TimeStampedDataParser.getInstance(contentInfo.getContent(BERTags.SEQUENCE));
        }
        else
        {
            throw new IllegalArgumentException("Malformed content - type must be " + CMSObjectIdentifiers.timestampedData.getId());
        }
    }
    catch (IOException e)
    {
        throw new CMSException("parsing exception: " + e.getMessage(), e);
    }
}
项目:bc-java    文件:CMSCompressedDataParser.java   
/**
 * @deprecated  use getContent(InputExpandedProvider)
 */
public CMSTypedStream  getContent()
    throws CMSException
{
    try
    {
        CompressedDataParser  comData = new CompressedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));
        ContentInfoParser     content = comData.getEncapContentInfo();

        ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(BERTags.OCTET_STRING);

        return new CMSTypedStream(content.getContentType().toString(), new InflaterInputStream(bytes.getOctetStream()));
    }
    catch (IOException e)
    {
        throw new CMSException("IOException reading compressed content.", e);
    }
}
项目:bc-java    文件:CMSCompressedDataParser.java   
/**
 * Return a typed stream which will allow the reading of the compressed content in
 * expanded form.
 *
 * @param expanderProvider a provider of expander algorithm implementations.
 * @return a type stream which will yield the un-compressed content.
 * @throws CMSException if there is an exception parsing the CompressedData object.
 */
public CMSTypedStream  getContent(InputExpanderProvider expanderProvider)
    throws CMSException
{
    try
    {
        CompressedDataParser  comData = new CompressedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));
        ContentInfoParser     content = comData.getEncapContentInfo();
        InputExpander expander = expanderProvider.get(comData.getCompressionAlgorithmIdentifier());

        ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(BERTags.OCTET_STRING);

        return new CMSTypedStream(content.getContentType().getId(), expander.getInputStream(bytes.getOctetStream()));
    }
    catch (IOException e)
    {
        throw new CMSException("IOException reading compressed content.", e);
    }
}
项目:bc-java    文件:CMSTimeStampedDataParser.java   
private void initialize(ContentInfoParser contentInfo)
    throws CMSException
{
    try
    {
        if (CMSObjectIdentifiers.timestampedData.equals(contentInfo.getContentType()))
        {
            this.timeStampedData = TimeStampedDataParser.getInstance(contentInfo.getContent(BERTags.SEQUENCE));
        }
        else
        {
            throw new IllegalArgumentException("Malformed content - type must be " + CMSObjectIdentifiers.timestampedData.getId());
        }
    }
    catch (IOException e)
    {
        throw new CMSException("parsing exception: " + e.getMessage(), e);
    }
}
项目:bc-java    文件:CMSTimeStampedDataParser.java   
private void initialize(ContentInfoParser contentInfo)
    throws CMSException
{
    try
    {
        if (CMSObjectIdentifiers.timestampedData.equals(contentInfo.getContentType()))
        {
            this.timeStampedData = TimeStampedDataParser.getInstance(contentInfo.getContent(BERTags.SEQUENCE));
        }
        else
        {
            throw new IllegalArgumentException("Malformed content - type must be " + CMSObjectIdentifiers.timestampedData.getId());
        }
    }
    catch (IOException e)
    {
        throw new CMSException("parsing exception: " + e.getMessage(), e);
    }
}
项目:ipack    文件:CMSSignedDataParser.java   
private static void pipeEncapsulatedOctetString(ContentInfoParser encapContentInfo,
        OutputStream rawOutputStream) throws IOException
    {
        ASN1OctetStringParser octs = (ASN1OctetStringParser)
            encapContentInfo.getContent(BERTags.OCTET_STRING);

        if (octs != null)
        {
            pipeOctetString(octs, rawOutputStream);
        }

//        BERTaggedObjectParser contentObject = (BERTaggedObjectParser)encapContentInfo.getContentObject();
//        if (contentObject != null)
//        {
//            // Handle IndefiniteLengthInputStream safely
//            InputStream input = ASN1StreamParser.getSafeRawInputStream(contentObject.getContentStream(true));
//
//            // TODO BerTaggedObjectGenerator?
//            BEROutputStream berOut = new BEROutputStream(rawOutputStream);
//            berOut.write(DERTags.CONSTRUCTED | DERTags.TAGGED | 0);
//            berOut.write(0x80);
//
//            pipeRawOctetString(input, rawOutputStream);
//
//            berOut.write(0x00);
//            berOut.write(0x00);
//
//            input.close();
//        }
    }
项目:gwt-crypto    文件:CMSSignedDataParser.java   
private static void pipeEncapsulatedOctetString(ContentInfoParser encapContentInfo,
        OutputStream rawOutputStream) throws IOException
    {
        ASN1OctetStringParser octs = (ASN1OctetStringParser)
            encapContentInfo.getContent(BERTags.OCTET_STRING);

        if (octs != null)
        {
            pipeOctetString(octs, rawOutputStream);
        }

//        BERTaggedObjectParser contentObject = (BERTaggedObjectParser)encapContentInfo.getContentObject();
//        if (contentObject != null)
//        {
//            // Handle IndefiniteLengthInputStream safely
//            InputStream input = ASN1StreamParser.getSafeRawInputStream(contentObject.getContentStream(true));
//
//            // TODO BerTaggedObjectGenerator?
//            BEROutputStream berOut = new BEROutputStream(rawOutputStream);
//            berOut.write(DERTags.CONSTRUCTED | DERTags.TAGGED | 0);
//            berOut.write(0x80);
//
//            pipeRawOctetString(input, rawOutputStream);
//
//            berOut.write(0x00);
//            berOut.write(0x00);
//
//            input.close();
//        }
    }
项目:Aki-SSL    文件:CMSSignedDataParser.java   
private static void pipeEncapsulatedOctetString(ContentInfoParser encapContentInfo,
        OutputStream rawOutputStream) throws IOException
    {
        ASN1OctetStringParser octs = (ASN1OctetStringParser)
            encapContentInfo.getContent(BERTags.OCTET_STRING);

        if (octs != null)
        {
            pipeOctetString(octs, rawOutputStream);
        }

//        BERTaggedObjectParser contentObject = (BERTaggedObjectParser)encapContentInfo.getContentObject();
//        if (contentObject != null)
//        {
//            // Handle IndefiniteLengthInputStream safely
//            InputStream input = ASN1StreamParser.getSafeRawInputStream(contentObject.getContentStream(true));
//
//            // TODO BerTaggedObjectGenerator?
//            BEROutputStream berOut = new BEROutputStream(rawOutputStream);
//            berOut.write(DERTags.CONSTRUCTED | DERTags.TAGGED | 0);
//            berOut.write(0x80);
//
//            pipeRawOctetString(input, rawOutputStream);
//
//            berOut.write(0x00);
//            berOut.write(0x00);
//
//            input.close();
//        }
    }
项目:irma_future_id    文件:CMSSignedDataParser.java   
private static void pipeEncapsulatedOctetString(ContentInfoParser encapContentInfo,
        OutputStream rawOutputStream) throws IOException
    {
        ASN1OctetStringParser octs = (ASN1OctetStringParser)
            encapContentInfo.getContent(BERTags.OCTET_STRING);

        if (octs != null)
        {
            pipeOctetString(octs, rawOutputStream);
        }

//        BERTaggedObjectParser contentObject = (BERTaggedObjectParser)encapContentInfo.getContentObject();
//        if (contentObject != null)
//        {
//            // Handle IndefiniteLengthInputStream safely
//            InputStream input = ASN1StreamParser.getSafeRawInputStream(contentObject.getContentStream(true));
//
//            // TODO BerTaggedObjectGenerator?
//            BEROutputStream berOut = new BEROutputStream(rawOutputStream);
//            berOut.write(DERTags.CONSTRUCTED | DERTags.TAGGED | 0);
//            berOut.write(0x80);
//
//            pipeRawOctetString(input, rawOutputStream);
//
//            berOut.write(0x00);
//            berOut.write(0x00);
//
//            input.close();
//        }
    }
项目:irma_future_id    文件:CMSSignedDataParser.java   
private static void pipeEncapsulatedOctetString(ContentInfoParser encapContentInfo,
        OutputStream rawOutputStream) throws IOException
    {
        ASN1OctetStringParser octs = (ASN1OctetStringParser)
            encapContentInfo.getContent(BERTags.OCTET_STRING);

        if (octs != null)
        {
            pipeOctetString(octs, rawOutputStream);
        }

//        BERTaggedObjectParser contentObject = (BERTaggedObjectParser)encapContentInfo.getContentObject();
//        if (contentObject != null)
//        {
//            // Handle IndefiniteLengthInputStream safely
//            InputStream input = ASN1StreamParser.getSafeRawInputStream(contentObject.getContentStream(true));
//
//            // TODO BerTaggedObjectGenerator?
//            BEROutputStream berOut = new BEROutputStream(rawOutputStream);
//            berOut.write(DERTags.CONSTRUCTED | DERTags.TAGGED | 0);
//            berOut.write(0x80);
//
//            pipeRawOctetString(input, rawOutputStream);
//
//            berOut.write(0x00);
//            berOut.write(0x00);
//
//            input.close();
//        }
    }
项目:irma_future_id    文件:CMSSignedDataParser.java   
private static void pipeEncapsulatedOctetString(ContentInfoParser encapContentInfo,
        OutputStream rawOutputStream) throws IOException
    {
        ASN1OctetStringParser octs = (ASN1OctetStringParser)
            encapContentInfo.getContent(BERTags.OCTET_STRING);

        if (octs != null)
        {
            pipeOctetString(octs, rawOutputStream);
        }

//        BERTaggedObjectParser contentObject = (BERTaggedObjectParser)encapContentInfo.getContentObject();
//        if (contentObject != null)
//        {
//            // Handle IndefiniteLengthInputStream safely
//            InputStream input = ASN1StreamParser.getSafeRawInputStream(contentObject.getContentStream(true));
//
//            // TODO BerTaggedObjectGenerator?
//            BEROutputStream berOut = new BEROutputStream(rawOutputStream);
//            berOut.write(DERTags.CONSTRUCTED | DERTags.TAGGED | 0);
//            berOut.write(0x80);
//
//            pipeRawOctetString(input, rawOutputStream);
//
//            berOut.write(0x00);
//            berOut.write(0x00);
//
//            input.close();
//        }
    }
项目:irma_future_id    文件:CMSSignedDataParser.java   
private static void pipeEncapsulatedOctetString(ContentInfoParser encapContentInfo,
        OutputStream rawOutputStream) throws IOException
    {
        ASN1OctetStringParser octs = (ASN1OctetStringParser)
            encapContentInfo.getContent(BERTags.OCTET_STRING);

        if (octs != null)
        {
            pipeOctetString(octs, rawOutputStream);
        }

//        BERTaggedObjectParser contentObject = (BERTaggedObjectParser)encapContentInfo.getContentObject();
//        if (contentObject != null)
//        {
//            // Handle IndefiniteLengthInputStream safely
//            InputStream input = ASN1StreamParser.getSafeRawInputStream(contentObject.getContentStream(true));
//
//            // TODO BerTaggedObjectGenerator?
//            BEROutputStream berOut = new BEROutputStream(rawOutputStream);
//            berOut.write(DERTags.CONSTRUCTED | DERTags.TAGGED | 0);
//            berOut.write(0x80);
//
//            pipeRawOctetString(input, rawOutputStream);
//
//            berOut.write(0x00);
//            berOut.write(0x00);
//
//            input.close();
//        }
    }
项目:bc-java    文件:CMSSignedDataParser.java   
private static void pipeEncapsulatedOctetString(ContentInfoParser encapContentInfo,
        OutputStream rawOutputStream) throws IOException
    {
        ASN1OctetStringParser octs = (ASN1OctetStringParser)
            encapContentInfo.getContent(BERTags.OCTET_STRING);

        if (octs != null)
        {
            pipeOctetString(octs, rawOutputStream);
        }

//        BERTaggedObjectParser contentObject = (BERTaggedObjectParser)encapContentInfo.getContentObject();
//        if (contentObject != null)
//        {
//            // Handle IndefiniteLengthInputStream safely
//            InputStream input = ASN1StreamParser.getSafeRawInputStream(contentObject.getContentStream(true));
//
//            // TODO BerTaggedObjectGenerator?
//            BEROutputStream berOut = new BEROutputStream(rawOutputStream);
//            berOut.write(DERTags.CONSTRUCTED | DERTags.TAGGED | 0);
//            berOut.write(0x80);
//
//            pipeRawOctetString(input, rawOutputStream);
//
//            berOut.write(0x00);
//            berOut.write(0x00);
//
//            input.close();
//        }
    }
项目:bc-java    文件:CMSSignedDataParser.java   
private static void pipeEncapsulatedOctetString(ContentInfoParser encapContentInfo,
        OutputStream rawOutputStream) throws IOException
    {
        ASN1OctetStringParser octs = (ASN1OctetStringParser)
            encapContentInfo.getContent(BERTags.OCTET_STRING);

        if (octs != null)
        {
            pipeOctetString(octs, rawOutputStream);
        }

//        BERTaggedObjectParser contentObject = (BERTaggedObjectParser)encapContentInfo.getContentObject();
//        if (contentObject != null)
//        {
//            // Handle IndefiniteLengthInputStream safely
//            InputStream input = ASN1StreamParser.getSafeRawInputStream(contentObject.getContentStream(true));
//
//            // TODO BerTaggedObjectGenerator?
//            BEROutputStream berOut = new BEROutputStream(rawOutputStream);
//            berOut.write(DERTags.CONSTRUCTED | DERTags.TAGGED | 0);
//            berOut.write(0x80);
//
//            pipeRawOctetString(input, rawOutputStream);
//
//            berOut.write(0x00);
//            berOut.write(0x00);
//
//            input.close();
//        }
    }
项目:bc-java    文件:CMSSignedDataParser.java   
private static void pipeEncapsulatedOctetString(ContentInfoParser encapContentInfo,
        OutputStream rawOutputStream) throws IOException
    {
        ASN1OctetStringParser octs = (ASN1OctetStringParser)
            encapContentInfo.getContent(BERTags.OCTET_STRING);

        if (octs != null)
        {
            pipeOctetString(octs, rawOutputStream);
        }

//        BERTaggedObjectParser contentObject = (BERTaggedObjectParser)encapContentInfo.getContentObject();
//        if (contentObject != null)
//        {
//            // Handle IndefiniteLengthInputStream safely
//            InputStream input = ASN1StreamParser.getSafeRawInputStream(contentObject.getContentStream(true));
//
//            // TODO BerTaggedObjectGenerator?
//            BEROutputStream berOut = new BEROutputStream(rawOutputStream);
//            berOut.write(DERTags.CONSTRUCTED | DERTags.TAGGED | 0);
//            berOut.write(0x80);
//
//            pipeRawOctetString(input, rawOutputStream);
//
//            berOut.write(0x00);
//            berOut.write(0x00);
//
//            input.close();
//        }
    }
项目:bc-java    文件:CMSSignedDataParser.java   
private static void pipeEncapsulatedOctetString(ContentInfoParser encapContentInfo,
        OutputStream rawOutputStream) throws IOException
    {
        ASN1OctetStringParser octs = (ASN1OctetStringParser)
            encapContentInfo.getContent(BERTags.OCTET_STRING);

        if (octs != null)
        {
            pipeOctetString(octs, rawOutputStream);
        }

//        BERTaggedObjectParser contentObject = (BERTaggedObjectParser)encapContentInfo.getContentObject();
//        if (contentObject != null)
//        {
//            // Handle IndefiniteLengthInputStream safely
//            InputStream input = ASN1StreamParser.getSafeRawInputStream(contentObject.getContentStream(true));
//
//            // TODO BerTaggedObjectGenerator?
//            BEROutputStream berOut = new BEROutputStream(rawOutputStream);
//            berOut.write(DERTags.CONSTRUCTED | DERTags.TAGGED | 0);
//            berOut.write(0x80);
//
//            pipeRawOctetString(input, rawOutputStream);
//
//            berOut.write(0x00);
//            berOut.write(0x00);
//
//            input.close();
//        }
    }
项目:irma_future_id    文件:ParseTest.java   
private void parseEnveloped(byte[] data) throws IOException
{
    ASN1StreamParser aIn = new ASN1StreamParser(data);

    ContentInfoParser cP = new ContentInfoParser((ASN1SequenceParser)aIn.readObject());

    EnvelopedDataParser eP = new EnvelopedDataParser((ASN1SequenceParser)cP.getContent(BERTags.SEQUENCE));

    eP.getRecipientInfos().toASN1Primitive(); // Must drain the parser!

    EncryptedContentInfoParser ecP = eP.getEncryptedContentInfo();

    ASN1OctetStringParser content = (ASN1OctetStringParser)ecP.getEncryptedContent(BERTags.OCTET_STRING);

    Streams.drain(content.getOctetStream());
}
项目:irma_future_id    文件:OctetStringTest.java   
public void testNestedStructure()
    throws Exception
{
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();

    BERSequenceGenerator sGen = new BERSequenceGenerator(bOut);

    sGen.addObject(new DERObjectIdentifier(CMSObjectIdentifiers.compressedData.getId()));

    BERSequenceGenerator cGen = new BERSequenceGenerator(sGen.getRawOutputStream(), 0, true);

    cGen.addObject(new DERInteger(0));

    //
    // AlgorithmIdentifier
    //
    DERSequenceGenerator algGen = new DERSequenceGenerator(cGen.getRawOutputStream());

    algGen.addObject(new DERObjectIdentifier("1.2"));

    algGen.close();

    //
    // Encapsulated ContentInfo
    //
    BERSequenceGenerator eiGen = new BERSequenceGenerator(cGen.getRawOutputStream());

    eiGen.addObject(new DERObjectIdentifier("1.1"));

    BEROctetStringGenerator octGen = new BEROctetStringGenerator(eiGen.getRawOutputStream(), 0, true);

    //
    // output containing zeroes
    //
    OutputStream out = octGen.getOctetOutputStream();

    out.write(new byte[] { 1, 2, 3, 4 });
    out.write(new byte[4]);
    out.write(new byte[20]);

    out.close();
    eiGen.close();
    cGen.close();
    sGen.close();

    //
    // reading back
    //
    ASN1StreamParser aIn = new ASN1StreamParser(bOut.toByteArray());

    ContentInfoParser cp = new ContentInfoParser((ASN1SequenceParser)aIn.readObject());

    CompressedDataParser comData = new CompressedDataParser((ASN1SequenceParser)cp.getContent(BERTags.SEQUENCE));
    ContentInfoParser     content = comData.getEncapContentInfo();

    ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(BERTags.OCTET_STRING);

    InputStream in = bytes.getOctetStream();
    int         count = 0;

    while (in.read() >= 0)
    {
        count++;
    }

    assertEquals(28, count);
}
项目:bc-java    文件:ParseTest.java   
private void parseEnveloped(byte[] data) throws IOException
{
    ASN1StreamParser aIn = new ASN1StreamParser(data);

    ContentInfoParser cP = new ContentInfoParser((ASN1SequenceParser)aIn.readObject());

    EnvelopedDataParser eP = new EnvelopedDataParser((ASN1SequenceParser)cP.getContent(BERTags.SEQUENCE));

    eP.getRecipientInfos().toASN1Primitive(); // Must drain the parser!

    EncryptedContentInfoParser ecP = eP.getEncryptedContentInfo();

    ASN1OctetStringParser content = (ASN1OctetStringParser)ecP.getEncryptedContent(BERTags.OCTET_STRING);

    Streams.drain(content.getOctetStream());
}
项目:bc-java    文件:OctetStringTest.java   
public void testNestedStructure()
    throws Exception
{
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();

    BERSequenceGenerator sGen = new BERSequenceGenerator(bOut);

    sGen.addObject(new DERObjectIdentifier(CMSObjectIdentifiers.compressedData.getId()));

    BERSequenceGenerator cGen = new BERSequenceGenerator(sGen.getRawOutputStream(), 0, true);

    cGen.addObject(new DERInteger(0));

    //
    // AlgorithmIdentifier
    //
    DERSequenceGenerator algGen = new DERSequenceGenerator(cGen.getRawOutputStream());

    algGen.addObject(new DERObjectIdentifier("1.2"));

    algGen.close();

    //
    // Encapsulated ContentInfo
    //
    BERSequenceGenerator eiGen = new BERSequenceGenerator(cGen.getRawOutputStream());

    eiGen.addObject(new DERObjectIdentifier("1.1"));

    BEROctetStringGenerator octGen = new BEROctetStringGenerator(eiGen.getRawOutputStream(), 0, true);

    //
    // output containing zeroes
    //
    OutputStream out = octGen.getOctetOutputStream();

    out.write(new byte[] { 1, 2, 3, 4 });
    out.write(new byte[4]);
    out.write(new byte[20]);

    out.close();
    eiGen.close();
    cGen.close();
    sGen.close();

    //
    // reading back
    //
    ASN1StreamParser aIn = new ASN1StreamParser(bOut.toByteArray());

    ContentInfoParser cp = new ContentInfoParser((ASN1SequenceParser)aIn.readObject());

    CompressedDataParser comData = new CompressedDataParser((ASN1SequenceParser)cp.getContent(BERTags.SEQUENCE));
    ContentInfoParser     content = comData.getEncapContentInfo();

    ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(BERTags.OCTET_STRING);

    InputStream in = bytes.getOctetStream();
    int         count = 0;

    while (in.read() >= 0)
    {
        count++;
    }

    assertEquals(28, count);
}