org.dspace.eperson
Class AccountManager

java.lang.Object
  extended by org.dspace.eperson.AccountManager

public class AccountManager
extends Object

Methods for handling registration by email and forgotten passwords. When someone registers as a user, or forgets their password, the sendRegistrationInfo or sendForgotPasswordInfo methods can be used to send an email to the user. The email contains a special token, a long string which is randomly generated and thus hard to guess. When the user presents the token back to the system, the AccountManager can use the token to determine the identity of the eperson. *NEW* now ignores expiration dates so that tokens never expire

Version:
$Revision: 3762 $
Author:
Peter Breton

Constructor Summary
protected AccountManager()
          Protected Constructor
 
Method Summary
static void deleteToken(Context context, String token)
          Delete token.
static String getEmail(Context context, String token)
          Return the e-mail address referred to by a token, or null if email address can't be found ignores expiration of token
static EPerson getEPerson(Context context, String token)
           Return the EPerson corresponding to token, where token was emailed to the person by either the sendRegistrationInfo or sendForgotPasswordInfo methods.
static void sendForgotPasswordInfo(Context context, String email)
          Email forgot password info to the given email address.
protected static TableRow sendInfo(Context context, String email, boolean isRegister, boolean send)
           
static void sendRegistrationInfo(Context context, String email)
          Email registration info to the given email address.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccountManager

protected AccountManager()
Protected Constructor

Method Detail

sendRegistrationInfo

public static void sendRegistrationInfo(Context context,
                                        String email)
                                 throws SQLException,
                                        IOException,
                                        javax.mail.MessagingException,
                                        AuthorizeException
Email registration info to the given email address. Potential error conditions: Cannot create registration data in database (throws SQLException) Error sending email (throws MessagingException) Error reading email template (throws IOException) Authorization error (throws AuthorizeException)

Parameters:
context - DSpace context
email - Email address to send the registration email to
Throws:
SQLException
IOException
javax.mail.MessagingException
AuthorizeException

sendForgotPasswordInfo

public static void sendForgotPasswordInfo(Context context,
                                          String email)
                                   throws SQLException,
                                          IOException,
                                          javax.mail.MessagingException,
                                          AuthorizeException
Email forgot password info to the given email address. Potential error conditions: No EPerson with that email (returns null) Cannot create registration data in database (throws SQLException) Error sending email (throws MessagingException) Error reading email template (throws IOException) Authorization error (throws AuthorizeException)

Parameters:
context - DSpace context
email - Email address to send the forgot-password email to
Throws:
SQLException
IOException
javax.mail.MessagingException
AuthorizeException

getEPerson

public static EPerson getEPerson(Context context,
                                 String token)
                          throws SQLException,
                                 AuthorizeException

Return the EPerson corresponding to token, where token was emailed to the person by either the sendRegistrationInfo or sendForgotPasswordInfo methods.

If the token is not found return null.

Parameters:
context - DSpace context
token - Account token
Returns:
The EPerson corresponding to token, or null.
Throws:
SQLException - If the token or eperson cannot be retrieved from the database.
AuthorizeException

getEmail

public static String getEmail(Context context,
                              String token)
                       throws SQLException
Return the e-mail address referred to by a token, or null if email address can't be found ignores expiration of token

Parameters:
context - DSpace context
token - Account token
Returns:
The email address corresponding to token, or null.
Throws:
SQLException

deleteToken

public static void deleteToken(Context context,
                               String token)
                        throws SQLException
Delete token.

Parameters:
context - DSpace context
token - The token to delete
Throws:
SQLException - If a database error occurs

sendInfo

protected static TableRow sendInfo(Context context,
                                   String email,
                                   boolean isRegister,
                                   boolean send)
                            throws SQLException,
                                   IOException,
                                   javax.mail.MessagingException,
                                   AuthorizeException
Throws:
SQLException
IOException
javax.mail.MessagingException
AuthorizeException


Copyright © 2010 DuraSpace. All Rights Reserved.