Skip to content

Commit 66e55f7

Browse files
committed
spn naming feedback
1 parent bbb5636 commit 66e55f7

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIProxy.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ internal class SNIProxy
3434
/// <param name="fullServerName">Full server name from connection string</param>
3535
/// <param name="timeout">Timer expiration</param>
3636
/// <param name="instanceName">Instance name</param>
37-
/// <param name="spnBuffer">SPN</param>
37+
/// <param name="spns">SPNs</param>
3838
/// <param name="serverSPN">pre-defined SPN</param>
3939
/// <param name="flushCache">Flush packet cache</param>
4040
/// <param name="async">Asynchronous connection</param>
@@ -51,7 +51,7 @@ internal static SNIHandle CreateConnectionHandle(
5151
string fullServerName,
5252
TimeoutTimer timeout,
5353
out byte[] instanceName,
54-
ref string[] spnBuffer,
54+
ref string[] spns,
5555
string serverSPN,
5656
bool flushCache,
5757
bool async,
@@ -103,7 +103,7 @@ internal static SNIHandle CreateConnectionHandle(
103103
{
104104
try
105105
{
106-
spnBuffer = GetSqlServerSPNs(details, serverSPN);
106+
spns = GetSqlServerSPNs(details, serverSPN);
107107
}
108108
catch (Exception e)
109109
{

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ internal sealed partial class TdsParser
112112

113113
private bool _is2022 = false;
114114

115-
private string[] _sniSpn = null;
115+
private string[] _serverSpn = null;
116116

117117
// SqlStatistics
118118
private SqlStatistics _statistics = null;
@@ -389,7 +389,7 @@ internal void Connect(
389389
}
390390
else
391391
{
392-
_sniSpn = null;
392+
_serverSpn = null;
393393
SqlClientEventSource.Log.TryTraceEvent("TdsParser.Connect | SEC | Connection Object Id {0}, Authentication Mode: {1}", _connHandler.ObjectID,
394394
authType == SqlAuthenticationMethod.NotSpecified ? SqlAuthenticationMethod.SqlPassword.ToString() : authType.ToString());
395395
}
@@ -401,7 +401,7 @@ internal void Connect(
401401
SqlClientEventSource.Log.TryTraceEvent("<sc.TdsParser.Connect|SEC> Encryption will be disabled as target server is a SQL Local DB instance.");
402402
}
403403

404-
_sniSpn = null;
404+
_serverSpn = null;
405405
_authenticationProvider = null;
406406

407407
// AD Integrated behaves like Windows integrated when connecting to a non-fedAuth server
@@ -440,7 +440,7 @@ internal void Connect(
440440
serverInfo.ExtendedServerName,
441441
timeout,
442442
out instanceName,
443-
ref _sniSpn,
443+
ref _serverSpn,
444444
false,
445445
true,
446446
fParallel,
@@ -539,7 +539,7 @@ internal void Connect(
539539
_physicalStateObj.CreatePhysicalSNIHandle(
540540
serverInfo.ExtendedServerName,
541541
timeout, out instanceName,
542-
ref _sniSpn,
542+
ref _serverSpn,
543543
true,
544544
true,
545545
fParallel,
@@ -13316,7 +13316,7 @@ internal string TraceString()
1331613316
_fMARS ? bool.TrueString : bool.FalseString,
1331713317
_sessionPool == null ? "(null)" : _sessionPool.TraceString(),
1331813318
_is2005 ? bool.TrueString : bool.FalseString,
13319-
_sniSpn == null ? "(null)" : _sniSpn.Length.ToString((IFormatProvider)null),
13319+
_serverSpn == null ? "(null)" : _serverSpn.Length.ToString((IFormatProvider)null),
1332013320
_physicalStateObj != null ? "(null)" : _physicalStateObj.ErrorCount.ToString((IFormatProvider)null),
1332113321
_physicalStateObj != null ? "(null)" : _physicalStateObj.WarningCount.ToString((IFormatProvider)null),
1332213322
_physicalStateObj != null ? "(null)" : _physicalStateObj.PreAttentionErrorCount.ToString((IFormatProvider)null),

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ internal int ObjectID
128128

129129
private bool _is2022 = false;
130130

131-
private string _sniSpn = null;
131+
private string _serverSpn = null;
132132

133133
// UNDONE - need to have some for both instances - both command and default???
134134

@@ -432,13 +432,13 @@ internal void Connect(ServerInfo serverInfo,
432432
{
433433
if (!string.IsNullOrEmpty(serverInfo.ServerSPN))
434434
{
435-
_sniSpn = serverInfo.ServerSPN;
435+
_serverSpn = serverInfo.ServerSPN;
436436
SqlClientEventSource.Log.TryTraceEvent("<sc.TdsParser.Connect|SEC> Server SPN `{0}` from the connection string is used.", serverInfo.ServerSPN);
437437
}
438438
else
439439
{
440-
// Empty signifies to interop layer that SNI needs to be generated
441-
_sniSpn = string.Empty;
440+
// Empty signifies to interop layer that SPN needs to be generated
441+
_serverSpn = string.Empty;
442442
}
443443

444444
_authenticationProvider = _physicalStateObj.CreateSSPIContextProvider();
@@ -447,7 +447,7 @@ internal void Connect(ServerInfo serverInfo,
447447
else
448448
{
449449
_authenticationProvider = null;
450-
_sniSpn = null;
450+
_serverSpn = null;
451451

452452
switch (authType)
453453
{
@@ -526,7 +526,7 @@ internal void Connect(ServerInfo serverInfo,
526526
serverInfo.ExtendedServerName,
527527
timeout,
528528
out instanceName,
529-
ref _sniSpn,
529+
ref _serverSpn,
530530
false,
531531
true,
532532
fParallel,
@@ -626,7 +626,7 @@ internal void Connect(ServerInfo serverInfo,
626626
serverInfo.ExtendedServerName,
627627
timeout,
628628
out instanceName,
629-
ref _sniSpn,
629+
ref _serverSpn,
630630
true,
631631
true,
632632
fParallel,
@@ -13782,7 +13782,7 @@ internal string TraceString()
1378213782
_is2000 ? bool.TrueString : bool.FalseString,
1378313783
_is2000SP1 ? bool.TrueString : bool.FalseString,
1378413784
_is2005 ? bool.TrueString : bool.FalseString,
13785-
_sniSpn == null ? "(null)" : _sniSpn.Length.ToString((IFormatProvider)null),
13785+
_serverSpn == null ? "(null)" : _serverSpn.Length.ToString((IFormatProvider)null),
1378613786
_physicalStateObj != null ? "(null)" : _physicalStateObj.ErrorCount.ToString((IFormatProvider)null),
1378713787
_physicalStateObj != null ? "(null)" : _physicalStateObj.WarningCount.ToString((IFormatProvider)null),
1378813788
_physicalStateObj != null ? "(null)" : _physicalStateObj.PreAttentionErrorCount.ToString((IFormatProvider)null),

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NativeSSPIContextProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private void LoadSSPILibrary()
4949
}
5050
}
5151

52-
protected override void GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter, ReadOnlySpan<string> _sniSpnBuffer)
52+
protected override void GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter, ReadOnlySpan<string> serverSpn)
5353
{
5454
#if NETFRAMEWORK
5555
SNIHandle handle = _physicalStateObj.Handle;
@@ -62,7 +62,7 @@ protected override void GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlo
6262
var sendLength = s_maxSSPILength;
6363
var outBuff = outgoingBlobWriter.GetSpan((int)sendLength);
6464

65-
if (0 != SniNativeWrapper.SNISecGenClientContext(handle, incomingBlob, outBuff, ref sendLength, _sniSpnBuffer[0]))
65+
if (0 != SniNativeWrapper.SNISecGenClientContext(handle, incomingBlob, outBuff, ref sendLength, serverSpn[0]))
6666
{
6767
throw new InvalidOperationException(SQLMessage.SSPIGenerateError());
6868
}

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SSPIContextProvider.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ private protected virtual void Initialize()
2626
{
2727
}
2828

29-
protected abstract void GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter, ReadOnlySpan<string> _sniSpnBuffer);
29+
protected abstract void GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter, ReadOnlySpan<string> serverSpn);
3030

31-
internal void SSPIData(ReadOnlySpan<byte> receivedBuff, IBufferWriter<byte> outgoingBlobWriter, string sniSpnBuffer)
32-
=> SSPIData(receivedBuff, outgoingBlobWriter, new[] { sniSpnBuffer });
31+
internal void SSPIData(ReadOnlySpan<byte> receivedBuff, IBufferWriter<byte> outgoingBlobWriter, string serverSpn)
32+
=> SSPIData(receivedBuff, outgoingBlobWriter, new[] { serverSpn });
3333

34-
internal void SSPIData(ReadOnlySpan<byte> receivedBuff, IBufferWriter<byte> outgoingBlobWriter, string[] sniSpnBuffer)
34+
internal void SSPIData(ReadOnlySpan<byte> receivedBuff, IBufferWriter<byte> outgoingBlobWriter, string[] serverSpn)
3535
{
3636
using (TrySNIEventScope.Create(nameof(SSPIContextProvider)))
3737
{
3838
try
3939
{
40-
GenerateSspiClientContext(receivedBuff, outgoingBlobWriter, sniSpnBuffer);
40+
GenerateSspiClientContext(receivedBuff, outgoingBlobWriter, serverSpn);
4141
}
4242
catch (Exception e)
4343
{

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal void ProcessSSPI(int receivedLength)
2929
var writer = SqlObjectPools.BufferWriter.Rent();
3030

3131
// make call for SSPI data
32-
_authenticationProvider!.SSPIData(receivedBuff.AsSpan(0, receivedLength), writer, _sniSpn);
32+
_authenticationProvider!.SSPIData(receivedBuff.AsSpan(0, receivedLength), writer, _serverSpn);
3333

3434
// DO NOT SEND LENGTH - TDS DOC INCORRECT! JUST SEND SSPI DATA!
3535
_physicalStateObj.WriteByteSpan(writer.WrittenSpan);
@@ -159,7 +159,7 @@ internal void TdsLogin(
159159
// byte[] buffer and 0 for the int length.
160160
Debug.Assert(SniContext.Snix_Login == _physicalStateObj.SniContext, $"Unexpected SniContext. Expecting Snix_Login, actual value is '{_physicalStateObj.SniContext}'");
161161
_physicalStateObj.SniContext = SniContext.Snix_LoginSspi;
162-
_authenticationProvider.SSPIData(ReadOnlySpan<byte>.Empty, sspiWriter, _sniSpn);
162+
_authenticationProvider.SSPIData(ReadOnlySpan<byte>.Empty, sspiWriter, _serverSpn);
163163

164164
_physicalStateObj.SniContext = SniContext.Snix_Login;
165165

0 commit comments

Comments
 (0)