View Javadoc

1   /*
2    * $Id: MemoryUserImpl.java 125 2004-11-01 19:10:53Z josem $
3    *
4    * Tarsis
5    * Copyright (C) 2002 Talika Open Source Group
6    *
7    * This program is free software; you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation; either version 2 of the License, or
10   * (at your option) any later version.
11   *
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program; if not, write to the Free Software
19   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20   *
21   */
22  
23  package org.talika.tarsis.security.memory;
24  
25  import java.io.Serializable;
26  import java.util.Set;
27  
28  import org.talika.tarsis.security.UserImpl;
29  
30  /**
31   * XML/Memory implementation of <code>User</code> interface.
32   *
33   * @author  Jose M. Palomar
34   * @version $Revision: 125 $
35   *
36   * @todo Make password field transient or remove it. Add a empty parameters default
37   * constructor.
38   */
39  public final class MemoryUserImpl extends UserImpl implements Serializable {
40  
41      // Constants
42  
43      // Fields
44      /**
45       * Password of user.
46       */
47      private final String password;
48  
49      // Constructors
50      /**
51       * Creates a new <code>MemoryUserImpl</code> using given parameters.
52       *
53       * @param login String login name of user.
54       * @param name String real name of user.
55       * @param password String password of user.
56       * @param roles Set roles of user.
57       */
58      public MemoryUserImpl(String login, String name, String password, Set roles) {
59          super(login, name, roles);
60          this.password = password;
61      }
62  
63      // Methods
64      /**
65       * Returns <code>true</code> if password is valid.
66       *
67       * @param password String password to check.
68       * @return boolean <code>true</code> if password is valid.
69       */
70      public boolean isPasswordValid(String password) {
71          return this.password.equals(password);
72      }
73  
74  }