1 package org.apache.turbine.om.security; 2 3 import java.util.Date; 4 5 /* 6 * Licensed to the Apache Software Foundation (ASF) under one 7 * or more contributor license agreements. See the NOTICE file 8 * distributed with this work for additional information 9 * regarding copyright ownership. The ASF licenses this file 10 * to you under the Apache License, Version 2.0 (the 11 * "License"); you may not use this file except in compliance 12 * with the License. You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, 17 * software distributed under the License is distributed on an 18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19 * KIND, either express or implied. See the License for the 20 * specific language governing permissions and limitations 21 * under the License. 22 */ 23 24 import java.util.Map; 25 26 import javax.servlet.http.HttpSessionBindingListener; 27 28 import org.apache.fulcrum.security.model.turbine.entity.TurbineUser; 29 30 /** 31 * This interface represents functionality that all users of the 32 * Turbine system require. 33 * 34 * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a> 35 * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a> 36 * @author <a href="mailto:jon@collab.net">Jon S. Stevens</a> 37 * @author <a href="mailto:cberry@gluecode.com">Craig D. Berry</a> 38 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a> 39 * @version $Id$ 40 */ 41 public interface User 42 extends HttpSessionBindingListener, TurbineUserDelegate, TurbineUser 43 { 44 /** The 'perm storage' key name for the create_date field. */ 45 String CREATE_DATE = "CREATE_DATE"; 46 47 /** The 'perm storage' key name for the last_login field. */ 48 String LAST_LOGIN = "LAST_LOGIN"; 49 50 /** The 'perm storage' key for the confirm_value field. */ 51 String CONFIRM_VALUE = "CONFIRM_VALUE"; 52 53 /** This is the value that is stored in the database for confirmed users */ 54 String CONFIRM_DATA = "CONFIRMED"; 55 56 /** The 'perm storage' key name for the access counter. */ 57 String ACCESS_COUNTER = "_access_counter"; 58 59 /** The 'temp storage' key name for the session access counter */ 60 String SESSION_ACCESS_COUNTER = "_session_access_counter"; 61 62 /** The 'temp storage' key name for the 'has logged in' flag */ 63 String HAS_LOGGED_IN = "_has_logged_in"; 64 65 /** The session key for the User object. */ 66 String SESSION_KEY = "turbine.user"; 67 68 /** 69 * Gets the access counter for a user from perm storage. 70 * 71 * @return The access counter for the user. 72 */ 73 int getAccessCounter(); 74 75 /** 76 * Gets the access counter for a user during a session. 77 * 78 * @return The access counter for the user for the session. 79 */ 80 int getAccessCounterForSession(); 81 82 /** 83 * Gets the last access date for this User. This is the last time 84 * that the user object was referenced. 85 * 86 * @return A Java Date with the last access date for the user. 87 */ 88 Date getLastAccessDate(); 89 90 /** 91 * Gets the create date for this User. This is the time at which 92 * the user object was created. 93 * 94 * @return A Java Date with the date of creation for the user. 95 */ 96 Date getCreateDate(); 97 98 /** 99 * Returns the user's last login date. 100 * 101 * @return A Java Date with the last login date for the user. 102 */ 103 Date getLastLogin(); 104 105 /** 106 * Get an object from permanent storage. 107 * 108 * @param name The object's name. 109 * @return An Object with the given name. 110 */ 111 Object getPerm(String name); 112 113 /** 114 * Get an object from permanent storage; return default if value 115 * is null. 116 * 117 * @param name The object's name. 118 * @param def A default value to return. 119 * @return An Object with the given name. 120 */ 121 Object getPerm(String name, Object def); 122 123 /** 124 * This should only be used in the case where we want to save the 125 * data to the database. 126 * 127 * @return A Map. 128 */ 129 Map<String, Object> getPermStorage(); 130 131 /** 132 * This should only be used in the case where we want to save the 133 * data to the database. 134 * 135 * @return A Map. 136 */ 137 Map<String, Object> getTempStorage(); 138 139 /** 140 * Get an object from temporary storage. 141 * 142 * @param name The object's name. 143 * @return An Object with the given name. 144 */ 145 Object getTemp(String name); 146 147 /** 148 * Get an object from temporary storage; return default if value 149 * is null. 150 * 151 * @param name The object's name. 152 * @param def A default value to return. 153 * @return An Object with the given name. 154 */ 155 Object getTemp(String name, Object def); 156 157 /** 158 * This sets whether or not someone has logged in. hasLoggedIn() 159 * returns this value. 160 * 161 * @param value Whether someone has logged in or not. 162 */ 163 void setHasLoggedIn(Boolean value); 164 165 /** 166 * The user is considered logged in if they have not timed out. 167 * 168 * @return True if the user has logged in. 169 */ 170 boolean hasLoggedIn(); 171 172 /** 173 * Increments the permanent hit counter for the user. 174 */ 175 void incrementAccessCounter(); 176 177 /** 178 * Increments the session hit counter for the user. 179 */ 180 void incrementAccessCounterForSession(); 181 182 /** 183 * Remove an object from temporary storage and return the object. 184 * 185 * @param name The name of the object to remove. 186 * @return An Object. 187 */ 188 Object removeTemp(String name); 189 190 /** 191 * Sets the access counter for a user, saved in perm storage. 192 * 193 * @param cnt The new count. 194 */ 195 void setAccessCounter(int cnt); 196 197 /** 198 * Sets the session access counter for a user, saved in temp 199 * storage. 200 * 201 * @param cnt The new count. 202 */ 203 void setAccessCounterForSession(int cnt); 204 205 /** 206 * Sets the last access date for this User. This is the last time 207 * that the user object was referenced. 208 */ 209 void setLastAccessDate(); 210 211 /** 212 * Set last login date/time. 213 * 214 * @param lastLogin The last login date. 215 */ 216 void setLastLogin(Date lastLogin); 217 218 /** 219 * Put an object into permanent storage. 220 * 221 * @param name The object's name. 222 * @param value The object. 223 */ 224 void setPerm(String name, 225 Object value); 226 227 /** 228 * This should only be used in the case where we want to save the 229 * data to the database. 230 * 231 * @param storage A Map. 232 */ 233 void setPermStorage(Map<String, Object> storage); 234 235 /** 236 * This should only be used in the case where we want to save the 237 * data to the database. 238 * 239 * @param storage A Map. 240 */ 241 void setTempStorage(Map<String, Object> storage); 242 243 /** 244 * Put an object into temporary storage. 245 * 246 * @param name The object's name. 247 * @param value The object. 248 */ 249 void setTemp(String name, Object value); 250 251 /** 252 * Sets the creation date for this user. 253 * 254 * @param date Creation date 255 */ 256 void setCreateDate(Date date); 257 258 /** 259 * This method reports whether or not the user has been confirmed 260 * in the system by checking the TurbineUserPeer.CONFIRM_VALUE 261 * column to see if it is equal to CONFIRM_DATA. 262 * 263 * @return True if the user has been confirmed. 264 */ 265 boolean isConfirmed(); 266 267 /** 268 * Sets the confirmation value. 269 * 270 * @param value The confirmation key value. 271 */ 272 void setConfirmed(String value); 273 274 /** 275 * Gets the confirmation value. 276 * 277 * @return The confirmed value 278 */ 279 String getConfirmed(); 280 281 /** 282 * Updates the last login date in the database. 283 * 284 * @throws Exception A generic exception. 285 */ 286 287 void updateLastLogin() 288 throws Exception; 289 }