Esempio n. 1
0
        /**
         * Copies an Entry into a target POIFS directory, recursively
         */

        public static void CopyNodeRecursively(Entry entry, DirectoryEntry target)
        {
            // System.err.println("copyNodeRecursively called with "+entry.GetName()+
            // ","+tarGet.getName());
            DirectoryEntry newTarget = null;

            if (entry.IsDirectoryEntry)
            {
                newTarget = target.CreateDirectory(entry.Name);
                IEnumerator entries = ((DirectoryEntry)entry).Entries;

                while (entries.MoveNext())
                {
                    CopyNodeRecursively((Entry)entries.Current, newTarget);
                }
            }
            else
            {
                DocumentEntry dentry = (DocumentEntry)entry;
                using (DocumentInputStream dstream = new DocumentInputStream(dentry))
                {
                    target.CreateDocument(dentry.Name, dstream);
                    //now part of usings call to Dispose: dstream.Close();
                }
            }
        }
Esempio n. 2
0
        public void TestSkip()
        {
            DocumentInputStream[] streams = new DocumentInputStream[] {
                new DocumentInputStream(_workbook_o),
                new NDocumentInputStream(_workbook_n)
            };
            foreach (DocumentInputStream stream in streams)
            {
                Assert.AreEqual(_workbook_size, stream.Available());
                int count = stream.Available();

                while (stream.Available() >= _buffer_size)
                {
                    Assert.AreEqual(_buffer_size, stream.Skip(_buffer_size));
                    count -= _buffer_size;
                    Assert.AreEqual(count, stream.Available());
                }
                Assert.AreEqual(_workbook_size % _buffer_size,
                                stream.Skip(_buffer_size));
                Assert.AreEqual(0, stream.Available());
                stream.Reset();
                Assert.AreEqual(_workbook_size, stream.Available());
                Assert.AreEqual(_workbook_size, stream.Skip(_workbook_size * 2));
                Assert.AreEqual(0, stream.Available());
                stream.Reset();
                Assert.AreEqual(_workbook_size, stream.Available());
                Assert.AreEqual(_workbook_size,
                                stream.Skip(2 + (long)Int32.MaxValue));
                Assert.AreEqual(0, stream.Available());
            }
        }
Esempio n. 3
0
        private static void ReadModule(DocumentInputStream dis, String name, ModuleMap modules)
        {
            Module module = modules.Get(name);

            // TODO Refactor this to fetch dir then do the rest
            if (module == null)
            {
                // no DIR stream with offsets yet, so store the compressed bytes for later
                module = new Module();
                modules.Put(name, module);
                module.Read(dis);
            }
            else
            {
                if (module.offset == null)
                {
                    //This should not happen. bug 59858
                    throw new IOException("Module offset for '" + name + "' was never Read.");
                }
                // we know the offset already, so decompress immediately on-the-fly
                long skippedBytes = dis.Skip(module.offset.Value);
                if (skippedBytes != module.offset)
                {
                    throw new IOException("tried to skip " + module.offset + " bytes, but actually skipped " + skippedBytes + " bytes");
                }
                InputStream stream = new RLEDecompressingInputStream(dis);
                module.Read(stream);
                stream.Close();
            }
        }
Esempio n. 4
0
        public void TestAvailable()
        {
            DocumentInputStream ostream = new DocumentInputStream(_workbook_o);
            DocumentInputStream nstream = new NDocumentInputStream(_workbook_n);

            Assert.AreEqual(_workbook_size, ostream.Available());
            Assert.AreEqual(_workbook_size, nstream.Available());
            ostream.Close();
            nstream.Close();

            try
            {
                ostream.Available();
                Assert.Fail("Should have caught IOException");
            }
            catch (InvalidOperationException)
            {
                // as expected
            }
            try
            {
                nstream.Available();
                Assert.Fail("Should have caught IOException");
            }
            catch (InvalidOperationException)
            {
                // as expected
            }
        }
Esempio n. 5
0
        /**
         * package scoped constructor
         *
         * @param stream the DocumentInputStream, freshly opened
         * @param path the path of the document
         * @param documentName the name of the document
         */

        public POIFSReaderEvent(DocumentInputStream stream,
                                POIFSDocumentPath path, String documentName)
        {
            this.stream       = stream;
            this.path         = path;
            this.documentName = documentName;
        }
Esempio n. 6
0
 public AgileCipherInputStream(DocumentInputStream stream, long size,
                               IEncryptionInfoBuilder builder, AgileDecryptor decryptor)
     : base(stream, size, 4096, builder, decryptor)
 {
     this.builder   = builder;
     this.decryptor = decryptor;
 }
Esempio n. 7
0
        public EncryptionHeader(DocumentInputStream dr)
        {
            flags         = dr.ReadInt();
            sizeExtra     = dr.ReadInt();
            algorithm     = dr.ReadInt();
            hashAlgorithm = dr.ReadInt();
            keySize       = dr.ReadInt();
            providerType  = dr.ReadInt();

            dr.ReadLong();  //skip reserved.

            StringBuilder builder = new StringBuilder();

            while (true)
            {
                char c = (char)dr.ReadShort();

                if (c == 0)
                {
                    break;
                }
                builder.Append(c);
            }

            cspName    = builder.ToString();
            cipherMode = MODE_ECB;
            keySalt    = null;
        }
Esempio n. 8
0
        /**
         * Copies an Entry into a target POIFS directory, recursively
         */

        public static void CopyNodeRecursively(Entry entry, DirectoryEntry target)
        {
            // System.err.println("copyNodeRecursively called with "+entry.GetName()+
            // ","+tarGet.getName());
            DirectoryEntry newTarget = null;
            if (entry.IsDirectoryEntry)
            {
                newTarget = target.CreateDirectory(entry.Name);
                IEnumerator entries = ((DirectoryEntry)entry).Entries;

                while (entries.MoveNext())
                {
                    CopyNodeRecursively((Entry)entries.Current, newTarget);
                }
            }
            else
            {
                DocumentEntry dentry = (DocumentEntry)entry;
                using (DocumentInputStream dstream = new DocumentInputStream(dentry))
                {
                    target.CreateDocument(dentry.Name, dstream);
                    //now part of usings call to Dispose: dstream.Close();
                }
            }
        }
