HiRISE

HiRISE.HiWish
Class People

java.lang.Object
  extended by HiRISE.HiWish.People

public class People
extends Object

Handles all People-related queries.


Field Summary
protected static Logger logger
          Logger instance
 
Constructor Summary
People(Connection conn)
          Create a new instance with a database connection.
 
Method Summary
 void changeEmail(long id)
           
 void changePassword(long id, String password)
          Change the password for a particular user.
 boolean checkUsername(RegisterForm form)
          Determines if a username is already in use.
 void clearConfirmationToken(String token)
          Clear the token by value
 int countWishes(long id)
          Perform count for wish throttling.
 User createUser(RegisterForm form)
          Inserts a new stub User with the info from the registration form.
 boolean editUser(long id, EditSelfForm form)
          Change the record for an existing user.
 void fillUser(long id, EditSelfForm form)
          Fill in information about a user, based on info from form.
 User getUser(LoginForm form)
          Attempts to load a User from the database.
 User getUser(ResetPasswordForm form)
          A user has forgotten their password, this method will confirm that there is a user with their username.
 User getUser(String hashpass)
          Attempts to load a User from the database.
 User getUserByToken(String token)
          Locate a user by token value.
 void setConfirmationToken(String username, User.ConfirmationType type, String token)
          Set a token for a user
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static Logger logger
Logger instance

Constructor Detail

People

public People(Connection conn)
Create a new instance with a database connection.

Parameters:
conn - The connection
Method Detail

getUser

public User getUser(LoginForm form)
             throws SQLException
Attempts to load a User from the database. Return null if not found.

Parameters:
form - Initialized form instance
Returns:
User instance or null
Throws:
SQLException - Could not complete query

getUser

public User getUser(String hashpass)
             throws SQLException
Attempts to load a User from the database. Return null if not found.

Parameters:
hashpass - SHA-1 digested password
Returns:
User instance or null
Throws:
SQLException - Could not complete query

checkUsername

public boolean checkUsername(RegisterForm form)
                      throws SQLException
Determines if a username is already in use.

Parameters:
form - The input
Returns:
True if username is already claimed
Throws:
SQLException - Could not complete query

getUser

public User getUser(ResetPasswordForm form)
             throws SQLException
A user has forgotten their password, this method will confirm that there is a user with their username.

Parameters:
form - Info to look up user
Returns:
The user
Throws:
SQLException - Query failed

fillUser

public void fillUser(long id,
                     EditSelfForm form)
              throws SQLException
Fill in information about a user, based on info from form.

Parameters:
id - The user's ID.
form - The form
Throws:
SQLException - Query failed

createUser

public User createUser(RegisterForm form)
                throws SQLException
Inserts a new stub User with the info from the registration form. The password will be null. When the email is confirmed, the user will be prompted to set the password.

Parameters:
form - The registration input
Returns:
The created instance
Throws:
SQLException - Could not insert user properly

changePassword

public void changePassword(long id,
                           String password)
                    throws SQLException
Change the password for a particular user.

Parameters:
id - The database key index
password - New password (undigested)
Throws:
SQLException - Query failed

changeEmail

public void changeEmail(long id)
                 throws SQLException
Parameters:
id - The database key index
Throws:
SQLException - Sets the EMAIL_ADDRESS to be the value in EMAIL_ADDRESS_TMP, and sets EMAIL_ADDRESS_TMP to be NULL. This should only be called after EMAIL_ADDRESS_TMP has already been set and that email address has been validated.

editUser

public boolean editUser(long id,
                        EditSelfForm form)
                 throws SQLException
Change the record for an existing user.

Parameters:
id - The database key index
form - Updated info
Returns:
true if the email address in the form was different from the email in the database, false otherwise. If the email address specified in the form is different than the value stored in the database, it the database field EMAIL_ADDRESS_TMP is set to be the value of the form, and the method returns true. If they are the same, the method returns false.
Throws:
SQLException - Query failed

countWishes

public int countWishes(long id)
                throws SQLException
Perform count for wish throttling.

Parameters:
id - The user ID
Returns:
number of wishes accepted in the last 24 hours
Throws:
SQLException - Could not complete query

setConfirmationToken

public void setConfirmationToken(String username,
                                 User.ConfirmationType type,
                                 String token)
                          throws SQLException
Set a token for a user

Parameters:
username - The username
type - Token type
token - Token value
Throws:
SQLException - database update failed

clearConfirmationToken

public void clearConfirmationToken(String token)
                            throws SQLException
Clear the token by value

Parameters:
token - the value
Throws:
SQLException - Could not clear token

getUserByToken

public User getUserByToken(String token)
                    throws SQLException
Locate a user by token value.

Parameters:
token - The unguessable value
Returns:
the user object
Throws:
SQLException - could not get user

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona