authenticationmanager.java
来自「一个很好的开源项目管理系统源代码」· Java 代码 · 共 78 行
JAVA
78 行
package net.java.workeffort.service.security;import java.util.List;import net.java.workeffort.infrastructure.encrypt.IPasswordEncrypter;import net.java.workeffort.infrastructure.security.ISecurityProfile;import net.java.workeffort.service.IAuthenticationService;import net.java.workeffort.service.support.InvalidPartyException;import net.java.workeffort.service.support.InvalidPasswordException;/** * Authentication Manager implementation. * <p> * Uses <code>AuthenticationService</code> to get the encrypted password from the database.The * <code>PasswordEncypter</code> facilitates the validation of the user entered password against the encrypted * password from the database. * </p> * @author Antony Joseph */public class AuthenticationManager implements IAuthenticationManager { private IAuthenticationService authenticationService; private IPasswordEncrypter passwordEncrypter; public void authenticate(ISecurityProfile securityProfile) throws InvalidPartyException, InvalidPasswordException { String encryptedPassword = null; encryptedPassword = authenticationService .getPassword(securityProfile.getPartyCd()); if (encryptedPassword == null) throw new InvalidPartyException("invalid user name: " + securityProfile.getPartyCd()); else { if (!passwordEncrypter.isPasswordValid(securityProfile .getPassword(), encryptedPassword)) throw new InvalidPasswordException("Invalid password for user " + securityProfile.getPartyCd()); } } /** * @return Returns the authenticationService. */ public IAuthenticationService getAuthenticationService() { return authenticationService; } /** * @param authenticationService The authenticationService to set. */ public void setAuthenticationService( IAuthenticationService authenticationService) { this.authenticationService = authenticationService; } /** * @return Returns the passwordEncypter. */ public IPasswordEncrypter getPasswordEncrypter() { return passwordEncrypter; } /** * @param passwordEncrypter The passwordEncypter to set. IOC */ public void setPasswordEncrypter(IPasswordEncrypter passwordEncrypter) { this.passwordEncrypter = passwordEncrypter; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?