Esempio n. 9
0
        private void CheckAllDirectoryContents(DirectoryEntry dir)
        {
            IEnumerator <Entry> it = dir.Entries;

            //foreach (Entry entry in dir)
            while (it.MoveNext())
            {
                Entry entry = it.Current;
                if (entry is DirectoryEntry)
                {
                    CheckAllDirectoryContents((DirectoryEntry)entry);
                }
                else
                {
                    DocumentNode        doc = (DocumentNode)entry;
                    DocumentInputStream dis = new DocumentInputStream(doc);
                    try
                    {
                        int    numBytes = dis.Available();
                        byte[] data     = new byte[numBytes];
                        dis.Read(data);
                    }
                    finally
                    {
                        dis.Close();
                    }
                }
            }
        }
Esempio n. 10
0
        public override Stream GetDataStream(DirectoryNode dir)
        {
            DocumentInputStream dr = dir.CreateDocumentInputStream("EncryptedPackage");
            long size = dr.ReadLong();

            return(new ChunkedCipherInputStream(dr, size, this));
        }
Esempio n. 11
0
        public EncryptionHeader(DocumentInputStream dr)
        {
            flags = dr.ReadInt();
            sizeExtra = dr.ReadInt();
            algorithm = dr.ReadInt();
            hashAlgorithm = dr.ReadInt();
            keySize = dr.ReadInt();
            providerType = dr.ReadInt();

            dr.ReadLong();  //skip reserved.

            StringBuilder builder = new StringBuilder();

            while (true)
            {
                char c = (char)dr.ReadShort();

                if (c == 0)
                    break;
                builder.Append(c);
            }

            cspName = builder.ToString();
            cipherMode = MODE_ECB;
            keySalt = null;
        }
Esempio n. 12
0
        public override Stream GetDataStream(DirectoryNode dir)
        {
            DocumentInputStream dis = dir.CreateDocumentInputStream("EncryptedPackage");

            _length = dis.ReadLong();
            return(new ChunkedCipherInputStream(dis, _length, this));
        }
Esempio n. 13
0
        /**
         * package scoped constructor
         *
         * @param stream the DocumentInputStream, freshly opened
         * @param path the path of the document
         * @param documentName the name of the document
         */

        public POIFSReaderEvent(DocumentInputStream stream,
                         POIFSDocumentPath path, String documentName)
        {
            this.stream = stream;
            this.path = path;
            this.documentName = documentName;
        }
Esempio n. 14
0
        PropertySet GetPropertySet(DirectoryNode dir, string name)
        {
            DocumentInputStream dis = dir.CreateDocumentInputStream(name);
            PropertySet         set = PropertySetFactory.Create(dis);

            return(set);
        }
Esempio n. 15
0
        public EncryptionInfo(DirectoryNode dir)
        {
            DocumentInputStream dis = dir.CreateDocumentInputStream("EncryptionInfo");
            versionMajor = dis.ReadShort();
            versionMinor = dis.ReadShort();

            encryptionFlags = dis.ReadInt();

            if (versionMajor == 4 && versionMinor == 4 && encryptionFlags == 0x40)
            {
                StringBuilder builder = new StringBuilder();
                byte[] xmlDescriptor = new byte[dis.Available()];
                dis.Read(xmlDescriptor);
                foreach (byte b in xmlDescriptor)
                    builder.Append((char)b);
                string descriptor = builder.ToString();
                header = new EncryptionHeader(descriptor);
                verifier = new EncryptionVerifier(descriptor);
            }
            else
            {
                int hSize = dis.ReadInt();
                header = new EncryptionHeader(dis);
                if (header.Algorithm == EncryptionHeader.ALGORITHM_RC4)
                {
                    verifier = new EncryptionVerifier(dis, 20);
                }
                else
                {
                    verifier = new EncryptionVerifier(dis, 32);
                }
            }
        }
Esempio n. 16
0
        public override Stream GetDataStream(DirectoryNode dir)
        {
            DocumentInputStream dr = dir.CreateDocumentInputStream("EncryptedPackage");
            long size = dr.ReadLong();
            SymmetricAlgorithm cipher = GetCipher();

            return(new CryptoStream(dr, cipher.CreateDecryptor(cipher.Key, cipher.IV), CryptoStreamMode.Read));
        }
Esempio n. 17
0
        public void TestConstructor()
        {
            DocumentInputStream ostream = new DocumentInputStream(_workbook_o);
            DocumentInputStream nstream = new NDocumentInputStream(_workbook_n);

            Assert.AreEqual(_workbook_size, _workbook_o.Size);
            Assert.AreEqual(_workbook_size, _workbook_n.Size);
            Assert.AreEqual(_workbook_size, ostream.Available());
            Assert.AreEqual(_workbook_size, nstream.Available());
        }
Esempio n. 18
0
        public override InputStream GetDataStream(DirectoryNode dir)
        {
            DocumentInputStream dis = dir.CreateDocumentInputStream(DEFAULT_POIFS_ENTRY);

            _length = dis.ReadLong();
            BinaryRC4CipherInputStream cipherStream = new BinaryRC4CipherInputStream(dis, _length, this);

            //return cipherStream.GetStream();
            throw new NotImplementedException("BinaryRC4CipherInputStream should be derived from InputStream");
        }
Esempio n. 19
0
        /**
         * Decrypt the Document-/SummaryInformation and other optionally streams.
         * Opposed to other crypto modes, cryptoapi is record based and can't be used
         * to stream-decrypt a whole file
         *
         * @see <a href="http://msdn.microsoft.com/en-us/library/dd943321(v=office.12).aspx">2.3.5.4 RC4 CryptoAPI Encrypted Summary Stream</a>
         */

        public override InputStream GetDataStream(DirectoryNode dir)
        {
            NPOIFSFileSystem    fsOut = new NPOIFSFileSystem();
            DocumentNode        es    = (DocumentNode)dir.GetEntry("EncryptedSummary");
            DocumentInputStream dis   = dir.CreateDocumentInputStream(es);
            MemoryStream        bos   = new MemoryStream();

            IOUtils.Copy(dis, bos);
            dis.Close();
            SeekableMemoryStream    sbis    = new SeekableMemoryStream(bos.ToArray());
            LittleEndianInputStream leis    = new LittleEndianInputStream(sbis);
            int streamDescriptorArrayOffset = (int)leis.ReadUInt();
            int streamDescriptorArraySize   = (int)leis.ReadUInt();

            sbis.Seek(streamDescriptorArrayOffset - 8, SeekOrigin.Current);// sbis.Skip(streamDescriptorArrayOffset - 8);

            sbis.SetBlock(0);
            int encryptedStreamDescriptorCount = (int)leis.ReadUInt();

            StreamDescriptorEntry[] entries = new StreamDescriptorEntry[encryptedStreamDescriptorCount];
            for (int i = 0; i < encryptedStreamDescriptorCount; i++)
            {
                StreamDescriptorEntry entry = new StreamDescriptorEntry();
                entries[i]         = entry;
                entry.streamOffset = (int)leis.ReadUInt();
                entry.streamSize   = (int)leis.ReadUInt();
                entry.block        = leis.ReadUShort();
                int nameSize = leis.ReadUByte();
                entry.flags = leis.ReadUByte();
                bool IsStream = StreamDescriptorEntry.flagStream.IsSet(entry.flags);
                entry.reserved2  = leis.ReadInt();
                entry.streamName = StringUtil.ReadUnicodeLE(leis, nameSize);
                leis.ReadShort();
                Debug.Assert(entry.streamName.Length == nameSize);
            }

            foreach (StreamDescriptorEntry entry in entries)
            {
                sbis.Seek(entry.streamOffset);
                sbis.SetBlock(entry.block);
                Stream is1 = new BufferedStream(sbis, entry.streamSize);
                fsOut.CreateDocument(is1, entry.streamName);
            }

            leis.Close();
            sbis = null;

            bos.Seek(0, SeekOrigin.Begin); //bos.Reset();
            fsOut.WriteFileSystem(bos);
            fsOut.Close();
            _length = bos.Length;
            ByteArrayInputStream bis = new ByteArrayInputStream(bos.ToArray());

            throw new NotImplementedException("ByteArrayInputStream should be derived from InputStream");
        }
