[pgsqlclient-checkins] pgsqlclient_10/PgSqlClient.Security.Tls/source TlsReader.cs,1.10,1.11
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2003-09-01 11:56:57
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source In directory sc8-pr-cvs1:/tmp/cvs-serv30270 Modified Files: TlsReader.cs Log Message: - Changed namespace name to a more standard name. - Changed the way for use TLS readers and writers, now the TlsSession class handles the socket used for connect to a server. - Improvements to TlsWriter class for better handling of application data records. Index: TlsReader.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsReader.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TlsReader.cs 1 Sep 2003 11:11:08 -0000 1.10 --- TlsReader.cs 1 Sep 2003 11:56:52 -0000 1.11 *************** *** 32,35 **** --- 32,36 ---- private TlsSession session; + private Encoding encoding; #endregion *************** *** 48,52 **** internal TlsReader(TlsSession session, Stream input, Encoding encoding) : base(input, encoding) { ! this.session = session; } --- 49,54 ---- internal TlsReader(TlsSession session, Stream input, Encoding encoding) : base(input, encoding) { ! this.session = session; ! this.encoding = encoding; } *************** *** 55,59 **** #region TLS_METHODS ! public byte[] ReadRecord() { if (session.State.ConnectionEnd) --- 57,317 ---- #region TLS_METHODS ! public override int Read() ! { ! if (session.IsSecure) ! { ! byte[] buffer = this.ReadRecord(); ! ! return buffer.Length; ! } ! else ! { ! return base.Read(); ! } ! } ! ! public override int Read(byte[] buffer, int index, int count) ! { ! if (session.IsSecure) ! { ! byte[] bytes = this.ReadRecord(); ! System.Array.Copy(bytes, 0, buffer, index, count); ! ! return count; ! } ! else ! { ! return base.Read(buffer, index, count); ! } ! } ! ! public override int Read(char[] buffer, int index, int count) ! { ! if (session.IsSecure) ! { ! byte[] bytes = this.ReadRecord(); ! encoding.GetChars(bytes, 0, count, buffer, index); ! ! return count; ! } ! else ! { ! return base.Read(buffer, index, count); ! } ! } ! ! public override bool ReadBoolean() ! { ! if (session.IsSecure) ! { ! return BitConverter.ToBoolean(this.ReadRecord(), 0); ! } ! else ! { ! return base.ReadBoolean(); ! } ! } ! ! public override byte ReadByte() ! { ! if (session.IsSecure) ! { ! return this.ReadRecord()[0]; ! } ! else ! { ! return base.ReadByte(); ! } ! } ! ! public byte[] ReadBytes() ! { ! if (session.IsSecure) ! { ! return this.ReadRecord(); ! } ! else ! { ! return base.ReadBytes((int)this.BaseStream.Length); ! } ! } ! ! public override byte[] ReadBytes(int count) ! { ! if (session.IsSecure) ! { ! return this.ReadRecord(); ! } ! else ! { ! return base.ReadBytes(count); ! } ! } ! ! public override char ReadChar() ! { ! if (session.IsSecure) ! { ! return (char)this.ReadRecord()[0]; ! } ! else ! { ! return base.ReadChar(); ! } ! } ! ! public override char[] ReadChars(int count) ! { ! if (session.IsSecure) ! { ! return encoding.GetChars(this.ReadRecord()); ! } ! else ! { ! return base.ReadChars(count); ! } ! } ! ! public override decimal ReadDecimal() ! { ! if (session.IsSecure) ! { ! throw new NotSupportedException("ReadDecimal() method can be used with a secure connection."); ! } ! else ! { ! return base.ReadDecimal(); ! } ! } ! ! public override double ReadDouble() ! { ! if (session.IsSecure) ! { ! return BitConverter.ToDouble(this.ReadRecord(), 0); ! } ! else ! { ! return base.ReadDouble(); ! } ! } ! ! public override short ReadInt16() ! { ! if (session.IsSecure) ! { ! return BitConverter.ToInt16(this.ReadRecord(), 0); ! } ! else ! { ! return base.ReadInt16(); ! } ! } ! ! public override int ReadInt32() ! { ! if (session.IsSecure) ! { ! return BitConverter.ToInt32(this.ReadRecord(), 0); ! } ! else ! { ! return base.ReadInt32(); ! } ! } ! ! public override long ReadInt64() ! { ! if (session.IsSecure) ! { ! return BitConverter.ToInt64(this.ReadRecord(), 0); ! } ! else ! { ! return base.ReadInt64(); ! } ! } ! ! [CLSCompliant(false)] ! public override sbyte ReadSByte() ! { ! if (session.IsSecure) ! { ! return (sbyte)this.ReadRecord()[0]; ! } ! else ! { ! return base.ReadSByte(); ! } ! } ! ! public override float ReadSingle() ! { ! if (session.IsSecure) ! { ! return BitConverter.ToSingle(this.ReadRecord(), 0); ! } ! else ! { ! return base.ReadSingle(); ! } ! } ! ! public override string ReadString() ! { ! if (session.IsSecure) ! { ! return encoding.GetString(this.ReadRecord()); ! } ! else ! { ! return base.ReadString(); ! } ! } ! ! [CLSCompliant(false)] ! public override ushort ReadUInt16() ! { ! if (session.IsSecure) ! { ! return BitConverter.ToUInt16(this.ReadRecord(), 0); ! } ! else ! { ! return base.ReadUInt16(); ! } ! } ! ! [CLSCompliant(false)] ! public override uint ReadUInt32() ! { ! if (session.IsSecure) ! { ! return BitConverter.ToUInt32(this.ReadRecord(), 0); ! } ! else ! { ! return base.ReadUInt32(); ! } ! } ! ! [CLSCompliant(false)] ! public override ulong ReadUInt64() ! { ! if (session.IsSecure) ! { ! return BitConverter.ToUInt64(this.ReadRecord(), 0); ! } ! else ! { ! return base.ReadUInt64(); ! } ! } ! ! #endregion ! ! #region INTERNAL_METHODS ! ! internal byte[] ReadRecord() { if (session.State.ConnectionEnd) *************** *** 64,72 **** byte[] result = null; ! TlsContentType contentType = (TlsContentType)this.ReadByte(); TlsProtocol protocol = (TlsProtocol)this.ReadShort(); int length = this.ReadShort(); ! byte[] message = ReadBytes(length); // Check that the message as a valid protocol version --- 322,330 ---- byte[] result = null; ! TlsContentType contentType = (TlsContentType)base.ReadByte(); TlsProtocol protocol = (TlsProtocol)this.ReadShort(); int length = this.ReadShort(); ! byte[] message = base.ReadBytes(length); // Check that the message as a valid protocol version *************** *** 117,124 **** return result; } - - #endregion - - #region INTERNAL_METHODS internal short ReadShort() --- 375,378 ---- |