public class UserSignupManager extends AbstractMyBatisDAO
Modifier and Type | Class and Description |
---|---|
static class |
UserSignupManager.TempUser
Bean representing a user sign-up request.
|
Modifier and Type | Field and Description |
---|---|
protected I18nUtils |
_i18nUtils
The i18n utils.
|
protected URIResolver |
_pageUriResolver
The page URI resolver.
|
protected String |
_pwdChangeTable
The password change table.
|
protected AmetysObjectResolver |
_resolver
The ametys object resolver.
|
protected SiteConfigurationExtensionPoint |
_siteConf
The site configuration extension point.
|
protected SiteManager |
_siteManager
The site manager.
|
protected String |
_tempUsersTable
The temporary users table.
|
protected URIResolverExtensionPoint |
_uriResolverEP
The ametys object resolver.
|
protected UserManager |
_userManager
The user manager.
|
protected UserPopulationDAO |
_userPopulationDAO
The DAO for user populations
|
protected UserSignUpConfiguration |
_userSignUpConfiguration
The user sign up configuration
|
static int |
LOST_PASSWORD_EMPTY_EMAIL
Lost password return code: the user provided have an empty email
|
static int |
LOST_PASSWORD_POPULATION_UNKNOWN
Lost password return code: the population the user provided doesn't correspond to a user.
|
static int |
LOST_PASSWORD_UNMODIFIABLE_USER_DIRECTORY
Lost password return code: the user provided belongs to an unmodifiable user directory
|
static int |
LOST_PASSWORD_USER_UNKNOWN
Lost password return code: the login or e-mail the user provided doesn't correspond to a population.
|
static String |
ROLE
The component role.
|
static int |
SIGNUP_ERROR_TEMP_EMAIL_ALREADY_EXISTS
Temporary signup return code: a user tried to sign-up but the e-mail already exists in the temporary table.
|
static int |
SIGNUP_ERROR_USER_ALREADY_EXISTS
Temporary signup return code: a user tried to sign-up but the FO UsersManager already possesses a user with this e-mail as login.
|
static int |
SIGNUP_NO_ERROR
Return code which indicates no error.
|
static int |
SIGNUP_RESET_ERROR_EMAIL_UNKNOWN
Reset token return code: a user asked for a new token, but no subscription request can be found with this e-mail.
|
static int |
SIGNUP_TOKEN_EXPIRED
Token return code: a user provided a token, but it itn't valid anymore.
|
static int |
SIGNUP_TOKEN_UNKNOWN
Token return code: a user provided a token, but it doesn't exist.
|
_manager
Constructor and Description |
---|
UserSignupManager() |
Modifier and Type | Method and Description |
---|---|
protected void |
addPasswordToken(String siteName,
String login,
String token,
String population)
Create a user password change request in the database.
|
protected int |
addTemporaryUser(String siteName,
String email,
String firstName,
String lastName,
String token,
String population,
String userDirectoryId)
Create a user sign-up request ("temporary" user) in the database.
|
int |
changeUserPassword(String siteName,
String login,
String token,
String newPassword,
String population)
Change the user password.
|
int |
checkPasswordToken(String siteName,
String login,
String token,
String population)
Check the password change request token.
|
protected void |
checkPublicSignup(String siteName)
Verify that public sign-up is allowed.
|
int |
checkToken(String siteName,
String email,
String token,
String population,
String userDirectoryId)
Check the sign-up request token.
|
void |
configure(Configuration configuration) |
Page |
getPwdChangePage(String siteName,
String language)
Get the password change page in a given site and sitemap.
|
AmetysObjectIterable<Page> |
getPwdChangePages(String siteName,
String language)
Get all the pages tagged "password change".
|
Page |
getSignupPage(String siteName,
String language)
Get the sign-up page in a given site and sitemap.
If more than one page are tagged "sign-up", return the first. |
AmetysObjectIterable<Page> |
getSignupPages(String siteName,
String language)
Get all the pages tagged "sign-up".
|
protected UserSignupManager.TempUser |
getTempUser(String siteName,
String email,
String population,
String userDirectoryId)
Get a temporary user from his site name and e-mail.
|
protected UserSignupManager.TempUser |
getTempUser(String siteName,
String email,
String token,
String population,
String userDirectoryId)
Get a temporary user from his site name, e-mail and/or token.
|
Page |
getUserMainPrefsPage(String siteName,
String language)
Get the user main preferences page in a given site and sitemap.
|
AmetysObjectIterable<Page> |
getUserMainPrefsPages(String siteName,
String language)
Get all the pages tagged "user main preferences".
|
boolean |
isPublicSignupAllowed(String siteName)
Test if public signup is allowed in a site.
|
void |
removeExpiredPasswordTokens()
Remove the expired change password request tokens.
|
void |
removeExpiredTokens()
Remove the expired sign-up request tokens.
|
protected void |
removePasswordToken(String siteName,
String login,
String token,
String population)
Remove the password change request.
|
protected void |
removeTempUser(String siteName,
String email,
String token,
String population,
String userDirectoryId)
Remove the temporary .
|
int |
resetPassword(String siteName,
String language,
String login,
String populationId)
Create a reset password request and send a confirmation e-mail.
|
int |
resetTempSignup(String siteName,
String language,
String email,
String population,
String userDirectoryId)
Reset a sign-up request: generate a new token and re-send the confirmation e-mail.
|
protected void |
sendResetPasswordMail(String siteName,
String language,
User user,
String token)
Send a sign-up confirmation link by e-mail.
|
protected void |
sendSignupConfirmMail(String siteName,
String language,
String email,
String firstName,
String lastName,
String token)
Send a sign-up confirmation link by e-mail.
|
void |
service(ServiceManager serviceManager) |
int |
signup(String siteName,
String email,
String token,
String password,
String population,
String userDirectoryId)
Create the user in the FO UsersManager from his temporary request.
|
int |
temporarySignup(String siteName,
String language,
String email,
String firstName,
String lastName,
String population,
String userDirectoryId)
Validate and store a sign-up request and send a confirmation e-mail.
|
protected void |
updateTempToken(String siteName,
String email,
String newToken,
String population,
String userDirectoryId)
Update the sign-up request token: reset the date and set a new token.
|
boolean |
userExists(String email,
String population)
Tests if the FO users manager knows of the user with the given e-mail as the login.
|
Map<String,Errors> |
validate(String siteName,
String email,
String firstName,
String lastName,
Map<String,String> additionalValues)
Validate the user subscription data.
|
Map<String,Errors> |
validatePassword(String siteName,
String password,
String login,
String population)
Validate the user password.
|
_configureDatasource, _getDataSourceId, _getMyBatisConfiguration, contextualize, getSession, getSession, reload, setPluginInfo
getLogger, setLogger
public static final int SIGNUP_NO_ERROR
public static final int SIGNUP_ERROR_TEMP_EMAIL_ALREADY_EXISTS
public static final int SIGNUP_ERROR_USER_ALREADY_EXISTS
public static final int SIGNUP_TOKEN_UNKNOWN
public static final int SIGNUP_TOKEN_EXPIRED
public static final int SIGNUP_RESET_ERROR_EMAIL_UNKNOWN
public static final int LOST_PASSWORD_USER_UNKNOWN
public static final int LOST_PASSWORD_POPULATION_UNKNOWN
public static final int LOST_PASSWORD_UNMODIFIABLE_USER_DIRECTORY
public static final int LOST_PASSWORD_EMPTY_EMAIL
protected UserManager _userManager
protected UserPopulationDAO _userPopulationDAO
protected SiteManager _siteManager
protected SiteConfigurationExtensionPoint _siteConf
protected AmetysObjectResolver _resolver
protected URIResolverExtensionPoint _uriResolverEP
protected URIResolver _pageUriResolver
protected I18nUtils _i18nUtils
protected UserSignUpConfiguration _userSignUpConfiguration
protected String _tempUsersTable
protected String _pwdChangeTable
public UserSignupManager()
public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
service
in class AbstractMyBatisDAO
ServiceException
public void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
configure
in class AbstractMyBatisDAO
ConfigurationException
public boolean isPublicSignupAllowed(String siteName)
siteName
- the site to test.public Page getSignupPage(String siteName, String language)
siteName
- the site name.language
- the sitemap name.public AmetysObjectIterable<Page> getSignupPages(String siteName, String language)
siteName
- the site name.language
- the sitemap name.public Page getPwdChangePage(String siteName, String language)
siteName
- the site name.language
- the sitemap name.public AmetysObjectIterable<Page> getPwdChangePages(String siteName, String language)
siteName
- the site name.language
- the sitemap name.public Page getUserMainPrefsPage(String siteName, String language)
siteName
- the site name.language
- the sitemap name.public AmetysObjectIterable<Page> getUserMainPrefsPages(String siteName, String language)
siteName
- the site name.language
- the sitemap name.public boolean userExists(String email, String population) throws UserManagementException
email
- the e-mail to test.population
- The id of the populationUserManagementException
- if an error occurs.public Map<String,Errors> validate(String siteName, String email, String firstName, String lastName, Map<String,String> additionalValues) throws UserManagementException
siteName
- the site name.email
- the user e-mail.firstName
- the user first name.lastName
- the user last name.additionalValues
- the additional user values.UserManagementException
- if an error occurs.public Map<String,Errors> validatePassword(String siteName, String password, String login, String population) throws UserManagementException
siteName
- the site name.password
- the password to validate.login
- the login of the userpopulation
- The id of the populationUserManagementException
- if an error occurs.public int temporarySignup(String siteName, String language, String email, String firstName, String lastName, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.language
- the sitemap name.email
- the user e-mail address.firstName
- the user first name.lastName
- the user last name.population
- the populationuserDirectoryId
- the id of the user directory of the populationUserManagementException
- if an error occurs.public int resetTempSignup(String siteName, String language, String email, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.language
- the sitemap name.email
- the user e-mail address.population
- The id of the populationuserDirectoryId
- The id of the user directory of the populationUserManagementException
- if an error occurs.public int signup(String siteName, String email, String token, String password, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- the user e-mail address.token
- the request token.password
- the user password.population
- The id of the populationuserDirectoryId
- The id of the user directory of the populationUserManagementException
- if an error occurs.public int resetPassword(String siteName, String language, String login, String populationId) throws UserManagementException
siteName
- the site name.language
- the sitemap name.login
- the user login.populationId
- the populationUserManagementException
- if an error occurs.public int changeUserPassword(String siteName, String login, String token, String newPassword, String population) throws UserManagementException
siteName
- the site name.login
- the user login.token
- the password change request token.newPassword
- the new password.population
- the populationUserManagementException
- if an error occurs.public int checkToken(String siteName, String email, String token, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- the user e-mail.token
- the sign-up request token.population
- The id of the populationuserDirectoryId
- The id of the user directory of the populationUserManagementException
- if an error occurs.public int checkPasswordToken(String siteName, String login, String token, String population) throws UserManagementException
siteName
- the site name.login
- the user login.token
- the password change request token.population
- the populationUserManagementException
- if an error occurs.public void removeExpiredTokens() throws UserManagementException
UserManagementException
- if an error occurs.public void removeExpiredPasswordTokens() throws UserManagementException
UserManagementException
- if an error occurs.protected void checkPublicSignup(String siteName) throws UserManagementException
siteName
- the site name.UserManagementException
- if public sign-up is not enabled.protected int addTemporaryUser(String siteName, String email, String firstName, String lastName, String token, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- the user e-mail.firstName
- the user first name.lastName
- the user last name.token
- the generated token.population
- the populationuserDirectoryId
- the id of the user directory of the populationUserManagementException
- if an error occurs.protected void sendSignupConfirmMail(String siteName, String language, String email, String firstName, String lastName, String token) throws UserManagementException
siteName
- the site name.language
- the e-mail language.email
- the user e-mail.firstName
- the user first name.lastName
- the user last name.token
- the generated token.UserManagementException
- if an error occurs.protected void updateTempToken(String siteName, String email, String newToken, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- the user e-mail.newToken
- the new token.population
- The id of the populationuserDirectoryId
- The id of the user directory of the populationUserManagementException
- if an error occurs.protected void addPasswordToken(String siteName, String login, String token, String population) throws UserManagementException
siteName
- the site name.login
- the user login.token
- the generated token.population
- the populationUserManagementException
- if an error occurs.protected UserSignupManager.TempUser getTempUser(String siteName, String email, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- The temporary user e-mail. Cannot be null.population
- the populationuserDirectoryId
- the id of the user directory of the populationUserManagementException
- if an error occurs.protected UserSignupManager.TempUser getTempUser(String siteName, String email, String token, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- The temporary user e-mail. Can be null.token
- The temporary user token. Can be null.population
- the population. Must be not null if email is not nulluserDirectoryId
- the id of the user directory of the population. Must be not null if email is not nullUserManagementException
- if an error occurs.protected void removeTempUser(String siteName, String email, String token, String population, String userDirectoryId) throws UserManagementException
siteName
- the site name.email
- the user e-mail address.token
- the request token.population
- the populationuserDirectoryId
- the id of the user directory of the populationUserManagementException
- if an error occurs.protected void removePasswordToken(String siteName, String login, String token, String population) throws UserManagementException
siteName
- the site name.login
- the user login.token
- the request token.population
- the populationUserManagementException
- if an error occurs.protected void sendResetPasswordMail(String siteName, String language, User user, String token) throws UserManagementException
siteName
- the site name.language
- the e-mail language.user
- the user object.token
- the generated token.UserManagementException
- if an error occurs.