Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Licensed to Jasig under one or more contributor license
  * agreements. See the NOTICE file distributed with this work
  * for additional information regarding copyright ownership.
  * Jasig licenses this file to you under the Apache License,
  * Version 2.0 (the "License"); you may not use this file
  * except in compliance with the License.  You may obtain a
  * copy of the License at the following location:
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
package org.jasig.cas.adaptors.generic;
Handler that contains a list of valid users and passwords. Useful if there is a small list of users that we wish to allow. An example use case may be if there are existing handlers that make calls to LDAP, etc. but there is a need for additional users we don't want in LDAP. With the chain of command processing of handlers, this handler could be added to check before LDAP and provide the list of additional users. The list of acceptable users is stored in a map. The key of the map is the username and the password is the object retrieved from doing map.get(KEY).

Note that this class makes an unmodifiable copy of whatever map is provided to it.

Scott Battaglia
$Revision$ $Date$
public class AcceptUsersAuthenticationHandler extends
The list of users we will accept.
    private Map<StringStringusers;
    protected final boolean authenticateUsernamePasswordInternal(final UsernamePasswordCredentials credentials) {
        final String transformedUsername = getPrincipalNameTransformer().transform(credentials.getUsername());
        final String cachedPassword = this..get(transformedUsername);
        if (cachedPassword == null) {
            if (.isDebugEnabled()) {
                .debug("The user [" + transformedUsername
                    + "] was not found in the map.");
            return false;
        final String encodedPassword = this.getPasswordEncoder().encode(
        return (cachedPassword.equals(encodedPassword));


users The users to set.
    public final void setUsers(final Map<StringStringusers) {
        this. = Collections.unmodifiableMap(users);
New to GrepCode? Check out our FAQ X