View Javadoc
1   /*
2    * Copyright (c) 2002-2021, City of Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.mylutece.modules.database.authentication.business;
35  
36  import java.io.Serializable;
37  
38  import java.sql.Timestamp;
39  
40  /**
41   * This class represents the business object DatabaseUser
42   */
43  public class DatabaseUser implements Serializable
44  {
45      // Variables declarations
46      /**
47       * Status of not activated users.
48       */
49      public static final int STATUS_NOT_ACTIVATED = 0;
50  
51      /**
52       * Status of activated users.
53       */
54      public static final int STATUS_ACTIVATED = 1;
55  
56      /**
57       * Status of expired users. Expired users will be anonymized.
58       */
59      public static final int STATUS_EXPIRED = 5;
60  
61      /**
62       * Status of anonymized users.
63       */
64      public static final int STATUS_ANONYMIZED = 10;
65  
66      /**
67       * serialVersionUID
68       */
69      private static final long serialVersionUID = 8073247646404231859L;
70      private int _nUserId;
71      private String _strLogin;
72      private String _strLastName;
73      private String _strFirstName;
74      private String _strEmail;
75      private int _nStatus;
76      private Timestamp _passwordMaxValidDate;
77      private Timestamp _accountMaxValidDate;
78      public static final Timestamp DEFAULT_DATE_LAST_LOGIN = Timestamp.valueOf( "1980-01-01 00:00:00" );
79  
80      /**
81       * Returns the UserId
82       *
83       * @return The UserId
84       */
85      public int getUserId( )
86      {
87          return _nUserId;
88      }
89  
90      /**
91       * Sets the UserId
92       *
93       * @param nUserId
94       *            The UserId
95       */
96      public void setUserId( int nUserId )
97      {
98          _nUserId = nUserId;
99      }
100 
101     /**
102      * Returns the Email
103      *
104      * @return The Email
105      */
106     public String getEmail( )
107     {
108         return _strEmail;
109     }
110 
111     /**
112      * Sets the Email
113      *
114      * @param strEmail
115      *            The email
116      */
117     public void setEmail( String strEmail )
118     {
119         _strEmail = strEmail;
120     }
121 
122     /**
123      * Returns user first name
124      *
125      * @return The first name
126      */
127     public String getFirstName( )
128     {
129         return _strFirstName;
130     }
131 
132     /**
133      * Sets the first name
134      *
135      * @param strFirstName
136      *            The first name
137      */
138     public void setFirstName( String strFirstName )
139     {
140         _strFirstName = strFirstName;
141     }
142 
143     /**
144      * Returns the last name
145      *
146      * @return The last name
147      */
148     public String getLastName( )
149     {
150         return _strLastName;
151     }
152 
153     /**
154      * Sets the last name
155      *
156      * @param strLastName
157      *            The last name
158      */
159     public void setLastName( String strLastName )
160     {
161         _strLastName = strLastName;
162     }
163 
164     /**
165      * Returns the login
166      *
167      * @return The login
168      */
169     public String getLogin( )
170     {
171         return _strLogin;
172     }
173 
174     /**
175      * Sets the login
176      *
177      * @param strLogin
178      *            The login
179      */
180     public void setLogin( String strLogin )
181     {
182         _strLogin = strLogin;
183     }
184 
185     /**
186      * Get the status of the user
187      * 
188      * @return The status of the user
189      */
190     public int getStatus( )
191     {
192         return _nStatus;
193     }
194 
195     /**
196      * Set the status of the user
197      * 
198      * @param nStatus
199      *            The status of the user
200      */
201     public void setStatus( int nStatus )
202     {
203         _nStatus = nStatus;
204     }
205 
206     /**
207      * Check if the user is active
208      * 
209      * @return true if it is active, false otherwise
210      */
211     public boolean isActive( )
212     {
213         return ( ( _nStatus >= STATUS_ACTIVATED ) && ( _nStatus < STATUS_EXPIRED ) );
214     }
215 
216     /**
217      * Set the password maximum valide date of a user
218      * 
219      * @param passwordMaxValidDate
220      *            The new value of the password maximum valide date of a user
221      */
222     public void setPasswordMaxValidDate( Timestamp passwordMaxValidDate )
223     {
224         this._passwordMaxValidDate = passwordMaxValidDate;
225     }
226 
227     /**
228      * Get the password maximum valide date of a user
229      * 
230      * @return The password maximum valide date of a user
231      */
232     public Timestamp getPasswordMaxValidDate( )
233     {
234         return this._passwordMaxValidDate;
235     }
236 
237     /**
238      * Get the maximum valid date of the account of the user
239      * 
240      * @return The maximum valid date of the account of the user
241      */
242     public Timestamp getAccountMaxValidDate( )
243     {
244         return _accountMaxValidDate;
245     }
246 
247     /**
248      * Set the maximum valid date of the account of the user
249      * 
250      * @param accountMaxValidDate
251      *            The maximum valid date
252      */
253     public void setAccountMaxValidDate( Timestamp accountMaxValidDate )
254     {
255         this._accountMaxValidDate = accountMaxValidDate;
256     }
257 }