File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
mongodb-driver/src/main/java/org/eclipse/jnosql/diana/mongodb/document Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,6 @@ private MongoAuthentication() {
3737
3838 static Optional <MongoCredential > of (Settings settings ) {
3939
40-
4140 Optional <String > user = settings .get (Arrays .asList (USER .get (),
4241 Configurations .USER .get ()))
4342 .map (Object ::toString );
@@ -49,16 +48,20 @@ static Optional<MongoCredential> of(Settings settings) {
4948 Optional <String > source = settings .get (AUTHENTICATION_SOURCE .get ())
5049 .map (Object ::toString );
5150
52- AuthenticationMechanism mechanism = settings .get (AUTHENTICATION_MECHANISM .get ())
51+ Optional < AuthenticationMechanism > mechanism = settings .get (AUTHENTICATION_MECHANISM .get ())
5352 .map (Object ::toString )
54- .map (AuthenticationMechanism ::fromMechanismName )
55- .orElse (AuthenticationMechanism .PLAIN );
53+ .map (AuthenticationMechanism ::fromMechanismName );
5654
5755 if (!user .isPresent ()) {
5856 return Optional .empty ();
5957 }
6058
61- switch (mechanism ) {
59+ if (!mechanism .isPresent ()) {
60+ return Optional .of (MongoCredential .createCredential (user .orElseThrow (missingExceptionUser ()),
61+ source .orElseThrow (missingExceptionSource ()), password .orElseThrow (missingExceptionPassword ())));
62+ }
63+
64+ switch (mechanism .get ()) {
6265 case PLAIN :
6366 return Optional .of (MongoCredential .createPlainCredential (user .orElseThrow (missingExceptionUser ()),
6467 source .orElseThrow (missingExceptionSource ()), password .orElseThrow (missingExceptionPassword ())));
You can’t perform that action at this time.
0 commit comments