Class AccountServiceImpl

java.lang.Object
org.dspace.eperson.AccountServiceImpl
All Implemented Interfaces:
AccountService

public class AccountServiceImpl extends Object implements AccountService
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$
Author:
Peter Breton
  • Field Details

  • Constructor Details

    • AccountServiceImpl

      protected AccountServiceImpl()
  • Method Details

    • sendRegistrationInfo

      public void sendRegistrationInfo(Context context, String email) throws SQLException, IOException, jakarta.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).
      Specified by:
      sendRegistrationInfo in interface AccountService
      Parameters:
      context - DSpace context
      email - Email address to send the registration email to
      Throws:
      SQLException - passed through.
      IOException - passed through.
      jakarta.mail.MessagingException - passed through.
      AuthorizeException - passed through.
    • sendForgotPasswordInfo

      public void sendForgotPasswordInfo(Context context, String email) throws SQLException, IOException, jakarta.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).
      Specified by:
      sendForgotPasswordInfo in interface AccountService
      Parameters:
      context - DSpace context
      email - Email address to send the forgot-password email to
      Throws:
      SQLException - passed through.
      IOException - passed through.
      jakarta.mail.MessagingException - passed through.
      AuthorizeException - passed through.
    • getEPerson

      public 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.

      Specified by:
      getEPerson in interface AccountService
      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 - passed through.
    • getEmail

      public 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
      Specified by:
      getEmail in interface AccountService
      Parameters:
      context - DSpace context
      token - Account token
      Returns:
      The email address corresponding to token, or null.
      Throws:
      SQLException - passed through.
    • deleteToken

      public void deleteToken(Context context, String token) throws SQLException
      Delete token.
      Specified by:
      deleteToken in interface AccountService
      Parameters:
      context - DSpace context
      token - The token to delete
      Throws:
      SQLException - If a database error occurs
    • sendInfo

      protected RegistrationData sendInfo(Context context, String email, boolean isRegister, boolean send) throws SQLException, IOException, jakarta.mail.MessagingException, AuthorizeException
      THIS IS AN INTERNAL METHOD. THE SEND PARAMETER ALLOWS IT TO BE USED FOR TESTING PURPOSES. Send an info to the EPerson with the given email address. If isRegister is TRUE, this is registration email; otherwise, it is forgot-password email. If send is TRUE, the email is sent; otherwise it is skipped. Potential error conditions:
      Parameters:
      context - DSpace context
      email - Email address to send the forgot-password email to
      isRegister - If true, this is for registration; otherwise, it is for forgot-password
      send - If true, send email; otherwise do not send any email
      Returns:
      null if no EPerson with that email found
      Throws:
      SQLException - Cannot create registration data in database
      jakarta.mail.MessagingException - Error sending email
      IOException - Error reading email template
      AuthorizeException - Authorization error
    • sendEmail

      protected void sendEmail(Context context, String email, boolean isRegister, RegistrationData rd) throws jakarta.mail.MessagingException, IOException, SQLException
      Send a DSpace message to the given email address. If isRegister is true, this is registration email; otherwise, it is a forgot-password email.
      Parameters:
      context - The relevant DSpace Context.
      email - The email address to mail to
      isRegister - If true, this is registration email; otherwise it is forgot-password email.
      rd - The RDBMS row representing the registration data.
      Throws:
      jakarta.mail.MessagingException - If an error occurs while sending email
      IOException - A general class of exceptions produced by failed or interrupted I/O operations.
      SQLException - An exception that provides information on a database access error or other errors.