Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library should support Mongo 3 #17

Open
mzemmour opened this issue May 17, 2016 · 1 comment
Open

Library should support Mongo 3 #17

mzemmour opened this issue May 17, 2016 · 1 comment

Comments

@mzemmour
Copy link

Library should be able to work with Mongo 2 or mongo 3 (I'd suggest to add a boolean/enum argument in the constructor method to select the mongo version )

@mzemmour
Copy link
Author

Code should be like:

if (ConfigurationUtil.isUseMongo3Authentication()) { credential = Credential.builder().database(dbName).userName(userName).password(password.toCharArray()).authenticationType("SCRAM-SHA-1").build(); JavaScramSha1Authenticator authenticator = new JavaScramSha1Authenticator(); authenticator.setCredentials(credential);

            config.setCredentials(Lists.newArrayList(Credential.builder().database(dbName).userName(userName).password(password.toCharArray()).authenticator(authenticator).build()));
            //config.getCredentials().iterator().next()
            //config.addCredential(Credential.builder().database(dbName).userName(userName).password(password.toCharArray()).authenticator(authenticator).build());
        }
        else{
            credential = Credential.builder().database(dbName).userName(userName).password(password.toCharArray()).build();
            config.addCredential( credential );
        }
    }

    com.allanbank.mongodb.MongoClient mongoClient = MongoFactory.createClient(config);

    database        = mongoClient.getDatabase(dbName);`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants