Skip to content

Instantly share code, notes, and snippets.

@efroese
Created January 14, 2012 16:11
Show Gist options
  • Save efroese/1611905 to your computer and use it in GitHub Desktop.
Save efroese/1611905 to your computer and use it in GitHub Desktop.
@SuppressWarnings("unchecked")
public MongoClient(DB mongodb, Map<String,Object> props) {
this.mongodb = mongodb;
this.props = props;
String user = StorageClientUtils.getSetting(props.get(MongoClientPool.PROP_MONGO_USER), null);
String password = StorageClientUtils.getSetting(props.get(MongoClientPool.PROP_MONGO_USER), null);
if (user != null && password != null && !this.mongodb.isAuthenticated()){
if (!this.mongodb.authenticate(user, password.toCharArray())){
throw new MongoException("Unable to authenticate");
}
}
this.alternateKeys = (Map<String,String>)props.get(MongoClientPool.PROP_ALT_KEYS);
this.streamedContentHelper = new GridFSContentHelper(mongodb, this, props);
this.mongodb.requestStart();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment