public CmsAuthenticatedDataOutputStream( MacCalculator macCalculator, DigestCalculator digestCalculator, ASN1ObjectIdentifier contentType, OutputStream dataStream, BERSequenceGenerator cGen, BERSequenceGenerator envGen, BERSequenceGenerator eiGen) { this.macCalculator = macCalculator; this.digestCalculator = digestCalculator; this.contentType = contentType; this.dataStream = dataStream; this.cGen = cGen; this.envGen = envGen; this.eiGen = eiGen; }
public CmsSignedDataOutputStream( OutputStream out, ASN1ObjectIdentifier contentOID, BERSequenceGenerator sGen, BERSequenceGenerator sigGen, BERSequenceGenerator eiGen) { _out = out; _contentOID = contentOID; _sGen = sGen; _sigGen = sigGen; _eiGen = eiGen; }
public CmsEnvelopedDataOutputStream( OutputStream out, BERSequenceGenerator cGen, BERSequenceGenerator envGen, BERSequenceGenerator eiGen) { _out = out; _cGen = cGen; _envGen = envGen; _eiGen = eiGen; }
/** * @deprecated use open(OutputStream, ASN1ObjectIdentifier, ContentCompressor) */ public OutputStream open( OutputStream out, String contentOID, String compressionOID) throws IOException { BERSequenceGenerator sGen = new BERSequenceGenerator(out); sGen.addObject(CMSObjectIdentifiers.compressedData); // // Compressed Data // BERSequenceGenerator cGen = new BERSequenceGenerator(sGen.getRawOutputStream(), 0, true); cGen.addObject(new ASN1Integer(0)); // // AlgorithmIdentifier // DERSequenceGenerator algGen = new DERSequenceGenerator(cGen.getRawOutputStream()); algGen.addObject(new ASN1ObjectIdentifier(ZLIB)); algGen.close(); // // Encapsulated ContentInfo // BERSequenceGenerator eiGen = new BERSequenceGenerator(cGen.getRawOutputStream()); eiGen.addObject(new ASN1ObjectIdentifier(contentOID)); OutputStream octetStream = CMSUtils.createBEROctetOutputStream( eiGen.getRawOutputStream(), 0, true, _bufferSize); return new CmsCompressedOutputStream( new DeflaterOutputStream(octetStream), sGen, cGen, eiGen); }
/** * Open a compressing output stream. * * @param contentOID * @param out * @param compressor * @return * @throws IOException */ public OutputStream open( ASN1ObjectIdentifier contentOID, OutputStream out, OutputCompressor compressor) throws IOException { BERSequenceGenerator sGen = new BERSequenceGenerator(out); sGen.addObject(CMSObjectIdentifiers.compressedData); // // Compressed Data // BERSequenceGenerator cGen = new BERSequenceGenerator(sGen.getRawOutputStream(), 0, true); cGen.addObject(new ASN1Integer(0)); // // AlgorithmIdentifier // cGen.addObject(compressor.getAlgorithmIdentifier()); // // Encapsulated ContentInfo // BERSequenceGenerator eiGen = new BERSequenceGenerator(cGen.getRawOutputStream()); eiGen.addObject(contentOID); OutputStream octetStream = CMSUtils.createBEROctetOutputStream( eiGen.getRawOutputStream(), 0, true, _bufferSize); return new CmsCompressedOutputStream( compressor.getOutputStream(octetStream), sGen, cGen, eiGen); }
CmsCompressedOutputStream( OutputStream out, BERSequenceGenerator sGen, BERSequenceGenerator cGen, BERSequenceGenerator eiGen) { _out = out; _sGen = sGen; _cGen = cGen; _eiGen = eiGen; }
/** * Open a compressing output stream. * * @param contentOID the content type OID. * @param out the stream to encode to. * @param compressor the type of compressor to use. * @return an output stream to write the data be compressed to. * @throws IOException */ public OutputStream open( ASN1ObjectIdentifier contentOID, OutputStream out, OutputCompressor compressor) throws IOException { BERSequenceGenerator sGen = new BERSequenceGenerator(out); sGen.addObject(CMSObjectIdentifiers.compressedData); // // Compressed Data // BERSequenceGenerator cGen = new BERSequenceGenerator(sGen.getRawOutputStream(), 0, true); cGen.addObject(new ASN1Integer(0)); // // AlgorithmIdentifier // cGen.addObject(compressor.getAlgorithmIdentifier()); // // Encapsulated ContentInfo // BERSequenceGenerator eiGen = new BERSequenceGenerator(cGen.getRawOutputStream()); eiGen.addObject(contentOID); OutputStream octetStream = CMSUtils.createBEROctetOutputStream( eiGen.getRawOutputStream(), 0, true, _bufferSize); return new CmsCompressedOutputStream( compressor.getOutputStream(octetStream), sGen, cGen, eiGen); }
public void testBERWriting() throws Exception { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); BERSequenceGenerator seqGen = new BERSequenceGenerator(bOut); seqGen.addObject(new DERInteger(BigInteger.valueOf(0))); seqGen.addObject(new DERObjectIdentifier("1.1")); seqGen.close(); assertTrue("basic BER writing test failed.", Arrays.equals(berSeqData, bOut.toByteArray())); }
public void testBERExplicitTaggedSequenceWriting() throws Exception { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); BERSequenceGenerator seqGen = new BERSequenceGenerator(bOut, 1, true); seqGen.addObject(new DERInteger(BigInteger.valueOf(0))); seqGen.addObject(new DERObjectIdentifier("1.1")); seqGen.close(); assertTrue("explicit BER tag writing test failed.", Arrays.equals(berExpTagSeqData, bOut.toByteArray())); }
protected OutputStream open( ASN1ObjectIdentifier dataType, OutputStream out, ASN1EncodableVector recipientInfos, OutputEncryptor encryptor) throws IOException { // // ContentInfo // BERSequenceGenerator cGen = new BERSequenceGenerator(out); cGen.addObject(CMSObjectIdentifiers.envelopedData); // // Encrypted Data // BERSequenceGenerator envGen = new BERSequenceGenerator(cGen.getRawOutputStream(), 0, true); envGen.addObject(getVersion()); if (originatorInfo != null) { envGen.addObject(new DERTaggedObject(false, 0, originatorInfo)); } if (_berEncodeRecipientSet) { envGen.getRawOutputStream().write(new BERSet(recipientInfos).getEncoded()); } else { envGen.getRawOutputStream().write(new DERSet(recipientInfos).getEncoded()); } BERSequenceGenerator eiGen = new BERSequenceGenerator(envGen.getRawOutputStream()); eiGen.addObject(dataType); AlgorithmIdentifier encAlgId = encryptor.getAlgorithmIdentifier(); eiGen.getRawOutputStream().write(encAlgId.getEncoded()); OutputStream octetStream = CMSUtils.createBEROctetOutputStream( eiGen.getRawOutputStream(), 0, false, _bufferSize); OutputStream cOut = encryptor.getOutputStream(octetStream); return new CmsEnvelopedDataOutputStream(cOut, cGen, envGen, eiGen); }