Пример #1
0
  void checkAuth(DB db) throws IOException {
    DB.AuthorizationCredentials credentials = db.getAuthorizationCredentials();
    if (credentials == null) {
      if (db._name.equals("admin")) return;
      checkAuth(db._mongo.getDB("admin"));
      return;
    }
    if (_authed.containsKey(db)) return;

    CommandResult res = runCommand(db, credentials.getNonceCommand());
    res.throwOnError();

    res = runCommand(db, credentials.getAuthCommand(res.getString("nonce")));
    res.throwOnError();

    _authed.put(db, true);
  }