public AuthenticationMechanism getAuthenticationMechanism() { return credential.getAuthenticationMechanism(); }
@Override public String getMechanismName() { AuthenticationMechanism authMechanism = getMongoCredential().getAuthenticationMechanism(); if (authMechanism == null) { throw new IllegalArgumentException("Authentication mechanism cannot be null"); } return authMechanism.getMechanismName(); }
GSSAPIAuthenticator(final MongoCredentialWithCache credential) { super(credential); if (getMongoCredential().getAuthenticationMechanism() != GSSAPI) { throw new MongoException("Incorrect mechanism: " + getMongoCredential().getMechanism()); } }
@Override protected SaslClient createSaslClient(final ServerAddress serverAddress) { final MongoCredential credential = getMongoCredential(); isTrue("mechanism is PLAIN", credential.getAuthenticationMechanism() == PLAIN); try { return Sasl.createSaslClient(new String[]{PLAIN.getMechanismName()}, credential.getUserName(), DEFAULT_PROTOCOL, serverAddress.getHost(), null, new CallbackHandler() { @Override public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (final Callback callback : callbacks) { if (callback instanceof PasswordCallback) { ((PasswordCallback) callback).setPassword(credential.getPassword()); } else if (callback instanceof NameCallback) { ((NameCallback) callback).setName(credential.getUserName()); } } } }); } catch (SaslException e) { throw new MongoSecurityException(credential, "Exception initializing SASL client", e); } } }
public AuthenticationMechanism getAuthenticationMechanism() { return credential.getAuthenticationMechanism(); }
@Override public String getMechanismName() { AuthenticationMechanism authMechanism = getMongoCredential().getAuthenticationMechanism(); if (authMechanism == null) { throw new IllegalArgumentException("Authentication mechanism cannot be null"); } return authMechanism.getMechanismName(); }
GSSAPIAuthenticator(final MongoCredentialWithCache credential) { super(credential); if (getMongoCredential().getAuthenticationMechanism() != GSSAPI) { throw new MongoException("Incorrect mechanism: " + getMongoCredential().getMechanism()); } }
@Override protected SaslClient createSaslClient(final ServerAddress serverAddress) { final MongoCredential credential = getMongoCredential(); isTrue("mechanism is PLAIN", credential.getAuthenticationMechanism() == PLAIN); try { return Sasl.createSaslClient(new String[]{PLAIN.getMechanismName()}, credential.getUserName(), DEFAULT_PROTOCOL, serverAddress.getHost(), null, new CallbackHandler() { @Override public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (final Callback callback : callbacks) { if (callback instanceof PasswordCallback) { ((PasswordCallback) callback).setPassword(credential.getPassword()); } else if (callback instanceof NameCallback) { ((NameCallback) callback).setName(credential.getUserName()); } } } }); } catch (SaslException e) { throw new MongoSecurityException(credential, "Exception initializing SASL client", e); } } }