Esempio n. 20
0
        /**
         * Closes the MemoryStream and Reads it into a MemoryStream.
         * When finished writing information this method is used in the Tests to
         * start Reading from the Created document and then the see if the results match.
         *
         */
        private void CloseAndReOpen()
        {
            dsi.Write(dir, DocumentSummaryInformation.DEFAULT_STREAM_NAME);
            si.Write(dir, SummaryInformation.DEFAULT_STREAM_NAME);


            si  = null;
            dsi = null;
            try
            {
                poifs.WriteFileSystem(bout);
                bout.Flush();
            }
            catch (IOException)
            {
                ////e.printStackTrace();
                Assert.Fail();
            }

            Stream is1 = new MemoryStream(bout.ToArray());

            Assert.IsNotNull(is1);
            poifs = new POIFSFileSystem(is1);;
            is1.Close();

            Assert.IsNotNull(poifs);
            /* Read the document summary information. */
            dir = poifs.Root;

            DocumentEntry dsiEntry = (DocumentEntry)
                                     dir.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
            DocumentInputStream dis = new DocumentInputStream(dsiEntry);
            PropertySet         ps  = new PropertySet(dis);

            dis.Close();
            dsi = new DocumentSummaryInformation(ps);


            try
            {
                dsiEntry = (DocumentEntry)
                           dir.GetEntry(SummaryInformation.DEFAULT_STREAM_NAME);
                dis = new DocumentInputStream(dsiEntry);
                ps  = new PropertySet(dis);
                dis.Close();
                si = new SummaryInformation(ps);
            }
            catch (FileNotFoundException)
            {
                /* There is no document summary information yet. We have to Create a
                 * new one. */
                si = PropertySetFactory.CreateSummaryInformation();
                Assert.IsNotNull(si);
            }
        }
Esempio n. 21
0
        public override InputStream GetDataStream(DirectoryNode dir)
        {
            DocumentInputStream dis = dir.CreateDocumentInputStream(DEFAULT_POIFS_ENTRY);

            _length = dis.ReadLong();

            var stream = new AgileCipherInputStream(dis, _length, builder, this);

            stream.Position = 0;
            return(stream);
        }
Esempio n. 22
0
        static void Main(string[] args)
        {
            FileStream      stream  = new FileStream("thumbs.db", FileMode.Open, FileAccess.Read);
            POIFSFileSystem poifs   = new POIFSFileSystem(stream);
            var             entries = poifs.Root.Entries;

            //POIFSDocumentReader catalogdr = poifs.CreatePOIFSDocumentReader("Catalog");
            //byte[] b1=new byte[catalogdr.Length-4];
            //catalogdr.Read(b1,4,b1.Length);
            //Dictionary<string, string> indexList = new Dictionary<string, string>();
            //for (int j = 0; j < b1.Length; j++)
            //{
            //    if(b1[0]
            //}

            while (entries.MoveNext())
            {
                DocumentNode        entry = entries.Current as DocumentNode;
                DocumentInputStream dr    = poifs.CreateDocumentInputStream(entry.Name);

                if (entry.Name.ToLower() == "catalog")
                {
                    continue;
                }

                byte[] buffer = new byte[dr.Length];
                dr.Read(buffer);
                int startpos = 0;

                //detect jfif header
                for (int i = 3; i < buffer.Length; i++)
                {
                    if (buffer[i - 3] == 0xFF &&
                        buffer[i - 2] == 0xD8 &&
                        buffer[i - 1] == 0xFF &&
                        buffer[i] == 0xE0)
                    {
                        startpos = i - 3;
                        break;
                    }
                }
                if (startpos == 0)
                {
                    continue;
                }

                FileStream jpeg = File.Create(entry.Name + ".jpeg");
                jpeg.Write(buffer, startpos, buffer.Length - startpos);
                jpeg.Close();
            }

            stream.Close();
        }
Esempio n. 23
0
        /* ********** START implementation of POIFSReaderListener ********** */

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

        public void ProcessPOIFSReaderEvent(POIFSReaderEvent evt)
        {
            DocumentInputStream istream = evt.Stream;
            POIFSDocumentPath   path    = evt.Path;
            String name = evt.Name;

            try
            {
                int    size = (int)(istream.Length - istream.Position);
                byte[] data = new byte[size];

                istream.Read(data);
                DocumentDescriptor descriptor = new DocumentDescriptor(path,
                                                                       name);

                Console.WriteLine("Adding document: " + descriptor + " (" + size
                                  + " bytes)");
                dataMap[descriptor] = data;
                int            pathLength = path.Length;
                DirectoryEntry entry      = root;

                for (int k = 0; k < path.Length; k++)
                {
                    String componentName = path.GetComponent(k);
                    Entry  nextEntry     = null;

                    try
                    {
                        nextEntry = entry.GetEntry(componentName);
                    }
                    catch (FileNotFoundException ignored)
                    {
                        try
                        {
                            nextEntry = entry.CreateDirectory(componentName);
                        }
                        catch (IOException e)
                        {
                            Console.WriteLine("Unable to Create directory");
                            //e.printStackTrace();
                            throw;
                        }
                    }
                    entry = (DirectoryEntry)nextEntry;
                }
                entry.CreateDocument(name, size, this);
            }
            catch (IOException ignored)
            {
            }
        }
