⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchmodesearchdatabaseauthenticationhandler.java

📁 CAS在Tomcat中实现单点登录项目,单点登录(Single Sign On , 简称 SSO )是目前比较流行的服务于企业业务整合的解决方案之一
💻 JAVA
字号:
/* * 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.adaptors.jdbc;import org.jasig.cas.authentication.handler.AuthenticationException;import org.jasig.cas.authentication.principal.UsernamePasswordCredentials;import org.jasig.cas.util.annotation.NotNull;import org.springframework.beans.factory.InitializingBean;/** * Class that given a table, username field and password field will query a * database table with the provided encryption technique to see if the user * exists. This class defaults to a PasswordTranslator of * PlainTextPasswordTranslator. *  * @author Scott Battaglia * @author Dmitriy Kopylenko * @version $Revision: 42053 $ $Date: 2007-06-10 09:17:55 -0400 (Sun, 10 Jun 2007) $ * @since 3.0 */public class SearchModeSearchDatabaseAuthenticationHandler extends    AbstractJdbcUsernamePasswordAuthenticationHandler implements InitializingBean {    private static final String SQL_PREFIX = "Select count('x') from ";    @NotNull    private String fieldUser;    @NotNull    private String fieldPassword;    @NotNull    private String tableUsers;    private String sql;    protected final boolean authenticateUsernamePasswordInternal(        UsernamePasswordCredentials credentials) throws AuthenticationException {        final String encyptedPassword = getPasswordEncoder().encode(            credentials.getPassword());        final int count = getJdbcTemplate().queryForInt(this.sql,            credentials.getUsername(), encyptedPassword);        return count > 0;    }    public void afterPropertiesSet() throws Exception {        this.sql = SQL_PREFIX + this.tableUsers + " Where " + this.fieldUser        + " = ? And " + this.fieldPassword + " = ?";     }    /**     * @param fieldPassword The fieldPassword to set.     */    public final void setFieldPassword(final String fieldPassword) {        this.fieldPassword = fieldPassword;    }    /**     * @param fieldUser The fieldUser to set.     */    public final void setFieldUser(final String fieldUser) {        this.fieldUser = fieldUser;    }    /**     * @param tableUsers The tableUsers to set.     */    public final void setTableUsers(final String tableUsers) {        this.tableUsers = tableUsers;    }}

⌨️ 快捷键说明

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