Java 类org.bouncycastle.asn1.ASN1OctetStringParser 实例源码

项目:ipack    文件:TimeStampedDataParser.java   
private TimeStampedDataParser(ASN1SequenceParser parser)
    throws IOException
{
    this.parser = parser;
    this.version = ASN1Integer.getInstance(parser.readObject());

    ASN1Encodable obj = parser.readObject();

    if (obj instanceof DERIA5String)
    {
        this.dataUri = DERIA5String.getInstance(obj);
        obj = parser.readObject();
    }
    if (obj instanceof MetaData || obj instanceof ASN1SequenceParser)
    {
        this.metaData = MetaData.getInstance(obj.toASN1Primitive());
        obj = parser.readObject();
    }
    if (obj instanceof ASN1OctetStringParser)
    {
        this.content = (ASN1OctetStringParser)obj;
    }
}
项目: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);
    }
}
项目:gwt-crypto    文件:TimeStampedDataParser.java   
private TimeStampedDataParser(ASN1SequenceParser parser)
    throws IOException
{
    this.parser = parser;
    this.version = ASN1Integer.getInstance(parser.readObject());

    ASN1Encodable obj = parser.readObject();

    if (obj instanceof DERIA5String)
    {
        this.dataUri = DERIA5String.getInstance(obj);
        obj = parser.readObject();
    }
    if (obj instanceof MetaData || obj instanceof ASN1SequenceParser)
    {
        this.metaData = MetaData.getInstance(obj.toASN1Primitive());
        obj = parser.readObject();
    }
    if (obj instanceof ASN1OctetStringParser)
    {
        this.content = (ASN1OctetStringParser)obj;
    }
}
项目: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);
    }
}
项目:Aki-SSL    文件:TimeStampedDataParser.java   
private TimeStampedDataParser(ASN1SequenceParser parser)
    throws IOException
{
    this.parser = parser;
    this.version = ASN1Integer.getInstance(parser.readObject());

    ASN1Encodable obj = parser.readObject();

    if (obj instanceof DERIA5String)
    {
        this.dataUri = DERIA5String.getInstance(obj);
        obj = parser.readObject();
    }
    if (obj instanceof MetaData || obj instanceof ASN1SequenceParser)
    {
        this.metaData = MetaData.getInstance(obj.toASN1Primitive());
        obj = parser.readObject();
    }
    if (obj instanceof ASN1OctetStringParser)
    {
        this.content = (ASN1OctetStringParser)obj;
    }
}
项目: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);
    }
}
项目:TinyTravelTracker    文件:TimeStampedDataParser.java   
private TimeStampedDataParser(ASN1SequenceParser parser)
    throws IOException
{
    this.parser = parser;
    this.version = ASN1Integer.getInstance(parser.readObject());

    ASN1Encodable obj = parser.readObject();

    if (obj instanceof DERIA5String)
    {
        this.dataUri = DERIA5String.getInstance(obj);
        obj = parser.readObject();
    }
    if (obj instanceof MetaData || obj instanceof ASN1SequenceParser)
    {
        this.metaData = MetaData.getInstance(obj.toASN1Primitive());
        obj = parser.readObject();
    }
    if (obj instanceof ASN1OctetStringParser)
    {
        this.content = (ASN1OctetStringParser)obj;
    }
}
项目:CryptMeme    文件:TimeStampedDataParser.java   
private TimeStampedDataParser(ASN1SequenceParser parser)
    throws IOException
{
    this.parser = parser;
    this.version = ASN1Integer.getInstance(parser.readObject());

    ASN1Encodable obj = parser.readObject();

    if (obj instanceof DERIA5String)
    {
        this.dataUri = DERIA5String.getInstance(obj);
        obj = parser.readObject();
    }
    if (obj instanceof MetaData || obj instanceof ASN1SequenceParser)
    {
        this.metaData = MetaData.getInstance(obj.toASN1Primitive());
        obj = parser.readObject();
    }
    if (obj instanceof ASN1OctetStringParser)
    {
        this.content = (ASN1OctetStringParser)obj;
    }
}
项目: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    文件:TimeStampedDataParser.java   
private TimeStampedDataParser(ASN1SequenceParser parser)
    throws IOException
{
    this.parser = parser;
    this.version = ASN1Integer.getInstance(parser.readObject());

    ASN1Encodable obj = parser.readObject();

    if (obj instanceof DERIA5String)
    {
        this.dataUri = DERIA5String.getInstance(obj);
        obj = parser.readObject();
    }
    if (obj instanceof MetaData || obj instanceof ASN1SequenceParser)
    {
        this.metaData = MetaData.getInstance(obj.toASN1Primitive());
        obj = parser.readObject();
    }
    if (obj instanceof ASN1OctetStringParser)
    {
        this.content = (ASN1OctetStringParser)obj;
    }
}
项目: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    文件:TimeStampedDataParser.java   
private TimeStampedDataParser(ASN1SequenceParser parser)
    throws IOException
{
    this.parser = parser;
    this.version = ASN1Integer.getInstance(parser.readObject());

    ASN1Encodable obj = parser.readObject();

    if (obj instanceof DERIA5String)
    {
        this.dataUri = DERIA5String.getInstance(obj);
        obj = parser.readObject();
    }
    if (obj instanceof MetaData || obj instanceof ASN1SequenceParser)
    {
        this.metaData = MetaData.getInstance(obj.toASN1Primitive());
        obj = parser.readObject();
    }
    if (obj instanceof ASN1OctetStringParser)
    {
        this.content = (ASN1OctetStringParser)obj;
    }
}
项目: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();
//        }
    }