Esempio n. 24
0
        private void RunTest(FileStream file)
        {
            /* Read a Test document <em>doc</em> into a POI filesystem. */
            POIFSFileSystem poifs    = new POIFSFileSystem(file);
            DirectoryEntry  dir      = poifs.Root;
            DocumentEntry   dsiEntry = null;

            try
            {
                dsiEntry = (DocumentEntry)dir.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
            }
            catch (FileNotFoundException)
            {
                /*
                 * A missing document summary information stream is not an error
                 * and therefore silently ignored here.
                 */
            }

            /*
             * If there is a document summry information stream, Read it from
             * the POI filesystem, else Create a new one.
             */
            DocumentSummaryInformation dsi;

            if (dsiEntry != null)
            {
                DocumentInputStream dis = new DocumentInputStream(dsiEntry);
                PropertySet         ps  = new PropertySet(dis);
                dsi = new DocumentSummaryInformation(ps);
            }
            else
            {
                dsi = PropertySetFactory.CreateDocumentSummaryInformation();
            }
            CustomProperties cps = dsi.CustomProperties;

            if (cps == null)
            {
                /* The document does not have custom properties. */
                return;
            }

            foreach (var de in cps)
            {
                CustomProperty cp = (CustomProperty)de.Value;
                Assert.IsNotNull(cp.Name);
                Assert.IsNotNull(cp.Value);
            }
        }
Esempio n. 25
0
 public ChunkedCipherInputStream(DocumentInputStream dis, long size, AgileDecryptor ag)
 {
     try
     {
         _size   = size;
         _stream = dis;
         _ag     = ag;
         _cipher = _ag.GetCipher(_ag.Info.Header.Algorithm,
                                 _ag.Info.Header.CipherMode,
                                 _ag.SecretKey, _ag.Info.Header.KeySalt);
     }
     catch (System.Security.Cryptography.CryptographicException ex)
     {
         throw ex;
     }
 }
Esempio n. 26
0
        protected static EncryptionDocument ParseDescriptor(DocumentInputStream descriptor)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                byte[]      buf    = new byte[descriptor.Length - descriptor.Position];
                descriptor.ReadFully(buf);
                string xml = Encoding.UTF8.GetString(buf);
                OpenXml4Net.Util.XmlHelper.LoadXmlSafe(xmlDoc, xml, Encoding.UTF8);

                return(EncryptionDocument.Parse(xmlDoc));
            }
            catch (Exception e)
            {
                throw new EncryptedDocumentException("Unable to parse encryption descriptor", e);
            }
        }
Esempio n. 27
0
        public override InputStream GetDataStream(DirectoryNode dir)
        {
            DocumentInputStream dis = dir.CreateDocumentInputStream(Encryptor.DEFAULT_POIFS_ENTRY);

            _length = dis.ReadLong();

            // limit wrong calculated ole entries - (bug #57080)
            // standard encryption always uses aes encoding, so blockSize is always 16
            // http://stackoverflow.com/questions/3283787/size-of-data-after-aes-encryption
            int    blockSize = builder.GetHeader().CipherAlgorithm.blockSize;
            long   cipherLen = (_length / blockSize + 1) * blockSize;
            Cipher cipher    = GetCipher(GetSecretKey());


            ByteArrayInputStream boundedDis = new BoundedInputStream(dis, cipherLen);

            return(new BoundedInputStream(new CipherInputStream(boundedDis, cipher), _length));
        }
Esempio n. 28
0
        /**
         * <p>Creates the most specific {@link PropertySet} from an entry
         *  in the specified POIFS Directory. This is preferrably a {@link
         * DocumentSummaryInformation} or a {@link SummaryInformation}. If
         * the specified entry does not contain a property Set stream, an
         * exception is thrown. If no entry is found with the given name,
         * an exception is thrown.</p>
         *
         * @param dir The directory to find the PropertySet in
         * @param name The name of the entry Containing the PropertySet
         * @return The Created {@link PropertySet}.
         * @if there is no entry with that name
         * @if the stream does not
         * contain a property Set.
         * @if some I/O problem occurs.
         * @exception EncoderFallbackException if the specified codepage is not
         * supported.
         */

        public static PropertySet Create(DirectoryEntry dir, string name)
        {
            Stream inp = null;

            try {
                DocumentEntry entry = (DocumentEntry)dir.GetEntry(name);
                inp = new DocumentInputStream(entry);
                try {
                    return(Create(inp));
                }
                catch (MarkUnsupportedException) { return(null); }
            }
            finally {
                if (inp != null)
                {
                    inp.Dispose();
                }
            }
        }
Esempio n. 29
0
        public void TestReadSingleByte()
        {
            DocumentInputStream[] streams = new DocumentInputStream[] {
                new DocumentInputStream(_workbook_o),
                new NDocumentInputStream(_workbook_n)
            };
            foreach (DocumentInputStream stream in streams)
            {
                int remaining = _workbook_size;

                // Try and read each byte in turn
                for (int j = 0; j < _workbook_size; j++)
                {
                    int b = stream.Read();
                    Assert.IsTrue(b >= 0, "Checking sign of " + j);
                    Assert.AreEqual(_workbook_data[j],
                                    (byte)b, "validating byte " + j);
                    remaining--;
                    Assert.AreEqual(
                        remaining, stream.Available(), "Checking remaining After Reading byte " + j);
                }

                // Ensure we fell off the end
                Assert.AreEqual(-1, stream.Read());

                // Check that After close we can no longer read
                stream.Close();
                try
                {
                    stream.Read();
                    Assert.Fail("Should have caught IOException");
                }
                catch (IOException)
                {
                    // as expected
                }
            }
        }
Esempio n. 30
0
        public EncryptionVerifier(DocumentInputStream dis, int encryptedLength)
        {
            int saltSize = dis.ReadInt();

            if (saltSize != 16)
            {
                throw new Exception("Salt size != 16 !?");
            }

            salt = new byte[16];
            dis.ReadFully(salt);
            verifier = new byte[16];
            dis.ReadFully(verifier);

            verifierHashSize = dis.ReadInt();

            verifierHash = new byte[encryptedLength];
            dis.ReadFully(verifierHash);

            spinCount    = 50000;
            algorithm    = EncryptionHeader.ALGORITHM_AES_128;
            cipherMode   = EncryptionHeader.MODE_ECB;
            encryptedKey = null;
        }
