1 package org.apache.archiva.redback.rest.api.model;
3 import org.apache.archiva.redback.integration.util.DateUtils;
5 import javax.xml.bind.annotation.XmlRootElement;
6 import java.io.Serializable;
10 * Licensed to the Apache Software Foundation (ASF) under one
11 * or more contributor license agreements. See the NOTICE file
12 * distributed with this work for additional information
13 * regarding copyright ownership. The ASF licenses this file
14 * to you under the Apache License, Version 2.0 (the
15 * "License"); you may not use this file except in compliance
16 * with the License. You may obtain a copy of the License at
18 * http://www.apache.org/licenses/LICENSE-2.0
20 * Unless required by applicable law or agreed to in writing,
21 * software distributed under the License is distributed on an
22 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23 * KIND, either express or implied. See the License for the
24 * specific language governing permissions and limitations
28 @XmlRootElement( name = "user" )
30 implements Serializable
32 private String username;
34 private String fullName;
38 private boolean validated;
40 private boolean locked;
42 private String password;
44 private boolean passwordChangeRequired;
46 private boolean permanent;
48 private String confirmPassword;
50 // Display Only Fields.
51 private String timestampAccountCreation;
53 private String timestampLastLogin;
55 private String timestampLastPasswordChange;
58 * for password change only
62 private String previousPassword;
65 * for roles update only <b>not return on user read</b>
69 private List<String> assignedRoles;
76 public User( String username, String fullName, String email, boolean validated, boolean locked )
78 this.username = username;
79 this.fullName = fullName;
81 this.validated = validated;
85 public User( org.apache.archiva.redback.users.User user )
87 setUsername( user.getUsername() );
88 this.setEmail( user.getEmail() );
89 this.setFullName( user.getFullName() );
90 this.setLocked( user.isLocked() );
91 this.setPassword( user.getPassword() );
92 this.setValidated( user.isValidated() );
93 this.setPasswordChangeRequired( user.isPasswordChangeRequired() );
94 this.setPermanent( user.isPermanent() );
96 setTimestampAccountCreation( DateUtils.formatWithAge( user.getAccountCreationDate(), "ago" ) );
97 setTimestampLastLogin( DateUtils.formatWithAge( user.getLastLoginDate(), "ago" ) );
98 setTimestampLastPasswordChange( DateUtils.formatWithAge( user.getLastPasswordChange(), "ago" ) );
102 public String getUsername()
107 public void setUsername( String username )
109 this.username = username;
112 public String getFullName()
117 public void setFullName( String fullName )
119 this.fullName = fullName;
122 public String getEmail()
127 public void setEmail( String email )
132 public boolean isValidated()
137 public void setValidated( boolean validated )
139 this.validated = validated;
142 public boolean isLocked()
147 public void setLocked( boolean isLocked )
149 this.locked = isLocked;
152 public String getPassword()
157 public void setPassword( String password )
159 this.password = password;
162 public boolean isPasswordChangeRequired()
164 return passwordChangeRequired;
167 public void setPasswordChangeRequired( boolean passwordChangeRequired )
169 this.passwordChangeRequired = passwordChangeRequired;
172 public boolean isPermanent()
177 public void setPermanent( boolean permanent )
179 this.permanent = permanent;
182 public String getConfirmPassword()
184 return confirmPassword;
187 public void setConfirmPassword( String confirmPassword )
189 this.confirmPassword = confirmPassword;
192 public String getTimestampAccountCreation()
194 return timestampAccountCreation;
197 public void setTimestampAccountCreation( String timestampAccountCreation )
199 this.timestampAccountCreation = timestampAccountCreation;
202 public String getTimestampLastLogin()
204 return timestampLastLogin;
207 public void setTimestampLastLogin( String timestampLastLogin )
209 this.timestampLastLogin = timestampLastLogin;
212 public String getTimestampLastPasswordChange()
214 return timestampLastPasswordChange;
217 public void setTimestampLastPasswordChange( String timestampLastPasswordChange )
219 this.timestampLastPasswordChange = timestampLastPasswordChange;
222 public String getPreviousPassword()
224 return previousPassword;
227 public void setPreviousPassword( String previousPassword )
229 this.previousPassword = previousPassword;
232 public List<String> getAssignedRoles()
234 return assignedRoles;
237 public void setAssignedRoles( List<String> assignedRoles )
239 this.assignedRoles = assignedRoles;
243 public String toString()
245 final StringBuilder sb = new StringBuilder();
247 sb.append( "{username='" ).append( username ).append( '\'' );
248 sb.append( ", fullName='" ).append( fullName ).append( '\'' );
249 sb.append( ", email='" ).append( email ).append( '\'' );
250 sb.append( ", validated=" ).append( validated );
251 sb.append( ", locked=" ).append( locked );
252 sb.append( ", password='" ).append( password ).append( '\'' );
253 sb.append( ", passwordChangeRequired=" ).append( passwordChangeRequired );
254 sb.append( ", permanent=" ).append( permanent );
255 sb.append( ", confirmPassword='" ).append( confirmPassword ).append( '\'' );
256 sb.append( ", timestampAccountCreation='" ).append( timestampAccountCreation ).append( '\'' );
257 sb.append( ", timestampLastLogin='" ).append( timestampLastLogin ).append( '\'' );
258 sb.append( ", timestampLastPasswordChange='" ).append( timestampLastPasswordChange ).append( '\'' );
259 sb.append( ", previousPassword='" ).append( previousPassword ).append( '\'' );
260 sb.append( ", assignedRoles=" ).append( assignedRoles );
262 return sb.toString();
266 public boolean equals( Object o )
272 if ( !( o instanceof User ) )
277 User user = (User) o;
279 if ( !username.equals( user.username ) )
288 public int hashCode()
290 return username.hashCode();