Esempio n. 1
0
 /// <exception cref="System.IO.IOException"/>
 public virtual string NextLog()
 {
     if (currentLogData != null && currentLogLength > 0)
     {
         do
         {
             // seek to the end of the current log, relying on BoundedInputStream
             // to prevent seeking past the end of the current log
             if (currentLogData.Skip(currentLogLength) < 0)
             {
                 break;
             }
         }while (currentLogData.Read() != -1);
     }
     currentLogType   = null;
     currentLogLength = 0;
     currentLogData   = null;
     currentLogISR    = null;
     try
     {
         string logType      = valueStream.ReadUTF();
         string logLengthStr = valueStream.ReadUTF();
         currentLogLength = long.Parse(logLengthStr);
         currentLogData   = new BoundedInputStream(valueStream, currentLogLength);
         currentLogData.SetPropagateClose(false);
         currentLogISR = new InputStreamReader(currentLogData, Sharpen.Extensions.GetEncoding
                                                   ("UTF-8"));
         currentLogType = logType;
     }
     catch (EOFException)
     {
     }
     return(currentLogType);
 }
Esempio n. 2
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));
        }