From: <cin...@us...> - 2009-08-30 12:03:51
|
Revision: 1006 http://firebird.svn.sourceforge.net/firebird/?rev=1006&view=rev Author: cincura_net Date: 2009-08-30 12:01:41 +0000 (Sun, 30 Aug 2009) Log Message: ----------- Initial work on protocol 12 - isc_dpb_utf8_filename. Modified Paths: -------------- NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version10/GdsConnection.cs NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version10/GdsDatabase.cs NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version11/GdsDatabase.cs NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdClient/ClientFactory.cs NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdSql.Data.FirebirdClient.csproj Added Paths: ----------- NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version12/ NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version12/GdsDatabase.cs Modified: NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version10/GdsConnection.cs =================================================================== --- NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version10/GdsConnection.cs 2009-08-16 21:03:30 UTC (rev 1005) +++ NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version10/GdsConnection.cs 2009-08-30 12:01:41 UTC (rev 1006) @@ -168,7 +168,7 @@ outputStream.Write(1); // Architecture of client - Generic outputStream.Write(database); // Database path - outputStream.Write(2); // Protocol versions understood + outputStream.Write(3); // Protocol versions understood outputStream.WriteBuffer(user_id.ToArray()); // User identification Stuff outputStream.Write(IscCodes.PROTOCOL_VERSION10);// Protocol version @@ -182,6 +182,12 @@ outputStream.Write(2); // Minumum type (ptype_rpc) outputStream.Write(5); // Maximum type (ptype_lazy_send) outputStream.Write(1); // Preference weight + + outputStream.Write(IscCodes.PROTOCOL_VERSION12);// Protocol version + outputStream.Write(1); // Architecture of client - Generic + outputStream.Write(2); // Minumum type (ptype_rpc) + outputStream.Write(5); // Maximum type (ptype_lazy_send) + outputStream.Write(2); // Preference weight } outputStream.Flush(); @@ -193,7 +199,8 @@ if (this.protocolVersion < 0) { - this.protocolVersion = (this.protocolVersion & IscCodes.FB_PROTOCOL_FLAG) | 11; + //this.protocolVersion = (this.protocolVersion & IscCodes.FB_PROTOCOL_FLAG) | 11; + this.protocolVersion = (ushort)(this.protocolVersion & IscCodes.FB_PROTOCOL_MASK) | IscCodes.FB_PROTOCOL_FLAG; } } else Modified: NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version10/GdsDatabase.cs =================================================================== --- NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version10/GdsDatabase.cs 2009-08-16 21:03:30 UTC (rev 1005) +++ NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version10/GdsDatabase.cs 2009-08-30 12:01:41 UTC (rev 1006) @@ -202,15 +202,9 @@ { try { - // Attach to the database - this.Write(IscCodes.op_attach); - this.Write((int)0); // Database object ID - this.Write(database); // Database PATH - this.WriteBuffer(dpb.ToArray()); // DPB Parameter buffer + SendAttachToBuffer(dpb, database); this.Flush(); - - // Save the database connection handle - this.handle = this.ReadGenericResponse().ObjectHandle; + ProcessAttachResponse(this.ReadGenericResponse()); } catch (IOException) { @@ -230,6 +224,21 @@ } } + protected virtual void SendAttachToBuffer(DatabaseParameterBuffer dpb, string database) + { + // Attach to the database + this.Write(IscCodes.op_attach); + this.Write((int)0); // Database object ID + this.Write(database); // Database PATH + this.WriteBuffer(dpb.ToArray()); // DPB Parameter buffer + } + + protected virtual void ProcessAttachResponse(GenericResponse response) + { + // Save the database connection handle + this.handle = response.ObjectHandle; + } + public virtual void AttachWithTrustedAuth(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { throw new NotSupportedException("Trusted Auth isn't supported on < FB2.1."); Modified: NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version11/GdsDatabase.cs =================================================================== --- NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version11/GdsDatabase.cs 2009-08-16 21:03:30 UTC (rev 1005) +++ NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version11/GdsDatabase.cs 2009-08-30 12:01:41 UTC (rev 1006) @@ -75,27 +75,13 @@ using (SSPIHelper sspiHelper = new SSPIHelper()) { byte[] authData = sspiHelper.InitializeClientSecurity(); - dpb.Append(IscCodes.isc_dpb_trusted_auth, authData); - - // Attach to the database - this.Write(IscCodes.op_attach); - this.Write((int)0); // Database object ID - this.Write(database); // Database PATH - this.WriteBuffer(dpb.ToArray()); // DPB Parameter buffer + SendTrustedAuthToBuffer(dpb, authData); + SendAttachToBuffer(dpb, database); this.Flush(); IResponse response = this.ReadResponse(); - while (response is AuthResponse) - { - authData = sspiHelper.GetClientSecurity(((AuthResponse)response).Data); - this.Write(IscCodes.op_trusted_auth); - this.WriteBuffer(authData); - this.Flush(); - response = this.ReadResponse(); - } - - // Save the database connection handle - this.handle = ((GenericResponse)response).ObjectHandle; + ProcessTrustedAuthResponse(sspiHelper, ref response); + ProcessAttachResponse((GenericResponse)response); } } catch (IOException) @@ -118,6 +104,23 @@ throw new NotSupportedException(); #endif } + + protected virtual void SendTrustedAuthToBuffer(DatabaseParameterBuffer dpb, byte[] authData) + { + dpb.Append(IscCodes.isc_dpb_trusted_auth, authData); + } + + protected virtual void ProcessTrustedAuthResponse(SSPIHelper sspiHelper, ref IResponse response) + { + while (response is AuthResponse) + { + byte[] authData = sspiHelper.GetClientSecurity(((AuthResponse)response).Data); + this.Write(IscCodes.op_trusted_auth); + this.WriteBuffer(authData); + this.Flush(); + response = this.ReadResponse(); + } + } #endregion #region Public methods Added: NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version12/GdsDatabase.cs =================================================================== --- NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version12/GdsDatabase.cs (rev 0) +++ NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version12/GdsDatabase.cs 2009-08-30 12:01:41 UTC (rev 1006) @@ -0,0 +1,49 @@ +/* + * Firebird ADO.NET Data provider for .NET and Mono + * + * The contents of this file are subject to the Initial + * Developer's Public License Version 1.0 (the "License"); + * you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * http://www.firebirdsql.org/index.php?op=doc&id=idpl + * + * Software distributed under the License is distributed on + * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * Copyright (c) 2009 Jiri Cincura (ji...@ci...) + * + * All Rights Reserved. + */ + +using System; +using System.Collections; +using System.Data; +using System.Globalization; +using System.IO; +using System.Text; +using System.Net; +using System.Collections.Generic; + +using FirebirdSql.Data.Common; + +namespace FirebirdSql.Data.Client.Managed.Version12 +{ + internal class GdsDatabase : Version11.GdsDatabase + { + public GdsDatabase(Version10.GdsConnection connection) + : base(connection) + { } + + protected override void SendAttachToBuffer(DatabaseParameterBuffer dpb, string database) + { + // Attach to the database + this.Write(IscCodes.op_attach); + this.Write((int)0); // Database object ID + dpb.Append(IscCodes.isc_dpb_utf8_filename, 0); + this.WriteBuffer(Encoding.UTF8.GetBytes(database)); // Database PATH + this.WriteBuffer(dpb.ToArray()); // DPB Parameter buffer + } + } +} \ No newline at end of file Modified: NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdClient/ClientFactory.cs =================================================================== --- NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdClient/ClientFactory.cs 2009-08-16 21:03:30 UTC (rev 1005) +++ NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdClient/ClientFactory.cs 2009-08-30 12:01:41 UTC (rev 1006) @@ -82,7 +82,8 @@ switch (connection.ProtocolVersion) { - case IscCodes.PROTOCOL_VERSION12: + case IscCodes.PROTOCOL_VERSION12: + return new FirebirdSql.Data.Client.Managed.Version12.GdsDatabase(connection); case IscCodes.PROTOCOL_VERSION11: return new FirebirdSql.Data.Client.Managed.Version11.GdsDatabase(connection); case IscCodes.PROTOCOL_VERSION10: @@ -97,7 +98,7 @@ FirebirdSql.Data.Client.Managed.Version10.GdsConnection connection = new FirebirdSql.Data.Client.Managed.Version10.GdsConnection(options.DataSource, options.Port, options.PacketSize, Charset.GetCharset(options.Charset)); connection.Connect(); - connection.Identify(!String.IsNullOrEmpty(options.Database) ? options.Database : ""); + connection.Identify(!string.IsNullOrEmpty(options.Database) ? options.Database : string.Empty); switch (connection.ProtocolVersion) { Modified: NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdSql.Data.FirebirdClient.csproj =================================================================== --- NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdSql.Data.FirebirdClient.csproj 2009-08-16 21:03:30 UTC (rev 1005) +++ NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdSql.Data.FirebirdClient.csproj 2009-08-30 12:01:41 UTC (rev 1006) @@ -80,6 +80,7 @@ <ItemGroup> <Compile Include="Client\Managed\Version11\AuthResponse.cs" /> <Compile Include="Client\Managed\Version11\SSPIHelper.cs" /> + <Compile Include="Client\Managed\Version12\GdsDatabase.cs" /> <Compile Include="Entity\DmlSqlGenerator.cs" /> <Compile Include="Entity\ExpressionTranslator.cs" /> <Compile Include="Entity\FirstClause.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |