[JAVA-2061] Support GSSAPIServiceName in MongoClientOptions Created: 11/Dec/15  Updated: 11/Sep/19  Resolved: 23/Dec/15

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 3.0.0
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: James Duong Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

It does not seem possible to set the GSSAPIServiceName when connecting using MongoClientOptions instead of MongoURI.



 Comments   
Comment by Ross Lawley [ 11/Dec/15 ]

Hi jamesd,

Thanks for the ticket - just for future reference, the best place for questions regarding MongoDB usage or the Java driver specifics is the mongodb-user mailinglist or stackoverflow as you will reach a boarder audience there. This project is for driver bugs or feature requests.

So onto the question at hand - how do you configure the GSSAPIServiceName via MongoClientOptions? The short answer is you can't because credentials aren't handled by the MongoClientOptions. However, thats not a problem as you can supply them to the constructor of the MongoClient which has the same effect.

First you need to use the MongoCredential.createGSSAPICredential helper to create the GSSAPI Credential and then set the SERVICE_NAME property by calling: MongoCredential.withMechanismProperty like so:

ServerAddress addr = ...;
String myGSSAPIServiceName = "....";
MongoCredential credential = createGSSAPICredential(user).withMechanismProperty("SERVICE_NAME", myGSSAPIServiceName);
MongoClient client = MongoClient(addr, singletonList(credentialsList));

I hope that helps!

Ross

Generated at Thu Feb 08 08:56:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.