Java Code Examples for com.mongodb.AuthenticationMechanism#fromMechanismName()
The following examples show how to use
com.mongodb.AuthenticationMechanism#fromMechanismName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MongoSchemaFactory.java From Quicksql with MIT License | 6 votes |
private MongoCredential createCredentials(Map<String, Object> map) { final String authMechanismName = (String) map.get("authMechanism"); final AuthenticationMechanism authenticationMechanism = AuthenticationMechanism.fromMechanismName(authMechanismName); final String username = (String) map.get("userName"); final String authDatabase = (String) map.get("dbName"); final String password = (String) map.get("password"); switch (authenticationMechanism) { case PLAIN: return MongoCredential.createPlainCredential(username, authDatabase, password.toCharArray()); case SCRAM_SHA_1: return MongoCredential.createScramSha1Credential(username, authDatabase, password.toCharArray()); case GSSAPI: return MongoCredential.createGSSAPICredential(username); case MONGODB_CR: return MongoCredential.createMongoCRCredential(username, authDatabase, password.toCharArray()); case MONGODB_X509: return MongoCredential.createMongoX509Credential(username); } throw new IllegalArgumentException("Unsupported authentication mechanism " + authMechanismName); }
Example 2
Source File: MongoSchemaFactory.java From calcite with Apache License 2.0 | 6 votes |
private MongoCredential createCredential(Map<String, Object> map) { final String authMechanismName = (String) map.get("authMechanism"); final AuthenticationMechanism authenticationMechanism = AuthenticationMechanism.fromMechanismName(authMechanismName); final String username = (String) map.get("username"); final String authDatabase = (String) map.get("authDatabase"); final String password = (String) map.get("password"); switch (authenticationMechanism) { case PLAIN: return MongoCredential.createPlainCredential(username, authDatabase, password.toCharArray()); case SCRAM_SHA_1: return MongoCredential.createScramSha1Credential(username, authDatabase, password.toCharArray()); case SCRAM_SHA_256: return MongoCredential.createScramSha256Credential(username, authDatabase, password.toCharArray()); case GSSAPI: return MongoCredential.createGSSAPICredential(username); case MONGODB_X509: return MongoCredential.createMongoX509Credential(username); } throw new IllegalArgumentException("Unsupported authentication mechanism " + authMechanismName); }
Example 3
Source File: MongoClients.java From quarkus with Apache License 2.0 | 5 votes |
private AuthenticationMechanism getAuthenticationMechanism(String authMechanism) { AuthenticationMechanism mechanism; try { mechanism = AuthenticationMechanism.fromMechanismName(authMechanism.toUpperCase()); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Invalid authMechanism '" + authMechanism + "'"); } return mechanism; }
Example 4
Source File: CredentialListParser.java From vertx-mongo-client with Apache License 2.0 | 5 votes |
private AuthenticationMechanism getAuthenticationMechanism(String authMechanism) { AuthenticationMechanism mechanism; try { mechanism = AuthenticationMechanism.fromMechanismName(authMechanism); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Invalid authMechanism '" + authMechanism + "'"); } return mechanism; }