001package org.apache.archiva.redback.users.memory; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.archiva.redback.users.User; 023 024import java.io.Serializable; 025import java.util.ArrayList; 026import java.util.Date; 027import java.util.List; 028 029/** 030 * A Simple User record. 031 * 032 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> 033 */ 034public class SimpleUser 035 implements User, Serializable 036{ 037 private String username; 038 039 private String password; 040 041 private String email; 042 043 private String fullName; 044 045 private String encodedPassword; 046 047 private Date lastPasswordChange; 048 049 private Date lastLoginDate; 050 051 private int countFailedLoginAttempts = 0; 052 053 private boolean locked = false; 054 055 private boolean permanent = false; 056 057 private boolean validated = false; 058 059 private List<String> previousEncodedPasswords; 060 061 private Date accountCreationDate; 062 063 private boolean passwordChangeRequired; 064 065 public SimpleUser() 066 { 067 // no op 068 } 069 070 @Override 071 public void addPreviousEncodedPassword( String encodedPassword ) 072 { 073 getPreviousEncodedPasswords().add( encodedPassword ); 074 } 075 076 @Override 077 public Date getAccountCreationDate() 078 { 079 return accountCreationDate; 080 } 081 082 @Override 083 public int getCountFailedLoginAttempts() 084 { 085 return countFailedLoginAttempts; 086 } 087 088 @Override 089 public String getEmail() 090 { 091 return email; 092 } 093 094 @Override 095 public String getEncodedPassword() 096 { 097 return encodedPassword; 098 } 099 100 @Override 101 public String getFullName() 102 { 103 return fullName; 104 } 105 106 @Override 107 public Date getLastLoginDate() 108 { 109 return lastLoginDate; 110 } 111 112 @Override 113 public Date getLastPasswordChange() 114 { 115 return lastPasswordChange; 116 } 117 118 @Override 119 public String getPassword() 120 { 121 return password; 122 } 123 124 @Override 125 public List<String> getPreviousEncodedPasswords() 126 { 127 if ( previousEncodedPasswords == null ) 128 { 129 previousEncodedPasswords = new ArrayList<String>(); 130 } 131 return previousEncodedPasswords; 132 } 133 134 @Override 135 public String getUsername() 136 { 137 return username; 138 } 139 140 @Override 141 public boolean isLocked() 142 { 143 return locked; 144 } 145 146 @Override 147 public void setAccountCreationDate( Date accountCreationDate ) 148 { 149 this.accountCreationDate = accountCreationDate; 150 } 151 152 @Override 153 public void setCountFailedLoginAttempts( int countFailedLoginAttempts ) 154 { 155 this.countFailedLoginAttempts = countFailedLoginAttempts; 156 } 157 158 @Override 159 public void setEmail( String email ) 160 { 161 this.email = email; 162 } 163 164 @Override 165 public void setEncodedPassword( String encodedPassword ) 166 { 167 this.encodedPassword = encodedPassword; 168 } 169 170 @Override 171 public void setFullName( String fullName ) 172 { 173 this.fullName = fullName; 174 } 175 176 @Override 177 public void setLastLoginDate( Date lastLoginDate ) 178 { 179 this.lastLoginDate = lastLoginDate; 180 } 181 182 @Override 183 public void setLastPasswordChange( Date lastPasswordChange ) 184 { 185 this.lastPasswordChange = lastPasswordChange; 186 } 187 188 @Override 189 public void setLocked( boolean locked ) 190 { 191 this.locked = locked; 192 } 193 194 @Override 195 public void setPassword( String password ) 196 { 197 this.password = password; 198 } 199 200 @Override 201 public void setPreviousEncodedPasswords( List<String> previousEncodedPasswords ) 202 { 203 this.previousEncodedPasswords = previousEncodedPasswords; 204 } 205 206 @Override 207 public void setUsername( String username ) 208 { 209 this.username = username; 210 } 211 212 @Override 213 public boolean isPasswordChangeRequired() 214 { 215 return passwordChangeRequired; 216 } 217 218 @Override 219 public void setPasswordChangeRequired( boolean passwordChangeRequired ) 220 { 221 this.passwordChangeRequired = passwordChangeRequired; 222 } 223 224 @Override 225 public boolean isPermanent() 226 { 227 return permanent; 228 } 229 230 @Override 231 public void setPermanent( boolean permanent ) 232 { 233 this.permanent = permanent; 234 } 235 236 @Override 237 public boolean isValidated() 238 { 239 return validated; 240 } 241 242 @Override 243 public void setValidated( boolean validated ) 244 { 245 this.validated = validated; 246 } 247 248 @Override 249 public String getUserManagerId() 250 { 251 return "simple"; 252 } 253 254}