usernamepasswordcredentialstoprincipalresolver.java

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

JAVA
40
字号
/* * Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license * distributed with this file and available online at * http://www.ja-sig.org/products/cas/overview/license/ */package org.jasig.cas.authentication.principal;/** * Implementation of CredentialsToPrincipalResolver for Credentials based on * UsernamePasswordCredentials when a SimplePrincipal (username only) is * sufficient. * <p> * Implementation extracts the username from the Credentials provided and * constructs a new SimplePrincipal with the unique id set to the username. * </p> *  * @author Scott Battaglia * @version $Revision: 1.2 $ $Date: 2007/01/22 20:35:26 $ * @since 3.0 * @see org.jasig.cas.authentication.principal.SimplePrincipal */public final class UsernamePasswordCredentialsToPrincipalResolver extends    AbstractPersonDirectoryCredentialsToPrincipalResolver {    protected String extractPrincipalId(final Credentials credentials) {        final UsernamePasswordCredentials usernamePasswordCredentials = (UsernamePasswordCredentials) credentials;        return usernamePasswordCredentials.getUsername();    }    /**     * Return true if Credentials are UsernamePasswordCredentials, false     * otherwise.     */    public boolean supports(final Credentials credentials) {        return credentials != null            && UsernamePasswordCredentials.class.isAssignableFrom(credentials                .getClass());    }}

⌨️ 快捷键说明

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