public MongoCredential withMechanism ( final AuthenticationMechanism mechanism ) { if ( this . mechanism != null ) { throw new IllegalArgumentException ( "Mechanism already set" ) ; } return new MongoCredential ( mechanism , userName , source , password , mechanismProperties ) ; }
Creates a new MongoCredential with the set mechanism . The existing mechanism must be null .