Permalink
Browse files

Auth failing. Java driver expects a char array.

  • Loading branch information...
1 parent cdeb6d3 commit 788244d6b575d49715809e7668e3ad548951e6b6 @marclove marclove committed Dec 9, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/jmongo/db.rb
View
4 lib/jmongo/db.rb
@@ -47,7 +47,7 @@ def initialize(db_name, connection, options={})
def authenticate(username, password, save_auth=true)
begin
- succeeded = @j_db.authenticate(username, password)
+ succeeded = @j_db.authenticate(username, java.lang.String.new(password).toCharArray)
if save_auth && succeeded
@connection.add_auth(@name, username, password)
end
@@ -58,7 +58,7 @@ def authenticate(username, password, save_auth=true)
end
def add_user(username, password)
- @j_db.add_user(username, password)
+ @j_db.add_user(username, java.lang.String.new(password).toCharArray)
end
def remove_user(username)

4 comments on commit 788244d

@seanpd

Thanks for the fix; I ran into this one.
One thing you might consider in lib/mongo/db.rb...

      begin
        succeeded = @j_db.authenticate(username, password)
        if save_auth && succeeded
          @connection.add_auth(@name, username, password)
        end
      rescue => e
        succeeded = false
      end

The exception is eaten; this made it hard for me to find out the problem because it silently returns false. You might let the exception throw out instead.

@guyboertje
Owner

Are you using jmongo in production?

I am considering retiring this library because I have switched to Moped (from the Mongoid guys.) Have you looked at Moped?

@seanpd
@jacaetevha
Collaborator

@seanpd I'm using Moped in production as well. @guyboertje had asked if I wanted to take over maintenance of this library, but since choosing Moped that's not really feasible. I vote for lib-retirement. Thanks @guyboertje for the work you put into this.

Please sign in to comment.