View Javadoc

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