Example usage for org.apache.commons.collections15.keyvalue KeyedReader get

List of usage examples for org.apache.commons.collections15.keyvalue KeyedReader get

Introduction

In this page you can find the example usage for org.apache.commons.collections15.keyvalue KeyedReader get.

Prototype

V get(K key);

Source Link

Usage

From source file:org.apache.sshd.server.PasswordAuthenticatorUtils.java

/**
 * @param usersMap The users map as a {@link KeyedReader} object where
 * key=user name, value=expected password
 * @return A {@link PasswordAuthenticator} that authenticates using the
 * provided users map/*from w w w  .j av a2s.c  om*/
 */
public static final PasswordAuthenticator mappedUsersAuthenticator(final KeyedReader<String, String> usersMap) {
    return new PasswordAuthenticator() {
        @Override
        public boolean authenticate(String u, String p, ServerSession session) {
            String password = usersMap.get(u);
            if (password == null) {
                return false; // no such user
            } else if (p.equals(password)) {
                return true;
            } else {
                return false; // debug breakpoint
            }
        }
    };
}