@Override
 public void doOperation() {
   consoleDisplayFactory.getNewConsoleDisplay("Enter Login Credentials").display();
   consoleDisplayFactory.getNewConsoleDisplay("---------------------------").display();
   consoleDisplayFactory.getNewConsoleDisplay("BookLibrary Number :").display();
   String libraryNumber = inputReader.read();
   consoleDisplayFactory.getNewConsoleDisplay("Password :").display();
   String password = inputReader.read();
   currentUser = authenticator.authenticate(libraryNumber, password);
 }
예제 #2
0
 CommandResult authenticate(Mongo mongo, final MongoCredential credentials) {
   Authenticator authenticator;
   if (credentials.getMechanism().equals(MongoCredential.MONGODB_CR_MECHANISM)) {
     authenticator = new NativeAuthenticator(mongo, credentials);
   } else if (credentials.getMechanism().equals(MongoCredential.GSSAPI_MECHANISM)) {
     authenticator = new GSSAPIAuthenticator(mongo, credentials);
   } else if (credentials.getMechanism().equals(MongoCredential.PLAIN_MECHANISM)) {
     authenticator = new PlainAuthenticator(mongo, credentials);
   } else if (credentials.getMechanism().equals(MongoCredential.MONGODB_X509_MECHANISM)) {
     authenticator = new X509Authenticator(mongo, credentials);
   } else {
     throw new IllegalArgumentException(
         "Unsupported authentication protocol: " + credentials.getMechanism());
   }
   CommandResult res = authenticator.authenticate();
   authenticatedDatabases.add(credentials.getSource());
   return res;
 }
예제 #3
0
 /**
  * Authenticate
  *
  * @throws Exception
  */
 public void authenticate() throws Exception {
   credentials = authenticator.authenticate();
 }