Skip to content

Commit 33f6cb3

Browse files
committed
CSHARP-603: changes from MONGO-CR to MONGODB-CR per server.
1 parent f819fb5 commit 33f6cb3

File tree

7 files changed

+18
-20
lines changed

7 files changed

+18
-20
lines changed

MongoDB.Driver/Communication/Security/Authenticator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal class Authenticator
3030
// private static fields
3131
private static readonly List<IAuthenticationProtocol> __clientSupportedProtocols = new List<IAuthenticationProtocol>
3232
{
33-
// when we start negotiating, MONGO-CR should be moved to the bottom of the list...
33+
// when we start negotiating, MONGODB-CR should be moved to the bottom of the list...
3434
new MongoCRAuthenticationProtocol(),
3535
new SaslAuthenticationProtocol(new GssapiMechanism()),
3636
};

MongoDB.Driver/Communication/Security/MongoCRAuthenticationProtocol.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
namespace MongoDB.Driver.Communication.Security
2121
{
2222
/// <summary>
23-
/// Authenticates a credential using the MONGO-CR protocol.
23+
/// Authenticates a credential using the MONGODB-CR protocol.
2424
/// </summary>
2525
internal class MongoCRAuthenticationProtocol : IAuthenticationProtocol
2626
{
2727
// public properties
2828
public string Name
2929
{
30-
get { return "MONGO-CR"; }
30+
get { return "MONGODB-CR"; }
3131
}
3232

3333
// public methods
@@ -77,7 +77,7 @@ public void Authenticate(MongoConnection connection, MongoCredential credential)
7777
/// </returns>
7878
public bool CanUse(MongoCredential credential)
7979
{
80-
return credential.Mechanism.Equals("MONGO-CR", StringComparison.InvariantCultureIgnoreCase) &&
80+
return credential.Mechanism.Equals("MONGODB-CR", StringComparison.InvariantCultureIgnoreCase) &&
8181
credential.Evidence is PasswordEvidence;
8282
}
8383
}

MongoDB.Driver/MongoCredential.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,30 +180,30 @@ public static MongoCredential CreateGssapiCredential(string username, SecureStri
180180
}
181181

182182
/// <summary>
183-
/// Creates a credential used with MONGO-CR.
183+
/// Creates a credential used with MONGODB-CR.
184184
/// </summary>
185185
/// <param name="databaseName">Name of the database.</param>
186186
/// <param name="username">The username.</param>
187187
/// <param name="password">The password.</param>
188188
/// <returns></returns>
189189
public static MongoCredential CreateMongoCRCredential(string databaseName, string username, string password)
190190
{
191-
return FromComponents("MONGO-CR",
191+
return FromComponents("MONGODB-CR",
192192
databaseName,
193193
username,
194194
new PasswordEvidence(password));
195195
}
196196

197197
/// <summary>
198-
/// Creates a credential used with MONGO-CR.
198+
/// Creates a credential used with MONGODB-CR.
199199
/// </summary>
200200
/// <param name="databaseName">Name of the database.</param>
201201
/// <param name="username">The username.</param>
202202
/// <param name="password">The password.</param>
203203
/// <returns></returns>
204204
public static MongoCredential CreateMongoCRCredential(string databaseName, string username, SecureString password)
205205
{
206-
return FromComponents("MONGO-CR",
206+
return FromComponents("MONGODB-CR",
207207
databaseName,
208208
username,
209209
new PasswordEvidence(password));
@@ -288,24 +288,22 @@ private static MongoCredential FromComponents(string mechanism, string source, s
288288

289289
switch (mechanism.ToUpperInvariant())
290290
{
291-
case "MONGO-CR":
291+
case "MONGODB-CR":
292292
// it is allowed for a password to be an empty string, but not a username
293293
source = source ?? "admin";
294294
if (evidence == null || !(evidence is PasswordEvidence))
295295
{
296-
throw new ArgumentException("A MONGO-CR credential must have a password.");
296+
throw new ArgumentException("A MONGODB-CR credential must have a password.");
297297
}
298298

299299
return new MongoCredential(
300300
mechanism,
301301
new MongoInternalIdentity(source, username),
302302
evidence);
303303
case "GSSAPI":
304-
source = source ?? "$external";
305-
if (source != "$external")
306-
{
307-
throw new ArgumentException("The source for GSSAPI must be $external.");
308-
}
304+
// always $external for GSSAPI.
305+
// this will likely need to change in 2.6.
306+
source = "$external";
309307

310308
return new MongoCredential(
311309
"GSSAPI",

MongoDB.Driver/MongoDefaults.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static class MongoDefaults
2525
{
2626
// private static fields
2727
private static bool __assignIdOnInsert = true;
28-
private static string __authenticationMechanism = "MONGO-CR";
28+
private static string __authenticationMechanism = "MONGODB-CR";
2929
private static TimeSpan __connectTimeout = TimeSpan.FromSeconds(30);
3030
private static TimeSpan __maxConnectionIdleTime = TimeSpan.FromMinutes(10);
3131
private static TimeSpan __maxConnectionLifeTime = TimeSpan.FromMinutes(30);

MongoDB.Driver/MongoUrlBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ public override string ToString()
10001000
url.Append(_databaseName);
10011001
}
10021002
var query = new StringBuilder();
1003-
if (!_authenticationMechanism.Equals("MONGO-CR", StringComparison.InvariantCultureIgnoreCase))
1003+
if (!_authenticationMechanism.Equals("MONGODB-CR", StringComparison.InvariantCultureIgnoreCase))
10041004
{
10051005
query.AppendFormat("authMechanism={0};", _authenticationMechanism);
10061006
}

MongoDB.DriverUnitTests/MongoConnectionStringBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void TestAll()
135135
}
136136

137137
[Test]
138-
[TestCase("MONGO-CR", "server=localhost;authMechanism=MONGO-CR")]
138+
[TestCase("MONGODB-CR", "server=localhost;authMechanism=MONGODB-CR")]
139139
[TestCase("GSSAPI", "server=localhost;authMechanism=GSSAPI")]
140140
public void TestAuthMechanism(string mechanism, string connectionString)
141141
{

MongoDB.DriverUnitTests/MongoUrlBuilderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public void TestAll()
131131
}
132132

133133
[Test]
134-
[TestCase("MONGO-CR", "mongodb://localhost")]
134+
[TestCase("MONGODB-CR", "mongodb://localhost")]
135135
[TestCase("GSSAPI", "mongodb://localhost/?authMechanism=GSSAPI")]
136136
public void TestAuthMechanism(string mechanism, string connectionString)
137137
{
@@ -279,7 +279,7 @@ public void TestDefaults()
279279

280280
foreach (var builder in EnumerateBuiltAndParsedBuilders(built, connectionString))
281281
{
282-
Assert.AreEqual("MONGO-CR", builder.AuthenticationMechanism);
282+
Assert.AreEqual("MONGODB-CR", builder.AuthenticationMechanism);
283283
Assert.AreEqual(null, builder.AuthenticationSource);
284284
Assert.AreEqual(MongoDefaults.ComputedWaitQueueSize, builder.ComputedWaitQueueSize);
285285
Assert.AreEqual(ConnectionMode.Automatic, builder.ConnectionMode);

0 commit comments

Comments
 (0)