This project has retired. For details please refer to its Attic page.
LdapUser xref
View Javadoc

1   package org.apache.archiva.redback.common.ldap.user;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.archiva.redback.users.User;
23  
24  import javax.naming.directory.Attributes;
25  import java.io.Serializable;
26  import java.util.ArrayList;
27  import java.util.Date;
28  import java.util.List;
29  
30  // TODO this class should be able to be replaced with a model
31  public class LdapUser
32      implements User, Serializable
33  {
34  
35      private String username;
36  
37      private String fullName;
38  
39      private String email;
40  
41      private String encodedPassword;
42  
43      private List<String> previousEncodedPasswords;
44  
45      private boolean locked = false;
46  
47      private boolean requiresPasswordChange = false;
48  
49      private boolean permanent = true;
50  
51      private boolean valid = true;
52  
53      private Date creationDate = null;
54  
55      private int failedLoginAttempts;
56  
57      private Date lastLoginDate = null;
58  
59      private Date lastPasswordChange = null;
60  
61      // DO NOT STORE AS SUCH!!!
62      private String newPassword;
63  
64      private Attributes originalAttributes;
65  
66      /**
67       * @since 2.1
68       */
69      private String userManagerId = "ldap";
70  
71      public LdapUser( String username )
72      {
73          this.username = username;
74          this.previousEncodedPasswords = new ArrayList<String>( 0 );
75          this.failedLoginAttempts = 0;
76      }
77  
78      public LdapUser( String username, String fullName, String email )
79      {
80          this( username );
81          this.fullName = fullName;
82          this.email = email;
83      }
84  
85      public LdapUser()
86      {
87          previousEncodedPasswords = new ArrayList<String>( 0 );
88          failedLoginAttempts = Integer.MIN_VALUE;
89      }
90  
91      public void addPreviousEncodedPassword( String encodedPassword )
92      {
93          previousEncodedPasswords.add( encodedPassword );
94      }
95  
96      public Date getAccountCreationDate()
97      {
98          return creationDate;
99      }
100 
101     public int getCountFailedLoginAttempts()
102     {
103         return failedLoginAttempts;
104     }
105 
106     public String getEmail()
107     {
108         return email;
109     }
110 
111     public String getEncodedPassword()
112     {
113         return encodedPassword;
114     }
115 
116     public String getFullName()
117     {
118         return fullName;
119     }
120 
121     public Date getLastLoginDate()
122     {
123         return lastLoginDate;
124     }
125 
126     public Date getLastPasswordChange()
127     {
128         return lastPasswordChange;
129     }
130 
131     public String getPassword()
132     {
133         return newPassword;
134     }
135 
136     public List<String> getPreviousEncodedPasswords()
137     {
138         return previousEncodedPasswords;
139     }
140 
141 
142     public String getUsername()
143     {
144         return username;
145     }
146 
147     public boolean isLocked()
148     {
149         return locked;
150     }
151 
152     public boolean isPasswordChangeRequired()
153     {
154         return requiresPasswordChange;
155     }
156 
157     public boolean isPermanent()
158     {
159         return permanent;
160     }
161 
162     public boolean isValidated()
163     {
164         return valid;
165     }
166 
167     public void setCountFailedLoginAttempts( int count )
168     {
169         failedLoginAttempts = count;
170     }
171 
172     public void setEmail( String address )
173     {
174         email = address;
175     }
176 
177     public void setEncodedPassword( String encodedPassword )
178     {
179         this.encodedPassword = encodedPassword;
180     }
181 
182     public void setFullName( String name )
183     {
184         fullName = name;
185     }
186 
187     public void setAccountCreationDate( Date date )
188     {
189         creationDate = date;
190     }
191 
192     public void setLastLoginDate( Date date )
193     {
194         lastLoginDate = date;
195     }
196 
197     public void setLastPasswordChange( Date passwordChangeDate )
198     {
199         lastPasswordChange = passwordChangeDate;
200     }
201 
202     public void setLocked( boolean locked )
203     {
204         this.locked = locked;
205     }
206 
207     public void setPassword( String rawPassword )
208     {
209         newPassword = rawPassword;
210     }
211 
212     public void setPasswordChangeRequired( boolean changeRequired )
213     {
214         requiresPasswordChange = changeRequired;
215     }
216 
217     public void setPermanent( boolean permanent )
218     {
219         this.permanent = permanent;
220     }
221 
222     public void setPreviousEncodedPasswords( List<String> encodedPasswordList )
223     {
224         previousEncodedPasswords = new ArrayList<String>( encodedPasswordList );
225     }
226 
227     public void setUsername( String name )
228     {
229         username = name;
230     }
231 
232     public void setValidated( boolean valid )
233     {
234         this.valid = valid;
235     }
236 
237     public Attributes getOriginalAttributes()
238     {
239         return originalAttributes;
240     }
241 
242     public void setOriginalAttributes( Attributes originalAttributes )
243     {
244         this.originalAttributes = originalAttributes;
245     }
246 
247     public String getUserManagerId()
248     {
249         return userManagerId;
250     }
251 
252 }