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() {
37
37
38
38
static Optional <MongoCredential > of (Settings settings ) {
39
39
40
-
41
40
Optional <String > user = settings .get (Arrays .asList (USER .get (),
42
41
Configurations .USER .get ()))
43
42
.map (Object ::toString );
@@ -49,16 +48,20 @@ static Optional<MongoCredential> of(Settings settings) {
49
48
Optional <String > source = settings .get (AUTHENTICATION_SOURCE .get ())
50
49
.map (Object ::toString );
51
50
52
- AuthenticationMechanism mechanism = settings .get (AUTHENTICATION_MECHANISM .get ())
51
+ Optional < AuthenticationMechanism > mechanism = settings .get (AUTHENTICATION_MECHANISM .get ())
53
52
.map (Object ::toString )
54
- .map (AuthenticationMechanism ::fromMechanismName )
55
- .orElse (AuthenticationMechanism .PLAIN );
53
+ .map (AuthenticationMechanism ::fromMechanismName );
56
54
57
55
if (!user .isPresent ()) {
58
56
return Optional .empty ();
59
57
}
60
58
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 ()) {
62
65
case PLAIN :
63
66
return Optional .of (MongoCredential .createPlainCredential (user .orElseThrow (missingExceptionUser ()),
64
67
source .orElseThrow (missingExceptionSource ()), password .orElseThrow (missingExceptionPassword ())));
You can’t perform that action at this time.
0 commit comments