title: Can the camel mongo component connect to a password protected MongoDB instance?
body: <p>My target mongodb database is password protected.</p>
  
  <p>I am trying to connect to it via camel, using the <a href="http://camel.apache.org/mongodb.html" rel="nofollow">camel mongodb component</a></p>
  
  <p>Based on the <a href="http://svn.apache.org/viewvc/camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbProducer.java?view=markup" rel="nofollow">code I see</a>, I'm not sure camel can take authentication into account. Is this true?</p>
  
  <p>Using Camel 2.11.0, tried both Mongo Java Driver 2.11.1 and 2.9.1.</p>
  
  <p><strong>My Relevant Code:</strong></p>
  
  <p>Route:</p>
  
  <pre><code>from( "direct:input" )
    .to(mongodb:myDB?database=aDB&amp;collection=aColl&amp;operation=save&amp;writeConcern=SAFE" ))
  </code></pre>
  
  <p>AppCtx:</p>
  
  <pre><code>&lt;bean id="myDB" class="com.mongodb.Mongo"&gt;
  &lt;constructor-arg index="0"&gt;
      &lt;bean class="com.mongodb.MongoURI"&gt;
          &lt;constructor-arg index="0" 
          value="mongodb://$mongodb{user}:$mongodb{passwd}@$mongodb{host}:$mongodb{port}/$mongodb{db}"&gt;
          &lt;/constructor-arg&gt;
      &lt;/bean&gt;
  &lt;/constructor-arg&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>org.apache.camel.component.mongodb.CamelMongoDbException: 
  com.mongodb.CommandFailureException: { 
   "serverUsed" : "redacted" , 
   "errmsg" : "need to login" , 
   "ok" : 0.0}
  </code></pre>
  
  <p>I'd hate for this to be yet another case where I can't use the component because it just isn't quite there.</p>