Exemplo n.º 1
0
            public void ProcessPOIFSWriterEvent(POIFSWriterEvent event1)
            {
                try
                {
                    LittleEndianOutputStream leos = new LittleEndianOutputStream(event1.Stream);

                    // StreamSize (8 bytes): An unsigned integer that specifies the number of bytes used by data
                    // encrypted within the EncryptedData field, not including the size of the StreamSize field.
                    // Note that the actual size of the \EncryptedPackage stream (1) can be larger than this
                    // value, depending on the block size of the chosen encryption algorithm
                    leos.WriteLong(countBytes);
                    long rawPos = rawStream.Position;
                    //FileStream fis = new FileStream(fileOut.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    IOUtils.Copy(rawStream, leos.out1);
                    //fis.Close();
                    rawStream.Position = rawPos;
                    //File.Delete(fileOut.FullName + ".copy");
                    fileOut.Delete();


                    leos.Close();
                }
                catch (IOException e)
                {
                    throw new EncryptedDocumentException(e);
                }
            }
Exemplo n.º 2
0
        public NPOIFSDocument(string name, int size, NPOIFSFileSystem filesystem, POIFSWriterListener Writer)
        {
            _filesystem = filesystem;

            if (size < POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE)
            {
                _stream     = new NPOIFSStream(filesystem.GetMiniStore());
                _block_size = _filesystem.GetMiniStore().GetBlockStoreBlockSize();
            }
            else
            {
                _stream     = new NPOIFSStream(filesystem);
                _block_size = _filesystem.GetBlockStoreBlockSize();
            }

            Stream innerOs            = _stream.GetOutputStream();
            DocumentOutputStream os   = new DocumentOutputStream(innerOs, size);
            POIFSDocumentPath    path = new POIFSDocumentPath(name.Split(new string[] { "\\\\" }, StringSplitOptions.RemoveEmptyEntries));
            string           docName  = path.GetComponent(path.Length - 1);
            POIFSWriterEvent event1   = new POIFSWriterEvent(os, path, docName, size);

            Writer.ProcessPOIFSWriterEvent(event1);
            innerOs.Dispose();

            // And build the property for it
            _property            = new DocumentProperty(name, size);
            _property.StartBlock = (/*setter*/ _stream.GetStartBlock());
        }
Exemplo n.º 3
0
            public void ProcessPOIFSWriterEvent(POIFSWriterEvent event1)
            {
                try {
                    DocumentOutputStream os = event1.Stream;
                    byte[] buf = new byte[stream.chunkSize];

                    // StreamSize (8 bytes): An unsigned integer that specifies the number of bytes used by data
                    // encrypted within the EncryptedData field, not including the size of the StreamSize field.
                    // Note that the actual size of the \EncryptedPackage stream (1) can be larger than this
                    // value, depending on the block size of the chosen encryption algorithm
                    LittleEndian.PutLong(buf, 0, stream._pos);
                    os.Write(buf, 0, LittleEndian.LONG_SIZE);

                    FileStream fis = stream.fileOut.Create();
                    int        readBytes;
                    while ((readBytes = fis.Read(buf, 0, buf.Length)) != -1)
                    {
                        os.Write(buf, 0, readBytes);
                    }
                    fis.Close();

                    os.Close();

                    stream.fileOut.Delete();
                } catch (IOException e) {
                    throw new EncryptedDocumentException(e);
                }
            }
Exemplo n.º 4
0
 public void ProcessPOIFSWriterEvent(POIFSWriterEvent event1)
 {
     try
     {
         event1.Stream.Write(buf, 0, event1.Limit);
     }
     catch (IOException e)
     {
         throw new EncryptedDocumentException(e);
     }
 }
Exemplo n.º 5
0
 public void ProcessPOIFSWriterEvent(POIFSWriterEvent ev)
 {
     try
     {
         ;
     }
     catch (IOException exception)
     {
         throw new Exception("Exception on write: " + exception.Message);
     }
 }
Exemplo n.º 6
0
 public void ProcessPOIFSWriterEvent(POIFSWriterEvent ev)
 {
     try
     {
         ev.Stream.Write(0);
         Console.WriteLine("Send an event");
     }
     catch (IOException exception)
     {
         throw new Exception("Exception on write: " + exception.Message);
     }
 }
Exemplo n.º 7
0
        /* **********  END  implementation of POIFSReaderListener ********** */
        /* ********** START implementation of POIFSWriterListener ********** */

        /**
         * Process a POIFSWriterEvent that this listener had registered
         * for
         *
         * @param evt the POIFSWriterEvent
         */

        public void ProcessPOIFSWriterEvent(POIFSWriterEvent evt)
        {
            try
            {
                DocumentDescriptor descriptor =
                    new DocumentDescriptor(evt.Path, evt.Name);

                Console.WriteLine("looking up document: " + descriptor + " ("
                                  + evt.Limit + " bytes)");
                evt.Stream.Write((byte[])dataMap[descriptor]);
            }
            catch (IOException)
            {
                Console.WriteLine("Unable to Write document");
                //e.printStackTrace();
                //System.exit(1);
                throw;
            }
        }
Exemplo n.º 8
0
 public void ProcessPOIFSWriterEvent(POIFSWriterEvent ev)
 {
     Console.WriteLine("Written");
 }
Exemplo n.º 9
0
 public void ProcessPOIFSWriterEvent(POIFSWriterEvent ev)
 {
     TestEmptyDocument._logger.Log(POILogger.WARN, "Written");
     Console.WriteLine("Written");
 }