Package org.dspace.eperson
Class AccountServiceImpl
java.lang.Object
org.dspace.eperson.AccountServiceImpl
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteToken(Context context, String token) Delete token.Return the e-mail address referred to by a token, or null if email address can't be found ignores expiration of tokengetEPerson(Context context, String token) Return the EPerson corresponding to token, where token was emailed to the person by either the sendRegistrationInfo or sendForgotPasswordInfo methods.protected voidsendEmail(Context context, String email, boolean isRegister, RegistrationData rd) Send a DSpace message to the given email address.voidsendForgotPasswordInfo(Context context, String email) Email forgot password info to the given email address.protected RegistrationDataTHIS IS AN INTERNAL METHOD.voidsendRegistrationInfo(Context context, String email) Email registration info to the given email address.
-
Field Details
-
ePersonService
-
registrationDataService
-
-
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:
sendRegistrationInfoin interfaceAccountService- Parameters:
context- DSpace contextemail- 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:
sendForgotPasswordInfoin interfaceAccountService- Parameters:
context- DSpace contextemail- 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
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:
getEPersonin interfaceAccountService- Parameters:
context- DSpace contexttoken- 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
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:
getEmailin interfaceAccountService- Parameters:
context- DSpace contexttoken- Account token- Returns:
- The email address corresponding to token, or null.
- Throws:
SQLException- passed through.
-
deleteToken
Delete token.- Specified by:
deleteTokenin interfaceAccountService- Parameters:
context- DSpace contexttoken- 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 contextemail- Email address to send the forgot-password email toisRegister- If true, this is for registration; otherwise, it is for forgot-passwordsend- 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 databasejakarta.mail.MessagingException- Error sending emailIOException- Error reading email templateAuthorizeException- 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 istrue, this is registration email; otherwise, it is a forgot-password email.- Parameters:
context- The relevant DSpace Context.email- The email address to mail toisRegister- 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 emailIOException- 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.
-