mysqlauthenticator.java

来自「piweurrrrq i o fhsadhfka fd dskajc zxkjc」· Java 代码 · 共 49 行

JAVA
49
字号
/* * 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 + =
减小字号Ctrl + -
显示快捷键?