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

📄 mysqlauthenticator.java

📁 piweurrrrq i o fhsadhfka fd dskajc zxkjcnkjsahc
💻 JAVA
字号:
/* * Mysql Authentication Module: * By Leif Jackson <ljackson@jjcons.com> * Last Updated: 03.21.2000  * ChangeLog: *  - 03.21.2000  *   * Created base SQL code for auth and create a local connection to test with *  - 03.22.2000 - TL *   * Not logging SQLException because the Mysql class logs it for us  *   * Using an instance of the Mysql object rather than a static version */package com.lyrisoft.auth.mysql;import java.sql.SQLException;import com.lyrisoft.chat.server.remote.AccessDenied;import com.lyrisoft.chat.server.remote.IAuthenticator;import com.lyrisoft.chat.server.remote.Auth;/** * Authenitcator that reads from MySQL server using mm.mysql JDBC<p> * * If a user if found in the password file, his password is checked. * If a user is not found in the password file, the access level IAuthenticator.USER * is returned. */public class MysqlAuthenticator implements IAuthenticator {    private Mysql _mysql;    public MysqlAuthenticator() {        _mysql = new Mysql();    }    public Auth authenticate(String userId, String password) throws AccessDenied {        try {            MysqlRecord record = _mysql.getRecord(userId, password);            if (record == null) {                return new Auth(userId, USER);            } else {                return new Auth(userId, record.access);            }        }        catch (SQLException e) {            throw new AccessDenied("SQL Error: " + e.getMessage());        }    }}

⌨️ 快捷键说明

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