1 package org.apache.archiva.redback.users; 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 java.io.Serializable; 23 import java.util.Date; 24 import java.util.List; 25 26 /** 27 * The User Object. 28 * 29 * @author Jason van Zyl 30 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> 31 */ 32 public interface User 33 extends Serializable 34 { 35 36 // -------------------------------------------------------------------- 37 // Standard User Requirements. 38 // -------------------------------------------------------------------- 39 40 /** 41 * Gets the User Name for this user. 42 * <p/> 43 * This field is required, and should never be empty. 44 * 45 * @return the user name. 46 */ 47 String getUsername(); 48 49 /** 50 * Sets the User Name for this user. 51 * <p/> 52 * This field is required, and should never be empty. 53 * 54 * @param name the user name. 55 */ 56 void setUsername( String name ); 57 58 /** 59 * Gets the Full Name for this user. 60 * <p/> 61 * This field is required, and should never be empty. 62 * 63 * @return the full name. 64 */ 65 String getFullName(); 66 67 /** 68 * Sets the Full Name for this user. 69 * <p/> 70 * This field is required, and should never be empty. 71 * 72 * @param name the full name. 73 */ 74 void setFullName( String name ); 75 76 /** 77 * Gets the email address for this user. 78 * <p/> 79 * This field is required, and should never be empty. 80 * 81 * @return the email address. 82 */ 83 String getEmail(); 84 85 /** 86 * Sets the email address for this user. 87 * <p/> 88 * This field is required, and should never be empty. 89 * 90 * @param address the email address. 91 */ 92 void setEmail( String address ); 93 94 // -------------------------------------------------------------------- 95 // Password Requirements. 96 // -------------------------------------------------------------------- 97 98 /** 99 * Gets the Raw (unencoded) Password. 100 * Used only on password change requests. 101 * <p/> 102 * <p> 103 * <b>Notes for User Providers</b> 104 * </p> 105 * <ol> 106 * <li> 107 * Providers need to look for a value in here to indicate if the user is 108 * intending to change their password. 109 * </li> 110 * <li> 111 * The providers of this interface need to use this field, encode the password, place it's value 112 * into the encodedPassword field, and clear out the raw unencoded password field. 113 * </li> 114 * <li> 115 * This field should never be stored on disk. 116 * </li> 117 * </ol> 118 * 119 * @return the raw encoded password. 120 */ 121 String getPassword(); 122 123 /** 124 * Sets the raw (unencoded) password for this user. 125 * 126 * @param rawPassword the raw unencoded password for this user. 127 * @see #getPassword() 128 */ 129 void setPassword( String rawPassword ); 130 131 /** 132 * Gets the Encoded Password. 133 * 134 * @return the encoded password. 135 */ 136 String getEncodedPassword(); 137 138 /** 139 * Sets the Encoded Password. 140 * <p/> 141 * This field is populated by the {@link UserManager} process. 142 * 143 * @param encodedPassword 144 */ 145 void setEncodedPassword( String encodedPassword ); 146 147 /** 148 * Gets the Date of the Last Password Change. 149 * <p/> 150 * Used by password management policies to enforce password expiration rules. 151 * 152 * @return the date of the last password change. 153 */ 154 Date getLastPasswordChange(); 155 156 /** 157 * Sets the Last Password Change Date. 158 * <p/> 159 * This field is populated by the {@link UserManager} process. 160 * 161 * @param passwordChangeDate the date that the last password change occured. 162 */ 163 void setLastPasswordChange( Date passwordChangeDate ); 164 165 /** 166 * Gets the list of previous password (in encoded format). 167 * <p/> 168 * Used by password management policies to enforce password reuse rules. 169 * 170 * @return the list of {@link String} objects. Represents previous passwords (in encoded format). 171 */ 172 List<String> getPreviousEncodedPasswords(); 173 174 /** 175 * Sets the list of previous passwords (in encoded format) 176 * 177 * @param encodedPasswordList (list of {@link String} objects.) the previously passwords in encoded format. 178 */ 179 void setPreviousEncodedPasswords( List<String> encodedPasswordList ); 180 181 /** 182 * Add encoded password to previously passwords in encoded format. 183 * 184 * @param encodedPassword the encoded password to add. 185 */ 186 void addPreviousEncodedPassword( String encodedPassword ); 187 188 // -------------------------------------------------------------------- 189 // State 190 // -------------------------------------------------------------------- 191 192 /** 193 * Gets the flag indicating if this user is a permanent user or not. 194 * <p/> 195 * Usually Root / Admin / Guest users are flagged as such. 196 */ 197 boolean isPermanent(); 198 199 /** 200 * Sets the permanent flag for this user. 201 * <p/> 202 * Users such as Root / Admin / Guest are typically flagged as permanent. 203 * 204 * @param permanent true if permanent. 205 */ 206 void setPermanent( boolean permanent ); 207 208 /** 209 * Determines if this user account is locked from use or not. 210 * <p/> 211 * This state is set from an administrative point of view, or due to 212 * excessive failed login attempts. 213 * 214 * @return true if account is locked. 215 */ 216 boolean isLocked(); 217 218 /** 219 * Sets the locked state of this account. 220 * 221 * @param locked true if account is to be locked. 222 */ 223 void setLocked( boolean locked ); 224 225 /** 226 * Determines if this user account must change their password on next login. 227 * 228 * @return true if user must change password on next login. 229 */ 230 boolean isPasswordChangeRequired(); 231 232 /** 233 * Sets the flag to indicate if this user must change their password on next login. 234 * 235 * @param changeRequired true if user must change password on next login. 236 */ 237 void setPasswordChangeRequired( boolean changeRequired ); 238 239 /** 240 * Gets the flag indicating if this user has been validated (or not) 241 * 242 * @return true if validated. 243 */ 244 boolean isValidated(); 245 246 /** 247 * Sets the flag indicating if this user has been validated (or not) 248 * 249 * @param valid true if validated. 250 */ 251 void setValidated( boolean valid ); 252 253 // -------------------------------------------------------------------- 254 // Statistics 255 // -------------------------------------------------------------------- 256 257 /** 258 * Get Count of Failed Login Attempts. 259 * 260 * @return the count of failed login attempts. 261 */ 262 int getCountFailedLoginAttempts(); 263 264 /** 265 * Set the count of failed login attempts. 266 * 267 * @param count the count of failed login attempts. 268 */ 269 void setCountFailedLoginAttempts( int count ); 270 271 /** 272 * Get the Creation Date for this account. 273 * 274 * @return the date of creation for this account. 275 */ 276 Date getAccountCreationDate(); 277 278 /** 279 * Set the Creation Date for this account. 280 */ 281 void setAccountCreationDate( Date date ); 282 283 /** 284 * Get the Last Successful Login Date for this account. 285 * 286 * @return the date of the last successful login 287 */ 288 Date getLastLoginDate(); 289 290 /** 291 * Sets the Last Successful Login Date for this account. 292 */ 293 void setLastLoginDate( Date date ); 294 295 /** 296 * as we can user multiple userManagers implementation we must track from which one this one comes. 297 * @since 2.1 298 * @return userManager id 299 */ 300 String getUserManagerId(); 301 302 }