001: /*
002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003: * Distributed under the terms of either:
004: * - the common development and distribution license (CDDL), v1.0; or
005: * - the GNU Lesser General Public License, v2.1 or later
006: * $Id: RoleUser.java 3634 2007-01-08 21:42:24Z gbevin $
007: */
008: package com.uwyn.rife.authentication.credentials;
009:
010: import com.uwyn.rife.config.RifeConfig;
011: import com.uwyn.rife.site.ConstrainedBean;
012: import com.uwyn.rife.site.ConstrainedProperty;
013: import com.uwyn.rife.site.Validation;
014:
015: /**
016: * <p>Provides standard {@link RoleUserCredentials} functionalities by
017: * implementing the property accessors and setting up basic validation rules.
018: * These rules make the login and password mandatory and limit their length
019: * according to the settings in {@link
020: * com.uwyn.rife.config.RifeConfig.Authentication}.
021: *
022: * @author Geert Bevin (gbevin[remove] at uwyn dot com)
023: * @version $Revision: 3634 $
024: * @since 1.0
025: */
026: public class RoleUser extends
027: Validation<ConstrainedBean, ConstrainedProperty> implements
028: RoleUserCredentials, RememberMe {
029: private String mLogin = null;
030: private String mPassword = null;
031: private String mRole = null;
032: private boolean mRemember = false;
033:
034: public RoleUser() {
035: }
036:
037: protected void activateValidation() {
038: addConstraint(new ConstrainedProperty("login").notNull(true)
039: .minLength(
040: RifeConfig.Authentication
041: .getLoginMinimumLength()).maxLength(
042: RifeConfig.Authentication
043: .getLoginMaximumLength()));
044: addConstraint(new ConstrainedProperty("password").notNull(true)
045: .minLength(
046: RifeConfig.Authentication
047: .getPasswordMinimumLength()).maxLength(
048: RifeConfig.Authentication
049: .getPasswordMaximumLength()));
050: }
051:
052: public RoleUser(String login, String password) {
053: this ();
054: setLogin(login);
055: setPassword(password);
056: }
057:
058: public RoleUser(String login, String password, String role) {
059: this ();
060: setLogin(login);
061: setPassword(password);
062: setRole(role);
063: }
064:
065: public String getLogin() {
066: return mLogin;
067: }
068:
069: public RoleUser login(String login) {
070: setLogin(login);
071:
072: return this ;
073: }
074:
075: public void setLogin(String login) {
076: mLogin = login;
077: }
078:
079: public String getPassword() {
080: return mPassword;
081: }
082:
083: public RoleUser password(String password) {
084: setPassword(password);
085:
086: return this ;
087: }
088:
089: public void setPassword(String password) {
090: mPassword = password;
091: }
092:
093: public String getRole() {
094: return mRole;
095: }
096:
097: public RoleUser role(String role) {
098: setRole(role);
099:
100: return this ;
101: }
102:
103: public void setRole(String role) {
104: mRole = role;
105: }
106:
107: public boolean getRemember() {
108: return mRemember;
109: }
110:
111: public RoleUser remember(boolean remember) {
112: setRemember(remember);
113:
114: return this ;
115: }
116:
117: public void setRemember(boolean remember) {
118: mRemember = remember;
119: }
120: }
|