2929import com .mongodb .operation .CommandReadOperation ;
3030import com .mongodb .operation .CommandWriteOperation ;
3131import com .mongodb .operation .CreateCollectionOperation ;
32- import com .mongodb .operation .CreateUserOperation ;
3332import com .mongodb .operation .CreateViewOperation ;
3433import com .mongodb .operation .DropDatabaseOperation ;
35- import com .mongodb .operation .DropUserOperation ;
3634import com .mongodb .operation .ListCollectionsOperation ;
3735import com .mongodb .operation .ReadOperation ;
38- import com .mongodb .operation .UpdateUserOperation ;
39- import com .mongodb .operation .UserExistsOperation ;
4036import org .bson .BsonDocument ;
4137import org .bson .BsonDocumentWrapper ;
4238import org .bson .BsonInt32 ;
5248import java .util .concurrent .ConcurrentHashMap ;
5349
5450import static com .mongodb .DBCollection .createWriteConcernException ;
55- import static com .mongodb .MongoCredential .createMongoCRCredential ;
51+ import static com .mongodb .MongoCredential .createCredential ;
5652import static com .mongodb .MongoNamespace .checkDatabaseNameValidity ;
5753import static com .mongodb .ReadPreference .primary ;
5854import static com .mongodb .assertions .Assertions .notNull ;
@@ -604,6 +600,7 @@ public CommandResult getStats() {
604600 /**
605601 * Adds or updates a user for this database
606602 *
603+ * <p>Never create or modify users over an insecure network without the use of TLS.</p>
607604 * @param userName the user name
608605 * @param password the password
609606 * @return the result of executing this operation
@@ -621,6 +618,7 @@ public WriteResult addUser(final String userName, final char[] password) {
621618 /**
622619 * Adds or updates a user for this database
623620 *
621+ * <p>Never create or modify users over an insecure network without the use of TLS.</p>
624622 * @param userName the user name
625623 * @param password the password
626624 * @param readOnly if true, user will only be able to read
@@ -633,21 +631,21 @@ public WriteResult addUser(final String userName, final char[] password) {
633631 */
634632 @ Deprecated
635633 public WriteResult addUser (final String userName , final char [] password , final boolean readOnly ) {
636- MongoCredential credential = createMongoCRCredential (userName , getName (), password );
634+ MongoCredential credential = createCredential (userName , getName (), password );
637635 boolean userExists = false ;
638636 try {
639- userExists = executor .execute (new UserExistsOperation (getName (), userName ), primary ());
637+ userExists = executor .execute (new com . mongodb . operation . UserExistsOperation (getName (), userName ), primary ());
640638 } catch (MongoCommandException e ) {
641639 if (e .getCode () != 13 ) {
642640 throw e ;
643641 }
644642 }
645643 try {
646644 if (userExists ) {
647- executor .execute (new UpdateUserOperation (credential , readOnly , getWriteConcern ()));
645+ executor .execute (new com . mongodb . operation . UpdateUserOperation (credential , readOnly , getWriteConcern ()));
648646 return new WriteResult (1 , true , null );
649647 } else {
650- executor .execute (new CreateUserOperation (credential , readOnly , getWriteConcern ()));
648+ executor .execute (new com . mongodb . operation . CreateUserOperation (credential , readOnly , getWriteConcern ()));
651649 return new WriteResult (1 , false , null );
652650 }
653651 } catch (MongoWriteConcernException e ) {
@@ -667,7 +665,7 @@ public WriteResult addUser(final String userName, final char[] password, final b
667665 @ Deprecated
668666 public WriteResult removeUser (final String userName ) {
669667 try {
670- executor .execute (new DropUserOperation (getName (), userName , getWriteConcern ()));
668+ executor .execute (new com . mongodb . operation . DropUserOperation (getName (), userName , getWriteConcern ()));
671669 return new WriteResult (1 , true , null );
672670 } catch (MongoWriteConcernException e ) {
673671 throw createWriteConcernException (e );
0 commit comments