项目:ipack    文件:CMSSignedDataParser.java   
private static void pipeOctetString(
    ASN1OctetStringParser octs,
    OutputStream          output)
    throws IOException
{
    // TODO Allow specification of a specific fragment size?
    OutputStream outOctets = CMSUtils.createBEROctetOutputStream(
        output, 0, true, 0);
    Streams.pipeAll(octs.getOctetStream(), outOctets);
    outOctets.close();
}
项目:ipack    文件:CMSEnvelopedDataParser.java   
public CMSEnvelopedDataParser(
    InputStream    envelopedData) 
    throws CMSException, IOException
{
    super(envelopedData);

    this.attrNotRead = true;
    this.envelopedData = new EnvelopedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));

    // TODO Validate version?
    //DERInteger version = this._envelopedData.getVersion();

    OriginatorInfo info = this.envelopedData.getOriginatorInfo();

    if (info != null)
    {
        this.originatorInfo = new OriginatorInformation(info);
    }

    //
    // read the recipients
    //
    ASN1Set recipientInfos = ASN1Set.getInstance(this.envelopedData.getRecipientInfos().toASN1Primitive());

    //
    // read the encrypted content info
    //
    EncryptedContentInfoParser encInfo = this.envelopedData.getEncryptedContentInfo();
    this.encAlg = encInfo.getContentEncryptionAlgorithm();
    CMSReadable readable = new CMSProcessableInputStream(
        ((ASN1OctetStringParser)encInfo.getEncryptedContent(BERTags.OCTET_STRING)).getOctetStream());
    CMSSecureReadable secureReadable = new CMSEnvelopedHelper.CMSEnvelopedSecureReadable(
        this.encAlg, readable);

    //
    // build the RecipientInformationStore
    //
    this.recipientInfoStore = CMSEnvelopedHelper.buildRecipientInformationStore(
        recipientInfos, this.encAlg, secureReadable);
}
项目: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();
//        }
    }
项目:gwt-crypto    文件:CMSSignedDataParser.java   
private static void pipeOctetString(
    ASN1OctetStringParser octs,
    OutputStream          output)
    throws IOException
{
    // TODO Allow specification of a specific fragment size?
    OutputStream outOctets = CMSUtils.createBEROctetOutputStream(
        output, 0, true, 0);
    Streams.pipeAll(octs.getOctetStream(), outOctets);
    outOctets.close();
}
项目:gwt-crypto    文件:CMSEnvelopedDataParser.java   
public CMSEnvelopedDataParser(
    InputStream    envelopedData) 
    throws CMSException, IOException
{
    super(envelopedData);

    this.attrNotRead = true;
    this.envelopedData = new EnvelopedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));

    // TODO Validate version?
    //ASN1Integer version = this._envelopedData.getVersion();

    OriginatorInfo info = this.envelopedData.getOriginatorInfo();

    if (info != null)
    {
        this.originatorInfo = new OriginatorInformation(info);
    }

    //
    // read the recipients
    //
    ASN1Set recipientInfos = ASN1Set.getInstance(this.envelopedData.getRecipientInfos().toASN1Primitive());

    //
    // read the encrypted content info
    //
    EncryptedContentInfoParser encInfo = this.envelopedData.getEncryptedContentInfo();
    this.encAlg = encInfo.getContentEncryptionAlgorithm();
    CMSReadable readable = new CMSProcessableInputStream(
        ((ASN1OctetStringParser)encInfo.getEncryptedContent(BERTags.OCTET_STRING)).getOctetStream());
    CMSSecureReadable secureReadable = new CMSEnvelopedHelper.CMSEnvelopedSecureReadable(
        this.encAlg, readable);

    //
    // build the RecipientInformationStore
    //
    this.recipientInfoStore = CMSEnvelopedHelper.buildRecipientInformationStore(
        recipientInfos, this.encAlg, secureReadable);
}
项目: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();
//        }
    }
