@@ -304,7 +304,7 @@ protected void close(){
304304 _socket = null ;
305305 }
306306
307- void checkAuth (DB db , final boolean writePrivilegesRequired ) throws IOException {
307+ void checkAuth (DB db ) throws IOException {
308308 // TODO: add support for retry when credentials ticket times out
309309 if (db .getMongo ().getCredentials () != null ) {
310310 if (!globallyAuthed ) {
@@ -314,14 +314,14 @@ void checkAuth(DB db, final boolean writePrivilegesRequired) throws IOException
314314 new GSSAPIAuthenticator (this , db .getMongo ()).authenticate ();
315315 globallyAuthed = true ;
316316 }
317- saslAquireDatabasePrivileges (db , writePrivilegesRequired );
317+ saslAcquirePrivilegeForDatabase (db );
318318 }
319319 else {
320320 DB .AuthenticationCredentials credentials = db .getAuthenticationCredentials ();
321321 if (credentials == null ) {
322322 if (db ._name .equals ("admin" ))
323323 return ;
324- checkAuth (db ._mongo .getDB ("admin" ), writePrivilegesRequired );
324+ checkAuth (db ._mongo .getDB ("admin" ));
325325 return ;
326326 }
327327 if (_authed .containsKey (db ))
@@ -337,24 +337,15 @@ void checkAuth(DB db, final boolean writePrivilegesRequired) throws IOException
337337 }
338338 }
339339
340- private void saslAquireDatabasePrivileges (final DB db , final boolean writePrivilegesRequired ) throws IOException {
340+ private void saslAcquirePrivilegeForDatabase (final DB db ) throws IOException {
341341 BasicDBObject acquirePrivilegeCmd = new BasicDBObject ("acquirePrivilege" , 1 ).
342- append ("principal" , db .getMongo ().getCredentials ().getUserName ()).append ("resource" , db .getName ());
343- if (writePrivilegesRequired ) {
344- if (_saslWriteAuthed .get (db ) == null ) {
345- acquirePrivilegeCmd .append ("actions" , Arrays .asList ("oldWrite" ));
346- CommandResult res = runCommand (db .getSisterDB ("admin" ), acquirePrivilegeCmd );
347- res .throwOnError ();
348- _saslWriteAuthed .put (db , true );
349- _saslReadAuthed .put (db , true );
350- }
351- } else {
352- if (_saslReadAuthed .get (db ) == null ) {
353- acquirePrivilegeCmd .append ("actions" , Arrays .asList ("oldRead" ));
354- CommandResult res = runCommand (db .getSisterDB ("admin" ), acquirePrivilegeCmd );
355- res .throwOnError ();
356- _saslReadAuthed .put (db , true );
357- }
342+ append ("principal" , db .getMongo ().getCredentials ().getUserName ()).
343+ append ("resource" , db .getName ());
344+ if (_saslAuthed .get (db ) == null ) {
345+ acquirePrivilegeCmd .append ("actions" , Arrays .asList ("oldWrite" ));
346+ CommandResult res = runCommand (db .getSisterDB ("admin" ), acquirePrivilegeCmd );
347+ res .throwOnError ();
348+ _saslAuthed .put (db , true );
358349 }
359350 }
360351
@@ -381,8 +372,7 @@ public DBPortPool getPool() {
381372 private boolean _processingResponse ;
382373
383374 private Map <DB ,Boolean > _authed = new ConcurrentHashMap <DB , Boolean >( );
384- private Map <DB ,Boolean > _saslReadAuthed = new ConcurrentHashMap <DB , Boolean >( );
385- private Map <DB ,Boolean > _saslWriteAuthed = new ConcurrentHashMap <DB , Boolean >( );
375+ private Map <DB ,Boolean > _saslAuthed = new ConcurrentHashMap <DB , Boolean >( );
386376 int _lastThread ;
387377 long _calls = 0 ;
388378 private volatile ActiveState _activeState ;
0 commit comments