[pgsqlclient-checkins] pgsqlclient_10/PgSqlClient.Security.Tls/source TlsException.cs,1.3,1.4 TlsSes
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2003-10-03 19:09:49
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source In directory sc8-pr-cvs1:/tmp/cvs-serv19029 Modified Files: TlsException.cs TlsSession.cs TlsSocket.cs Log Message: Added some changes to exception handling Index: TlsException.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsException.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TlsException.cs 1 Sep 2003 11:11:08 -0000 1.3 --- TlsException.cs 3 Oct 2003 19:09:44 -0000 1.4 *************** *** 28,52 **** public sealed class TlsException : Exception { - #region FIELDS - - private TlsAlertLevel alertLevel; - private TlsAlertDescription alertDescription; - - #endregion - - #region PROPERTIES - - public TlsAlertLevel AlertLevel - { - get { return alertLevel; } - } - - public TlsAlertDescription AlertDescription - { - get { return alertDescription; } - } - - #endregion - #region CONSTRUCTORS --- 28,31 ---- *************** *** 55,66 **** } - internal TlsException(TlsAlertLevel alertLevel, - TlsAlertDescription alertDescription, - string message) : base(message) - { - this.alertLevel = alertLevel; - this.alertDescription = alertDescription; - } - internal TlsException(SerializationInfo info, StreamingContext context) : base(info, context) { --- 34,37 ---- *************** *** 69,81 **** internal TlsException(string message, Exception ex) : base(message, ex) { - } - - internal TlsException(TlsAlertLevel alertLevel, - TlsAlertDescription alertDescription, - string message, - Exception ex) : base(message, ex) - { - this.alertLevel = alertLevel; - this.alertDescription = alertDescription; } --- 40,43 ---- Index: TlsSession.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsSession.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** TlsSession.cs 3 Oct 2003 18:45:29 -0000 1.20 --- TlsSession.cs 3 Oct 2003 19:09:44 -0000 1.21 *************** *** 124,141 **** #region EXCEPTION_METHODS ! internal void ThrowException(TlsAlertLevel alertLevel, TlsAlertDescription alertDesc) { ! // Throw an exception will made the connection unavailable ! // for this both streams will be closed ! closeStreams(); ! // Throw exception ! throw new TlsException( ! alertLevel, ! alertDesc, ! TlsAlert.GetAlertMessage(alertDesc)); } ! internal void ThrowException(string message) { // Throw an exception will made the connection unavailable --- 124,141 ---- #region EXCEPTION_METHODS ! internal TlsException CreateException(TlsAlertLevel alertLevel, TlsAlertDescription alertDesc) { ! return CreateException(TlsAlert.GetAlertMessage(alertDesc)); ! } ! internal TlsException CreateException(string format, params object[] args) ! { ! StringBuilder message = new StringBuilder(); ! message.AppendFormat(format, args); ! ! return CreateException(message.ToString()); } ! internal TlsException CreateException(string message) { // Throw an exception will made the connection unavailable *************** *** 143,148 **** closeStreams(); ! // Throw exception ! throw new TlsException(message); } --- 143,147 ---- closeStreams(); ! return new TlsException(message); } *************** *** 242,246 **** default: ! throw new InvalidOperationException("Unknown server handshake message type: " + type.ToString() ); } } --- 241,245 ---- default: ! throw CreateException("Unknown server handshake message received ({0})", type.ToString()); } } Index: TlsSocket.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsSocket.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TlsSocket.cs 3 Oct 2003 18:45:29 -0000 1.6 --- TlsSocket.cs 3 Oct 2003 19:09:44 -0000 1.7 *************** *** 178,182 **** if (session.Context.ConnectionEnd) { ! session.ThrowException("The session is finished and it's no longer valid."); } --- 178,182 ---- if (session.Context.ConnectionEnd) { ! throw session.CreateException("The session is finished and it's no longer valid."); } *************** *** 199,203 **** if (protocol != TlsProtocol.Tls1) { ! session.ThrowException("Invalid protocol version on message received from server"); } --- 199,203 ---- if (protocol != TlsProtocol.Tls1) { ! throw session.CreateException("Invalid protocol version on message received from server"); } *************** *** 247,252 **** default: ! session.ThrowException("Unknown record received from server."); ! break; } --- 247,251 ---- default: ! throw session.CreateException("Unknown record received from server."); } *************** *** 375,379 **** if (session.Context.ConnectionEnd) { ! session.ThrowException("The session is finished and it's no longer valid."); } --- 374,378 ---- if (session.Context.ConnectionEnd) { ! throw session.CreateException("The session is finished and it's no longer valid."); } *************** *** 468,473 **** { case TlsAlertLevel.Fatal: ! session.ThrowException(alertLevel, alertDesc); ! break; case TlsAlertLevel.Warning: --- 467,471 ---- { case TlsAlertLevel.Fatal: ! throw session.CreateException(alertLevel, alertDesc); case TlsAlertLevel.Warning: |