abstractpersondirectorycredentialstoprincipalresolver.java

来自「CAS在Tomcat中实现单点登录项目,单点登录(Single Sign On 」· Java 代码 · 共 65 行

JAVA
65
字号
/* * Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license * distributed with this file and available online at * http://www.uportal.org/license.html */package org.jasig.cas.authentication.principal;import java.util.Map;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.jasig.cas.util.annotation.NotNull;import org.jasig.services.persondir.IPersonAttributeDao;import org.jasig.services.persondir.support.StubPersonAttributeDao;/** *  * @author Scott Battaglia * @version $Revision: 1.1 $ $Date: 2005/08/19 18:27:17 $ * @since 3.1 * */public abstract class AbstractPersonDirectoryCredentialsToPrincipalResolver    implements CredentialsToPrincipalResolver {    /** Log instance. */    protected final Log log = LogFactory.getLog(this.getClass());        /** Repository of principal attributes to be retrieved */    @NotNull    private IPersonAttributeDao attributeRepository = new StubPersonAttributeDao();    public final Principal resolvePrincipal(final Credentials credentials) {        if (log.isDebugEnabled()) {            log.debug("Attempting to resolve a principal...");        }        final String principalId = extractPrincipalId(credentials);                if (principalId == null) {            return null;        }                if (log.isDebugEnabled()) {            log.debug("Creating SimplePrincipal for ["                + principalId + "]");        }                final Map attributes = this.attributeRepository.getUserAttributes(principalId);        return new SimplePrincipal(principalId, attributes);    }        /**     * Extracts the id of the user from the provided credentials.     *      * @param credentials the credentials provided by the user.     * @return the username, or null if it could not be resolved.     */    protected abstract String extractPrincipalId(Credentials credentials);        public final void setAttributeRepository(final IPersonAttributeDao attributeRepository) {        this.attributeRepository = attributeRepository;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?