Exemplo n.º 1
0
        /// <exception cref="System.IO.IOException"></exception>
        public virtual CodecHandler CreateHandler(PageChannel channel, Encoding charset)
        {
            JetFormat format = channel.GetFormat();

            switch (format.CODEC_TYPE)
            {
            case JetFormat.CodecType.NONE:
            {
                // no encoding, all good
                return(DefaultCodecProvider.DUMMY_HANDLER);
            }

            case JetFormat.CodecType.JET:
            {
                return(JetCryptCodecHandler.Create(channel));
            }

            case JetFormat.CodecType.MSISAM:
            {
                return(MSISAMCryptCodecHandler.Create(GetPassword(), channel, charset));
            }

            default:
            {
                throw new RuntimeException("Unknown codec type " + format.CODEC_TYPE);
            }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// <inheritDoc></inheritDoc>
        /// <p>
        /// This implementation returns DUMMY_HANDLER for databases with no encoding
        /// and UNSUPPORTED_HANDLER for databases with any encoding.
        /// </summary>
        /// <exception cref="System.IO.IOException"></exception>
        public virtual CodecHandler CreateHandler(PageChannel channel, Encoding charset)
        {
            JetFormat format = channel.GetFormat();

            switch (format.CODEC_TYPE)
            {
            case JetFormat.CodecType.NONE:
            {
                // no encoding, all good
                return(DUMMY_HANDLER);
            }

            case JetFormat.CodecType.JET:
            {
                // check for an encode key.  if 0, not encoded
                ByteBuffer bb = channel.CreatePageBuffer();
                channel.ReadPage(bb, 0);
                int codecKey = bb.GetInt(format.OFFSET_ENCODING_KEY);
                return((codecKey == 0) ? DUMMY_HANDLER : UNSUPPORTED_HANDLER);
            }

            case JetFormat.CodecType.MSISAM:
            {
                // always encoded, we don't handle it
                return(UNSUPPORTED_HANDLER);
            }

            default:
            {
                throw new RuntimeException("Unknown codec type " + format.CODEC_TYPE);
            }
            }
        }
        /// <exception cref="System.IO.IOException"></exception>
        public static CodecHandler Create(string password, PageChannel channel, Encoding
                                          charset)
        {
            ByteBuffer buffer = ReadHeaderPage(channel);

            if ((buffer.Get(ENCRYPTION_FLAGS_OFFSET) & NEW_ENCRYPTION) != 0)
            {
                return(new HealthMarketScience.Jackcess.MSISAMCryptCodecHandler(password, charset
                                                                                , buffer));
            }
            // old MSISAM dbs use jet-style encryption w/ a different key
            return(new _JetCryptCodecHandler_87(GetOldDecryptionKey(buffer, channel.GetFormat
                                                                        ())));
        }
Exemplo n.º 4
0
        /// <exception cref="System.IO.IOException"></exception>
        public static CodecHandler Create(PageChannel channel)
        {
            ByteBuffer buffer = ReadHeaderPage(channel);
            JetFormat  format = channel.GetFormat();

            byte[] encodingKey = new byte[ENCODING_KEY_LENGTH];
            buffer.Position(format.OFFSET_ENCODING_KEY);
            buffer.Get(encodingKey);
            bool clearData = true;

            foreach (byte byteVal in encodingKey)
            {
                if (byteVal != 0)
                {
                    clearData = false;
                }
            }
            return(clearData ? DefaultCodecProvider.DUMMY_HANDLER : new HealthMarketScience.Jackcess.JetCryptCodecHandler
                       (encodingKey));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Returns a ByteBuffer of at least the defined page size, with the limit
 /// set to the page size, and the predefined byteOrder.
 /// </summary>
 /// <remarks>
 /// Returns a ByteBuffer of at least the defined page size, with the limit
 /// set to the page size, and the predefined byteOrder.  Will be rewound iff
 /// autoRewind is enabled for this buffer.
 /// </remarks>
 public ByteBuffer GetPageBuffer(PageChannel pageChannel)
 {
     return(GetBuffer(pageChannel, pageChannel.GetFormat().PAGE_SIZE));
 }