📄 jdbcauthenticator.java
字号:
/*
* Jdbc Authentication Module:
* By Wayne Hogue <w.hogue@chiphead.net>
* Last Updated: 04.02.2000
* Based on
* Mysql Authentication Module:
* com.lyrisoft.auth.mysql;
* By Leif Jackson <ljackson@jjcons.com>
*/
package com.lyrisoft.chat.server.remote.auth.jdbc;
import java.sql.SQLException;
import com.lyrisoft.chat.Translator;
import com.lyrisoft.chat.server.remote.AccessDenied;
import com.lyrisoft.chat.server.remote.IAuthenticator;
import com.lyrisoft.chat.server.remote.Auth;
import com.lyrisoft.chat.server.remote.ChatServer;
//import com.lyrisoft.chat.server.remote.Resources;
/**
* Authenitcator that reads from server using 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 JdbcAuthenticator implements IAuthenticator {
private Jdbc _jdbc;
public JdbcAuthenticator() {
_jdbc = new Jdbc();
}
public Auth authenticate(String userId, String password) throws AccessDenied {
try {
JdbcRecord record = _jdbc.getRecord(userId, password);
if (record == null) {
return new Auth(userId, USER);
} else {
return new Auth(userId, record.access);
}
}
catch (SQLException e) {
ChatServer.log(e);
throw new AccessDenied(Translator.getMessage("sql_error", e.toString()));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -