AuthenticationService.java
01 package net.sf.annocon.examples.basic.authentication;
02 
03 /**
04  * Service responsible for the authentication of username password combinations.
05  
06  @author Achim Huegen
07  */
08 public class AuthenticationService
09 {
10   private UserManager _userManager;
11 
12   public AuthenticationService()
13   {
14   }
15   
16   /**
17    * Checks if password for a user is correct
18    @param username
19    @param password
20    @return  True if password is correct, false if user doesn't exist or password is wrong.
21    */
22   public boolean checkPassword(String username, String password)
23   {
24     String userPassword = _userManager.getUserData(username);
25     if (userPassword == null)
26       return false;
27     else return userPassword.equals(password);
28   }
29 
30   public UserManager getUserManager()
31   {
32     return _userManager;
33   }
34 
35   public void setUserManager(UserManager userManager)
36   {
37     _userManager = userManager;
38   }
39 }