项目:Aki-SSL    文件:CMSSignedDataParser.java   
private static void pipeOctetString(
    ASN1OctetStringParser octs,
    OutputStream          output)
    throws IOException
{
    // TODO Allow specification of a specific fragment size?
    OutputStream outOctets = CMSUtils.createBEROctetOutputStream(
        output, 0, true, 0);
    Streams.pipeAll(octs.getOctetStream(), outOctets);
    outOctets.close();
}
项目:Aki-SSL    文件:CMSEnvelopedDataParser.java   
public CMSEnvelopedDataParser(
    InputStream    envelopedData) 
    throws CMSException, IOException
{
    super(envelopedData);

    this.attrNotRead = true;
    this.envelopedData = new EnvelopedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));

    // TODO Validate version?
    //ASN1Integer version = this._envelopedData.getVersion();

    OriginatorInfo info = this.envelopedData.getOriginatorInfo();

    if (info != null)
    {
        this.originatorInfo = new OriginatorInformation(info);
    }

    //
    // read the recipients
    //
    ASN1Set recipientInfos = ASN1Set.getInstance(this.envelopedData.getRecipientInfos().toASN1Primitive());

    //
    // read the encrypted content info
    //
    EncryptedContentInfoParser encInfo = this.envelopedData.getEncryptedContentInfo();
    this.encAlg = encInfo.getContentEncryptionAlgorithm();
    CMSReadable readable = new CMSProcessableInputStream(
        ((ASN1OctetStringParser)encInfo.getEncryptedContent(BERTags.OCTET_STRING)).getOctetStream());
    CMSSecureReadable secureReadable = new CMSEnvelopedHelper.CMSEnvelopedSecureReadable(
        this.encAlg, readable);

    //
    // build the RecipientInformationStore
    //
    this.recipientInfoStore = CMSEnvelopedHelper.buildRecipientInformationStore(
        recipientInfos, this.encAlg, secureReadable);
}
项目: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 pipeOctetString(
    ASN1OctetStringParser octs,
    OutputStream          output)
    throws IOException
{
    // TODO Allow specification of a specific fragment size?
    OutputStream outOctets = CMSUtils.createBEROctetOutputStream(
        output, 0, true, 0);
    Streams.pipeAll(octs.getOctetStream(), outOctets);
    outOctets.close();
}
项目:irma_future_id    文件:CMSEnvelopedDataParser.java   
public CMSEnvelopedDataParser(
    InputStream    envelopedData) 
    throws CMSException, IOException
{
    super(envelopedData);

    this.attrNotRead = true;
    this.envelopedData = new EnvelopedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));

    // TODO Validate version?
    //DERInteger version = this._envelopedData.getVersion();

    OriginatorInfo info = this.envelopedData.getOriginatorInfo();

    if (info != null)
    {
        this.originatorInfo = new OriginatorInformation(info);
    }

    //
    // read the recipients
    //
    ASN1Set recipientInfos = ASN1Set.getInstance(this.envelopedData.getRecipientInfos().toASN1Primitive());

    //
    // read the encrypted content info
    //
    EncryptedContentInfoParser encInfo = this.envelopedData.getEncryptedContentInfo();
    this.encAlg = encInfo.getContentEncryptionAlgorithm();
    CMSReadable readable = new CMSProcessableInputStream(
        ((ASN1OctetStringParser)encInfo.getEncryptedContent(BERTags.OCTET_STRING)).getOctetStream());
    CMSSecureReadable secureReadable = new CMSEnvelopedHelper.CMSEnvelopedSecureReadable(
        this.encAlg, readable);

    //
    // build the RecipientInformationStore
    //
    this.recipientInfoStore = CMSEnvelopedHelper.buildRecipientInformationStore(
        recipientInfos, this.encAlg, secureReadable);
}
项目: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 pipeOctetString(
    ASN1OctetStringParser octs,
    OutputStream          output)
    throws IOException
{
    // TODO Allow specification of a specific fragment size?
    OutputStream outOctets = CMSUtils.createBEROctetOutputStream(
        output, 0, true, 0);
    Streams.pipeAll(octs.getOctetStream(), outOctets);
    outOctets.close();
}
项目:irma_future_id    文件:CMSEnvelopedDataParser.java   
public CMSEnvelopedDataParser(
    InputStream    envelopedData) 
    throws CMSException, IOException
{
    super(envelopedData);

    this.attrNotRead = true;
    this.envelopedData = new EnvelopedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));

    // TODO Validate version?
    //DERInteger version = this._envelopedData.getVersion();

    OriginatorInfo info = this.envelopedData.getOriginatorInfo();

    if (info != null)
    {
        this.originatorInfo = new OriginatorInformation(info);
    }

    //
    // read the recipients
    //
    ASN1Set recipientInfos = ASN1Set.getInstance(this.envelopedData.getRecipientInfos().toASN1Primitive());

    //
    // read the encrypted content info
    //
    EncryptedContentInfoParser encInfo = this.envelopedData.getEncryptedContentInfo();
    this.encAlg = encInfo.getContentEncryptionAlgorithm();
    CMSReadable readable = new CMSProcessableInputStream(
        ((ASN1OctetStringParser)encInfo.getEncryptedContent(BERTags.OCTET_STRING)).getOctetStream());
    CMSSecureReadable secureReadable = new CMSEnvelopedHelper.CMSEnvelopedSecureReadable(
        this.encAlg, readable);

    //
    // build the RecipientInformationStore
    //
    this.recipientInfoStore = CMSEnvelopedHelper.buildRecipientInformationStore(
        recipientInfos, this.encAlg, secureReadable);
}
项目: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 pipeOctetString(
    ASN1OctetStringParser octs,
    OutputStream          output)
    throws IOException
{
    // TODO Allow specification of a specific fragment size?
    OutputStream outOctets = CMSUtils.createBEROctetOutputStream(
        output, 0, true, 0);
    Streams.pipeAll(octs.getOctetStream(), outOctets);
    outOctets.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 pipeOctetString(
    ASN1OctetStringParser octs,
    OutputStream          output)
    throws IOException
{
    // TODO Allow specification of a specific fragment size?
    OutputStream outOctets = CMSUtils.createBEROctetOutputStream(
        output, 0, true, 0);
    Streams.pipeAll(octs.getOctetStream(), outOctets);
    outOctets.close();
}
项目:irma_future_id    文件:OctetStringTest.java   
public void testReadingWriting()
    throws Exception
{
   ByteArrayOutputStream bOut = new ByteArrayOutputStream();
   BEROctetStringGenerator octGen = new BEROctetStringGenerator(bOut);

   OutputStream out = octGen.getOctetOutputStream();

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

   out.close();

   ASN1StreamParser aIn = new ASN1StreamParser(bOut.toByteArray());

   ASN1OctetStringParser s = (ASN1OctetStringParser)aIn.readObject();

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

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

   assertEquals(8, count);
}
项目:irma_future_id    文件:OctetStringTest.java   
public void testReadingWritingZeroInLength()
    throws Exception
{
   ByteArrayOutputStream bOut = new ByteArrayOutputStream();
   BEROctetStringGenerator octGen = new BEROctetStringGenerator(bOut);

   OutputStream out = octGen.getOctetOutputStream();

   out.write(new byte[] { 1, 2, 3, 4 });
   out.write(new byte[512]);  // forces a zero to appear in length

   out.close();

   ASN1StreamParser aIn = new ASN1StreamParser(bOut.toByteArray());

   ASN1OctetStringParser s = (ASN1OctetStringParser)aIn.readObject();

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

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

   assertEquals(516, count);
}
项目: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 pipeOctetString(
    ASN1OctetStringParser octs,
    OutputStream          output)
    throws IOException
{
    // TODO Allow specification of a specific fragment size?
    OutputStream outOctets = CMSUtils.createBEROctetOutputStream(
        output, 0, true, 0);
    Streams.pipeAll(octs.getOctetStream(), outOctets);
    outOctets.close();
}
项目:bc-java    文件:CMSEnvelopedDataParser.java   
public CMSEnvelopedDataParser(
    InputStream    envelopedData) 
    throws CMSException, IOException
{
    super(envelopedData);

    this.attrNotRead = true;
    this.envelopedData = new EnvelopedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));

    // TODO Validate version?
    //DERInteger version = this._envelopedData.getVersion();

    OriginatorInfo info = this.envelopedData.getOriginatorInfo();

    if (info != null)
    {
        this.originatorInfo = new OriginatorInformation(info);
    }

    //
    // read the recipients
    //
    ASN1Set recipientInfos = ASN1Set.getInstance(this.envelopedData.getRecipientInfos().toASN1Primitive());

    //
    // read the encrypted content info
    //
    EncryptedContentInfoParser encInfo = this.envelopedData.getEncryptedContentInfo();
    this.encAlg = encInfo.getContentEncryptionAlgorithm();
    CMSReadable readable = new CMSProcessableInputStream(
        ((ASN1OctetStringParser)encInfo.getEncryptedContent(BERTags.OCTET_STRING)).getOctetStream());
    CMSSecureReadable secureReadable = new CMSEnvelopedHelper.CMSEnvelopedSecureReadable(
        this.encAlg, readable);

    //
    // build the RecipientInformationStore
    //
    this.recipientInfoStore = CMSEnvelopedHelper.buildRecipientInformationStore(
        recipientInfos, this.encAlg, secureReadable);
}
项目: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();
//        }
    }