passwdauthenticator.java

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

JAVA
40
字号
/* * Copyright (c) 2000 Lyrisoft Solutions, Inc. * Used by permission */package com.lyrisoft.chat.server.remote.auth;import java.io.IOException;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;/** * Authenitcator that reads from a password file.<p> * * The file is made up of colon-delimited fields: * <userId>:<access_level>:<password> * <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 PasswdAuthenticator implements IAuthenticator {    public Auth authenticate(String userId, String password) throws AccessDenied {        try {            PasswdRecord record = Passwd.getRecord(userId, password);            if (record == null) {                return new Auth(userId, USER);            } else {                return new Auth(userId, record.access);            }        }        catch (IOException e) {            ChatServer.log(e);//            throw new AccessException(Resources.getString("err.passwd.io"));            throw new AccessDenied(userId);        }    }}

⌨️ 快捷键说明

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