Esempio n. 31
0
        /**
         * Reads VBA Project modules from a VBA Project directory located at
         * <tt>macroDir</tt> into <tt>modules</tt>.
         *
         * @since 3.15-beta2
         */
        protected void ReadMacros(DirectoryNode macroDir, ModuleMap modules)
        {
            foreach (Entry entry in macroDir)
            {
                if (!(entry is DocumentNode))
                {
                    continue;
                }

                String              name     = entry.Name;
                DocumentNode        document = (DocumentNode)entry;
                DocumentInputStream dis      = new DocumentInputStream(document);
                try
                {
                    if ("dir".Equals(name, StringComparison.OrdinalIgnoreCase))
                    {
                        // process DIR
                        RLEDecompressingInputStream in1 = new RLEDecompressingInputStream(dis);
                        String streamName = null;
                        int    recordId   = 0;
                        try
                        {
                            while (true)
                            {
                                recordId = in1.ReadShort();
                                if (EOF == recordId ||
                                    VERSION_INDEPENDENT_TERMINATOR == recordId)
                                {
                                    break;
                                }
                                int recordLength = in1.ReadInt();
                                switch (recordId)
                                {
                                case PROJECTVERSION:
                                    TrySkip(in1, 6);
                                    break;

                                case PROJECTCODEPAGE:
                                    int codepage = in1.ReadShort();
                                    ModuleMap.charset = Encoding.GetEncoding(codepage);     //Charset.ForName("Cp" + codepage);
                                    break;

                                case STREAMNAME:
                                    streamName = ReadString(in1, recordLength, ModuleMap.charset);
                                    break;

                                case MODULEOFFSET:
                                    ReadModule(in1, streamName, modules);
                                    break;

                                default:
                                    TrySkip(in1, recordLength);
                                    break;
                                }
                            }
                        }
                        catch (IOException e)
                        {
                            throw new IOException(
                                      "Error occurred while Reading macros at section id "
                                      + recordId + " (" + HexDump.ShortToHex(recordId) + ")", e);
                        }
                        finally
                        {
                            in1.Close();
                        }
                    }
                    else if (!name.StartsWith("__SRP", StringComparison.OrdinalIgnoreCase) &&
                             !name.StartsWith("_VBA_PROJECT", StringComparison.OrdinalIgnoreCase))
                    {
                        // process module, skip __SRP and _VBA_PROJECT since these do not contain macros
                        ReadModule(dis, name, modules);
                    }
                }
                finally
                {
                    dis.Close();
                }
            }
        }
Esempio n. 32
0
        public EncryptionVerifier(DocumentInputStream dis, int encryptedLength)
        {
            int saltSize = dis.ReadInt();

            if (saltSize != 16)
                throw new Exception("Salt size != 16 !?");

            salt = new byte[16];
            dis.ReadFully(salt);
            verifier = new byte[16];
            dis.ReadFully(verifier);

            verifierHashSize = dis.ReadInt();

            verifierHash = new byte[encryptedLength];
            dis.ReadFully(verifierHash);

            spinCount = 50000;
            algorithm = EncryptionHeader.ALGORITHM_AES_128;
            cipherMode = EncryptionHeader.MODE_ECB;
            encryptedKey = null;
        }
Esempio n. 33
0
        public void TestReadDocumentSummaryInformation()
        {
            POIDataSamples _samples = POIDataSamples.GetHPSFInstance();

            string[] files = _samples.GetFiles("Test*.*");

            for (int i = 0; i < files.Length; i++)
            {
                if (!TestReadAllFiles.checkExclude(files[i]))
                {
                    continue;
                }
                using (FileStream doc = new FileStream(files[i], FileMode.Open, FileAccess.Read))
                {
                    Console.WriteLine("Reading file " + doc);
                    try
                    {
                        /* Read a Test document <em>doc</em> into a POI filesystem. */
                        POIFSFileSystem poifs    = new POIFSFileSystem(doc);
                        DirectoryEntry  dir      = poifs.Root;
                        DocumentEntry   dsiEntry = null;
                        try
                        {
                            dsiEntry = (DocumentEntry)dir.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
                        }
                        catch (FileNotFoundException)
                        {
                            /*
                             * A missing document summary information stream is not an error
                             * and therefore silently ignored here.
                             */
                        }
                        //catch (System.IO.IOException ex)
                        //{
                        //     // The process cannot access the file 'testcases\test-data\hpsf\TestUnicode.xls' because it is being used by another process.
                        //    Console.Error.WriteLine("Exception ignored (because some other test cases may read this file, too): " + ex.Message);
                        //}

                        /*
                         * If there is a document summry information stream, Read it from
                         * the POI filesystem.
                         */
                        if (dsiEntry != null)
                        {
                            DocumentInputStream        dis = new DocumentInputStream(dsiEntry);
                            PropertySet                ps  = new PropertySet(dis);
                            DocumentSummaryInformation dsi = new DocumentSummaryInformation(ps);

                            /* Execute the Get... methods. */
                            Console.WriteLine(dsi.ByteCount);
                            Console.WriteLine(dsi.ByteOrder);
                            Console.WriteLine(dsi.Category);
                            Console.WriteLine(dsi.Company);
                            Console.WriteLine(dsi.CustomProperties);
                            // FIXME Console.WriteLine(dsi.Docparts);
                            // FIXME Console.WriteLine(dsi.HeadingPair);
                            Console.WriteLine(dsi.HiddenCount);
                            Console.WriteLine(dsi.LineCount);
                            Console.WriteLine(dsi.LinksDirty);
                            Console.WriteLine(dsi.Manager);
                            Console.WriteLine(dsi.MMClipCount);
                            Console.WriteLine(dsi.NoteCount);
                            Console.WriteLine(dsi.ParCount);
                            Console.WriteLine(dsi.PresentationFormat);
                            Console.WriteLine(dsi.Scale);
                            Console.WriteLine(dsi.SlideCount);
                        }
                    }
                    catch (Exception e)
                    {
                        throw new IOException("While handling file " + files[i], e);
                    }
                }
            }
        }
Esempio n. 34
0
        public void TestWriteWellKnown1()
        {
            POIDataSamples _samples = POIDataSamples.GetHPSFInstance();

            using (FileStream doc1 = _samples.GetFile(POI_FS))
            {
                /* Read a Test document <em>doc1</em> into a POI filesystem. */
                POIFSFileSystem poifs    = new POIFSFileSystem(doc1);
                DirectoryEntry  dir      = poifs.Root;
                DocumentEntry   siEntry  = (DocumentEntry)dir.GetEntry(SummaryInformation.DEFAULT_STREAM_NAME);
                DocumentEntry   dsiEntry = (DocumentEntry)dir.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);

                /*
                 * Read the summary information stream and the document summary
                 * information stream from the POI filesystem.
                 *
                 * Please note that the result consists of SummaryInformation and
                 * DocumentSummaryInformation instances which are in memory only. To
                 * make them permanent they have to be written to a POI filesystem
                 * explicitly (overwriting the former contents). Then the POI filesystem
                 * should be saved to a file.
                 */
                DocumentInputStream dis = new DocumentInputStream(siEntry);
                PropertySet         ps  = new PropertySet(dis);
                SummaryInformation  si  = new SummaryInformation(ps);
                dis = new DocumentInputStream(dsiEntry);
                ps  = new PropertySet(dis);
                DocumentSummaryInformation dsi = new DocumentSummaryInformation(ps);

                /*
                 * Write all properties supported by HPSF to the summary information
                 * (e.g. author, edit date, application name) and to the document
                 * summary information (e.g. company, manager).
                 */
                Calendar cal = new GregorianCalendar();
                //long time1 = (long)cal.GetMilliseconds(new DateTime(2000, 6, 6, 6, 6, 6));

                //long time2 = (long)cal.GetMilliseconds(new DateTime(2001, 7, 7, 7, 7, 7));
                //long time3 = (long)cal.GetMilliseconds(new DateTime(2002, 8, 8, 8, 8, 8));

                int      nr = 4711;
                String   P_APPLICATION_NAME    = "Microsoft Office Word";
                String   P_AUTHOR              = "Rainer Klute";
                int      P_CHAR_COUNT          = 125;
                String   P_COMMENTS            = ""; //"Comments";
                DateTime P_CREATE_DATE_TIME    = new DateTime(2006, 2, 1, 7, 36, 0);
                long     P_EDIT_TIME           = ++nr * 1000 * 10;
                String   P_KEYWORDS            = "Test HPSF SummaryInformation DocumentSummaryInformation Writing";
                String   P_LAST_AUTHOR         = "LastAuthor";
                DateTime?P_LAST_PRINTED        = new DateTime(2001, 7, 7, 7, 7, 7);
                DateTime P_LAST_SAVE_DATE_TIME = new DateTime(2008, 9, 30, 9, 54, 0);
                int      P_PAGE_COUNT          = 1;
                String   P_REV_NUMBER          = "RevNumber";
                int      P_SECURITY            = 1;
                String   P_SUBJECT             = "Subject";
                String   P_TEMPLATE            = "Normal.dotm";
                // FIXME (byte array properties not yet implemented): byte[] P_THUMBNAIL = new byte[123];
                String P_TITLE      = "This document is used for testing POI HPSF¡¯s writing capabilities for the summary information stream and the document summary information stream";
                int    P_WORD_COUNT = 21;

                int    P_BYTE_COUNT = ++nr;
                String P_CATEGORY   = "Category";
                String P_COMPANY    = "Rainer Klute IT-Consulting GmbH";
                // FIXME (byte array properties not yet implemented): byte[]  P_DOCPARTS = new byte[123];
                // FIXME (byte array properties not yet implemented): byte[]  P_HEADING_PAIR = new byte[123];
                int      P_HIDDEN_COUNT        = ++nr;
                int      P_LINE_COUNT          = ++nr;
                bool     P_LINKS_DIRTY         = true;
                String   P_MANAGER             = "Manager";
                int      P_MM_CLIP_COUNT       = ++nr;
                int      P_NOTE_COUNT          = ++nr;
                int      P_PAR_COUNT           = ++nr;
                String   P_PRESENTATION_FORMAT = "PresentationFormat";
                bool     P_SCALE       = false;
                int      P_SLIDE_COUNT = ++nr;
                DateTime now           = DateTime.Now;

                int    POSITIVE_INTEGER = 2222;
                long   POSITIVE_LONG    = 3333;
                Double POSITIVE_DOUBLE  = 4444;
                int    NEGATIVE_INTEGER = 2222;
                long   NEGATIVE_LONG    = 3333;
                Double NEGATIVE_DOUBLE  = 4444;

                int    MAX_INTEGER = int.MaxValue;
                int    MIN_INTEGER = int.MinValue;
                long   MAX_LONG    = long.MaxValue;
                long   MIN_LONG    = long.MinValue;
                Double MAX_DOUBLE  = Double.MaxValue;
                Double MIN_DOUBLE  = Double.MinValue;

                si.ApplicationName  = P_APPLICATION_NAME;
                si.Author           = P_AUTHOR;
                si.CharCount        = P_CHAR_COUNT;
                si.Comments         = P_COMMENTS;
                si.CreateDateTime   = P_CREATE_DATE_TIME;
                si.EditTime         = P_EDIT_TIME;
                si.Keywords         = P_KEYWORDS;
                si.LastAuthor       = P_LAST_AUTHOR;
                si.LastPrinted      = P_LAST_PRINTED;
                si.LastSaveDateTime = P_LAST_SAVE_DATE_TIME;
                si.PageCount        = P_PAGE_COUNT;
                si.RevNumber        = P_REV_NUMBER;
                si.Security         = P_SECURITY;
                si.Subject          = P_SUBJECT;
                si.Template         = P_TEMPLATE;
                // FIXME (byte array properties not yet implemented): si.Thumbnail=P_THUMBNAIL;
                si.Title     = P_TITLE;
                si.WordCount = P_WORD_COUNT;

                dsi.ByteCount = P_BYTE_COUNT;
                dsi.Category  = P_CATEGORY;
                dsi.Company   = P_COMPANY;
                // FIXME (byte array properties not yet implemented): dsi.Docparts=P_DOCPARTS;
                // FIXME (byte array properties not yet implemented): dsi.HeadingPair=P_HEADING_PAIR;
                dsi.HiddenCount        = P_HIDDEN_COUNT;
                dsi.LineCount          = P_LINE_COUNT;
                dsi.LinksDirty         = P_LINKS_DIRTY;
                dsi.Manager            = P_MANAGER;
                dsi.MMClipCount        = P_MM_CLIP_COUNT;
                dsi.NoteCount          = P_NOTE_COUNT;
                dsi.ParCount           = P_PAR_COUNT;
                dsi.PresentationFormat = P_PRESENTATION_FORMAT;
                dsi.Scale      = P_SCALE;
                dsi.SlideCount = P_SLIDE_COUNT;

                CustomProperties customProperties = dsi.CustomProperties;
                if (customProperties == null)
                {
                    customProperties = new CustomProperties();
                }
                customProperties.Put("Schlüssel 1", "Wert 1");
                customProperties.Put("Schlüssel 2", "Wert 2");
                customProperties.Put("Schlüssel 3", "Wert 3");
                customProperties.Put("Schlüssel 4", "Wert 4");
                customProperties.Put("positive_int", POSITIVE_INTEGER);
                customProperties.Put("positive_long", POSITIVE_LONG);
                customProperties.Put("positive_Double", POSITIVE_DOUBLE);
                customProperties.Put("negative_int", NEGATIVE_INTEGER);
                customProperties.Put("negative_long", NEGATIVE_LONG);
                customProperties.Put("negative_Double", NEGATIVE_DOUBLE);
                customProperties.Put("Boolean", true);
                customProperties.Put("Date", now);
                customProperties.Put("max_int", MAX_INTEGER);
                customProperties.Put("min_int", MIN_INTEGER);
                customProperties.Put("max_long", MAX_LONG);
                customProperties.Put("min_long", MIN_LONG);
                customProperties.Put("max_Double", MAX_DOUBLE);
                customProperties.Put("min_Double", MIN_DOUBLE);
                dsi.CustomProperties = customProperties;

                /* Write the summary information stream and the document summary
                 * information stream to the POI filesystem. */
                si.Write(dir, siEntry.Name);
                dsi.Write(dir, dsiEntry.Name);

                /* Write the POI filesystem to a (temporary) file <em>doc2</em>
                 * and Close the latter. */
                using (FileStream doc2 = File.Create(@".\POI_HPSF_Test2.tmp"))
                {
                    poifs.WriteFileSystem(doc2);
                    //doc2.Flush();

                    /*
                     * Open <em>doc2</em> for Reading and check summary information and
                     * document summary information. All properties written before must be
                     * found in the property streams of <em>doc2</em> and have the correct
                     * values.
                     */
                    doc2.Flush();
                    doc2.Position = 0;
                    POIFSFileSystem poifs2 = new POIFSFileSystem(doc2);
                    dir      = poifs2.Root;
                    siEntry  = (DocumentEntry)dir.GetEntry(SummaryInformation.DEFAULT_STREAM_NAME);
                    dsiEntry = (DocumentEntry)dir.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);

                    dis = new DocumentInputStream(siEntry);
                    ps  = new PropertySet(dis);
                    si  = new SummaryInformation(ps);
                    dis = new DocumentInputStream(dsiEntry);
                    ps  = new PropertySet(dis);
                    dsi = new DocumentSummaryInformation(ps);

                    Assert.AreEqual(P_APPLICATION_NAME, si.ApplicationName);
                    Assert.AreEqual(P_AUTHOR, si.Author);
                    Assert.AreEqual(P_CHAR_COUNT, si.CharCount);
                    Assert.AreEqual(P_COMMENTS, si.Comments);
                    Assert.AreEqual(P_CREATE_DATE_TIME, si.CreateDateTime);
                    Assert.AreEqual(P_EDIT_TIME, si.EditTime);
                    Assert.AreEqual(P_KEYWORDS, si.Keywords);
                    Assert.AreEqual(P_LAST_AUTHOR, si.LastAuthor);
                    Assert.AreEqual(P_LAST_PRINTED, si.LastPrinted);
                    Assert.AreEqual(P_LAST_SAVE_DATE_TIME, si.LastSaveDateTime);
                    Assert.AreEqual(P_PAGE_COUNT, si.PageCount);
                    Assert.AreEqual(P_REV_NUMBER, si.RevNumber);
                    Assert.AreEqual(P_SECURITY, si.Security);
                    Assert.AreEqual(P_SUBJECT, si.Subject);
                    Assert.AreEqual(P_TEMPLATE, si.Template);
                    // FIXME (byte array properties not yet implemented): Assert.AreEqual(P_THUMBNAIL, si.Thumbnail);
                    Assert.AreEqual(P_TITLE, si.Title);
                    Assert.AreEqual(P_WORD_COUNT, si.WordCount);

                    Assert.AreEqual(P_BYTE_COUNT, dsi.ByteCount);
                    Assert.AreEqual(P_CATEGORY, dsi.Category);
                    Assert.AreEqual(P_COMPANY, dsi.Company);
                    // FIXME (byte array properties not yet implemented): Assert.AreEqual(P_, dsi.Docparts);
                    // FIXME (byte array properties not yet implemented): Assert.AreEqual(P_, dsi.HeadingPair);
                    Assert.AreEqual(P_HIDDEN_COUNT, dsi.HiddenCount);
                    Assert.AreEqual(P_LINE_COUNT, dsi.LineCount);
                    Assert.AreEqual(P_LINKS_DIRTY, dsi.LinksDirty);
                    Assert.AreEqual(P_MANAGER, dsi.Manager);
                    Assert.AreEqual(P_MM_CLIP_COUNT, dsi.MMClipCount);
                    Assert.AreEqual(P_NOTE_COUNT, dsi.NoteCount);
                    Assert.AreEqual(P_PAR_COUNT, dsi.ParCount);
                    Assert.AreEqual(P_PRESENTATION_FORMAT, dsi.PresentationFormat);
                    Assert.AreEqual(P_SCALE, dsi.Scale);
                    Assert.AreEqual(P_SLIDE_COUNT, dsi.SlideCount);

                    CustomProperties cps = dsi.CustomProperties;
                    //Assert.AreEqual(customProperties, cps);
                    Assert.IsNull(cps["No value available"]);
                    Assert.AreEqual("Wert 1", cps["Schlüssel 1"]);
                    Assert.AreEqual("Wert 2", cps["Schlüssel 2"]);
                    Assert.AreEqual("Wert 3", cps["Schlüssel 3"]);
                    Assert.AreEqual("Wert 4", cps["Schlüssel 4"]);
                    Assert.AreEqual(POSITIVE_INTEGER, cps["positive_int"]);
                    Assert.AreEqual(POSITIVE_LONG, cps["positive_long"]);
                    Assert.AreEqual(POSITIVE_DOUBLE, cps["positive_Double"]);
                    Assert.AreEqual(NEGATIVE_INTEGER, cps["negative_int"]);
                    Assert.AreEqual(NEGATIVE_LONG, cps["negative_long"]);
                    Assert.AreEqual(NEGATIVE_DOUBLE, cps["negative_Double"]);
                    Assert.AreEqual(true, cps["Boolean"]);
                    Assert.AreEqual(now, cps["Date"]);
                    Assert.AreEqual(MAX_INTEGER, cps["max_int"]);
                    Assert.AreEqual(MIN_INTEGER, cps["min_int"]);
                    Assert.AreEqual(MAX_LONG, cps["max_long"]);
                    Assert.AreEqual(MIN_LONG, cps["min_long"]);
                    Assert.AreEqual(MAX_DOUBLE, cps["max_Double"]);
                    Assert.AreEqual(MIN_DOUBLE, cps["min_Double"]);

                    /* Remove all properties supported by HPSF from the summary
                     * information (e.g. author, edit date, application name) and from the
                     * document summary information (e.g. company, manager). */
                    si.RemoveApplicationName();
                    si.RemoveAuthor();
                    si.RemoveCharCount();
                    si.RemoveComments();
                    si.RemoveCreateDateTime();
                    si.RemoveEditTime();
                    si.RemoveKeywords();
                    si.RemoveLastAuthor();
                    si.RemoveLastPrinted();
                    si.RemoveLastSaveDateTime();
                    si.RemovePageCount();
                    si.RemoveRevNumber();
                    si.RemoveSecurity();
                    si.RemoveSubject();
                    si.RemoveTemplate();
                    si.RemoveThumbnail();
                    si.RemoveTitle();
                    si.RemoveWordCount();

                    dsi.RemoveByteCount();
                    dsi.RemoveCategory();
                    dsi.RemoveCompany();
                    dsi.RemoveCustomProperties();
                    dsi.RemoveDocparts();
                    dsi.RemoveHeadingPair();
                    dsi.RemoveHiddenCount();
                    dsi.RemoveLineCount();
                    dsi.RemoveLinksDirty();
                    dsi.RemoveManager();
                    dsi.RemoveMMClipCount();
                    dsi.RemoveNoteCount();
                    dsi.RemoveParCount();
                    dsi.RemovePresentationFormat();
                    dsi.RemoveScale();
                    dsi.RemoveSlideCount();

                    /*
                     * <li>Write the summary information stream and the document summary
                     * information stream to the POI filesystem. */
                    si.Write(dir, siEntry.Name);
                    dsi.Write(dir, dsiEntry.Name);

                    /*
                     * <li>Write the POI filesystem to a (temporary) file <em>doc3</em>
                     * and Close the latter. */
                    using (FileStream doc3 = File.Create(@".\POI_HPSF_Test3.tmp"))
                    {
                        poifs2.WriteFileSystem(doc3);
                        doc3.Position = 0;

                        /*
                         * Open <em>doc3</em> for Reading and check summary information
                         * and document summary information. All properties Removed before must not
                         * be found in the property streams of <em>doc3</em>.
                         */
                        POIFSFileSystem poifs3 = new POIFSFileSystem(doc3);

                        dir      = poifs3.Root;
                        siEntry  = (DocumentEntry)dir.GetEntry(SummaryInformation.DEFAULT_STREAM_NAME);
                        dsiEntry = (DocumentEntry)dir.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);

                        dis = new DocumentInputStream(siEntry);
                        ps  = new PropertySet(dis);
                        si  = new SummaryInformation(ps);
                        dis = new DocumentInputStream(dsiEntry);
                        ps  = new PropertySet(dis);
                        dsi = new DocumentSummaryInformation(ps);

                        Assert.AreEqual(null, si.ApplicationName);
                        Assert.AreEqual(null, si.Author);
                        Assert.AreEqual(0, si.CharCount);
                        Assert.IsTrue(si.WasNull);
                        Assert.AreEqual(null, si.Comments);
                        Assert.AreEqual(null, si.CreateDateTime);
                        Assert.AreEqual(0, si.EditTime);
                        Assert.IsTrue(si.WasNull);
                        Assert.AreEqual(null, si.Keywords);
                        Assert.AreEqual(null, si.LastAuthor);
                        Assert.AreEqual(null, si.LastPrinted);
                        Assert.AreEqual(null, si.LastSaveDateTime);
                        Assert.AreEqual(0, si.PageCount);
                        Assert.IsTrue(si.WasNull);
                        Assert.AreEqual(null, si.RevNumber);
                        Assert.AreEqual(0, si.Security);
                        Assert.IsTrue(si.WasNull);
                        Assert.AreEqual(null, si.Subject);
                        Assert.AreEqual(null, si.Template);
                        Assert.AreEqual(null, si.Thumbnail);
                        Assert.AreEqual(null, si.Title);
                        Assert.AreEqual(0, si.WordCount);
                        Assert.IsTrue(si.WasNull);

                        Assert.AreEqual(0, dsi.ByteCount);
                        Assert.IsTrue(dsi.WasNull);
                        Assert.AreEqual(null, dsi.Category);
                        Assert.AreEqual(null, dsi.CustomProperties);
                        // FIXME (byte array properties not yet implemented): Assert.AreEqual(null, dsi.Docparts);
                        // FIXME (byte array properties not yet implemented): Assert.AreEqual(null, dsi.HeadingPair);
                        Assert.AreEqual(0, dsi.HiddenCount);
                        Assert.IsTrue(dsi.WasNull);
                        Assert.AreEqual(0, dsi.LineCount);
                        Assert.IsTrue(dsi.WasNull);
                        Assert.AreEqual(false, dsi.LinksDirty);
                        Assert.IsTrue(dsi.WasNull);
                        Assert.AreEqual(null, dsi.Manager);
                        Assert.AreEqual(0, dsi.MMClipCount);
                        Assert.IsTrue(dsi.WasNull);
                        Assert.AreEqual(0, dsi.NoteCount);
                        Assert.IsTrue(dsi.WasNull);
                        Assert.AreEqual(0, dsi.ParCount);
                        Assert.IsTrue(dsi.WasNull);
                        Assert.AreEqual(null, dsi.PresentationFormat);
                        Assert.AreEqual(false, dsi.Scale);
                        Assert.IsTrue(dsi.WasNull);
                        Assert.AreEqual(0, dsi.SlideCount);
                        Assert.IsTrue(dsi.WasNull);
                    }
                }
            }

            if (File.Exists(@".\POI_HPSF_Test3.tmp"))
            {
                File.Delete(@".\POI_HPSF_Test3.tmp");
            }

            if (File.Exists(@".\POI_HPSF_Test2.tmp"))
            {
                File.Delete(@".\POI_HPSF_Test2.tmp");
            }
        }
Esempio n. 35
0
 public ChunkedCipherInputStream(DocumentInputStream dis, long size, AgileDecryptor ag)
 {
     try
     {
         _size = size;
         _stream = dis;
         _ag = ag;
         _cipher = _ag.GetCipher(_ag.Info.Header.Algorithm,
                                 _ag.Info.Header.CipherMode,
                                 _ag.SecretKey, _ag.Info.Header.KeySalt);
     }
     catch (System.Security.Cryptography.CryptographicException ex)
     {
         throw ex;
     }
 }