@Service(value="blCustomerService") public class CustomerServiceImpl extends Object implements CustomerService
| Modifier and Type | Field and Description |
|---|---|
protected EmailInfo |
changePasswordEmailInfo |
protected CustomerDao |
customerDao |
protected CustomerForgotPasswordSecurityTokenDao |
customerForgotPasswordSecurityTokenDao |
protected EmailService |
emailService |
protected EmailInfo |
forgotPasswordEmailInfo |
protected EmailInfo |
forgotUsernameEmailInfo |
protected IdGenerationService |
idGenerationService |
protected List<PasswordUpdatedHandler> |
passwordChangedHandlers |
protected org.springframework.security.crypto.password.PasswordEncoder |
passwordEncoderBean
This is simply a placeholder to be used by
#setupPasswordEncoder() to determine if we're using the
new PasswordEncoder or the deprecated PasswordEncoder |
protected List<PasswordUpdatedHandler> |
passwordResetHandlers |
protected int |
passwordTokenLength |
protected List<PostRegistrationObserver> |
postRegisterListeners |
protected EmailInfo |
registrationEmailInfo |
protected RoleDao |
roleDao |
protected int |
tokenExpiredMinutes |
| Constructor and Description |
|---|
CustomerServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
addPostRegisterListener(PostRegistrationObserver postRegisterListeners) |
protected Map<String,Object> |
buildCustomerRuleParams(Customer customer) |
Customer |
changePassword(PasswordChange passwordChange) |
protected void |
checkCustomer(Customer customer,
GenericResponse response) |
protected void |
checkPassword(String password,
String confirmPassword,
GenericResponse response) |
GenericResponse |
checkPasswordResetToken(String token,
Customer customer)
Verifies that a customer has a valid token.
|
protected CustomerForgotPasswordSecurityToken |
checkPasswordResetToken(String token,
Customer customer,
GenericResponse response) |
Customer |
createCustomer() |
Customer |
createCustomerFromId(Long customerId)
|
Customer |
createNewCustomer()
Returns a non-persisted
Customer. |
void |
createRegisteredCustomerRoles(Customer customer)
Subclassed implementations can assign unique roles for various customer types
|
boolean |
customerPassesCustomerRule(Customer customer,
CustomerRuleHolder customerRuleHolder)
Determines if the given customer passes the MVEL customer rule
|
void |
deleteCustomer(Customer customer)
Delete the customer entity from the persistent store
|
String |
encodePassword(String rawPassword)
Encodes the clear text parameter, using the salt provided by PasswordEncoder.
|
Long |
findNextCustomerId()
Allow customers to call from subclassed service.
|
protected String |
generateSecurePassword() |
EmailInfo |
getChangePasswordEmailInfo() |
EmailInfo |
getForgotPasswordEmailInfo() |
EmailInfo |
getForgotUsernameEmailInfo() |
List<PasswordUpdatedHandler> |
getPasswordChangedHandlers() |
List<PasswordUpdatedHandler> |
getPasswordResetHandlers() |
int |
getPasswordTokenLength() |
EmailInfo |
getRegistrationEmailInfo() |
int |
getTokenExpiredMinutes() |
protected void |
invalidateAllTokensForCustomer(Customer customer) |
boolean |
isPasswordValid(String rawPassword,
String encodedPassword)
Determines if a password is valid by comparing it to the encoded string, salting is handled internally to the
PasswordEncoder. |
protected boolean |
isTokenExpired(CustomerForgotPasswordSecurityToken fpst) |
protected void |
notifyPostRegisterListeners(Customer customer) |
List<Customer> |
readBatchCustomers(int start,
int pageSize) |
Customer |
readCustomerByEmail(String emailAddress) |
Customer |
readCustomerByExternalId(String userExternalId) |
Customer |
readCustomerById(Long id) |
Customer |
readCustomerByUsername(String username) |
Customer |
readCustomerByUsername(String username,
Boolean cacheable) |
Long |
readNumberOfCustomers() |
Customer |
registerCustomer(Customer customer,
String password,
String passwordConfirm) |
void |
removePostRegisterListener(PostRegistrationObserver postRegisterListeners) |
Customer |
resetPassword(PasswordReset passwordReset) |
GenericResponse |
resetPasswordUsingToken(String username,
String token,
String password,
String confirmPassword)
Updates the password for the passed in customer only if the passed
in token is valid for that customer.
|
Customer |
saveCustomer(Customer customer) |
Customer |
saveCustomer(Customer customer,
boolean register) |
protected void |
sendEmail(String emailAddress,
EmailInfo emailInfo,
Map<String,Object> props) |
GenericResponse |
sendForcedPasswordChangeNotification(String username,
String resetPasswordUrl)
Generates an access token and then emails the user.
|
GenericResponse |
sendForgotPasswordNotification(String username,
String resetPasswordUrl)
Generates an access token and then emails the user.
|
GenericResponse |
sendForgotUsernameNotification(String emailAddress)
Looks up the corresponding
Customer and emails the address on file with
the associated username. |
void |
setChangePasswordEmailInfo(EmailInfo changePasswordEmailInfo) |
void |
setCustomerDao(CustomerDao customerDao) |
void |
setForgotPasswordEmailInfo(EmailInfo forgotPasswordEmailInfo) |
void |
setForgotUsernameEmailInfo(EmailInfo forgotUsernameEmailInfo) |
void |
setPasswordChangedHandlers(List<PasswordUpdatedHandler> passwordChangedHandlers) |
void |
setPasswordResetHandlers(List<PasswordUpdatedHandler> passwordResetHandlers) |
void |
setPasswordTokenLength(int passwordTokenLength) |
void |
setRegistrationEmailInfo(EmailInfo registrationEmailInfo) |
void |
setTokenExpiredMinutes(int tokenExpiredMinutes) |
protected CustomerDao customerDao
protected IdGenerationService idGenerationService
protected CustomerForgotPasswordSecurityTokenDao customerForgotPasswordSecurityTokenDao
protected org.springframework.security.crypto.password.PasswordEncoder passwordEncoderBean
This is simply a placeholder to be used by #setupPasswordEncoder() to determine if we're using the
new PasswordEncoder or the deprecated PasswordEncoder
protected RoleDao roleDao
protected EmailService emailService
protected EmailInfo forgotPasswordEmailInfo
protected EmailInfo forgotUsernameEmailInfo
protected EmailInfo registrationEmailInfo
protected EmailInfo changePasswordEmailInfo
protected int tokenExpiredMinutes
protected int passwordTokenLength
protected final List<PostRegistrationObserver> postRegisterListeners
protected List<PasswordUpdatedHandler> passwordResetHandlers
protected List<PasswordUpdatedHandler> passwordChangedHandlers
@Transactional(value="blTransactionManager") public Customer saveCustomer(Customer customer)
saveCustomer in interface CustomerService@Transactional(value="blTransactionManager") public Customer saveCustomer(Customer customer, boolean register)
saveCustomer in interface CustomerServiceprotected String generateSecurePassword()
@Transactional(value="blTransactionManager") public Customer registerCustomer(Customer customer, String password, String passwordConfirm)
registerCustomer in interface CustomerServicepublic void createRegisteredCustomerRoles(Customer customer)
CustomerServicecreateRegisteredCustomerRoles in interface CustomerServicecustomer - Customer to create roles forpublic Customer readCustomerByEmail(String emailAddress)
readCustomerByEmail in interface CustomerService@Transactional(value="blTransactionManager") public Customer changePassword(PasswordChange passwordChange)
changePassword in interface CustomerService@Transactional(value="blTransactionManager") public Customer resetPassword(PasswordReset passwordReset)
resetPassword in interface CustomerServicepublic void addPostRegisterListener(PostRegistrationObserver postRegisterListeners)
addPostRegisterListener in interface CustomerServicepublic void removePostRegisterListener(PostRegistrationObserver postRegisterListeners)
removePostRegisterListener in interface CustomerServiceprotected void notifyPostRegisterListeners(Customer customer)
public Customer createCustomer()
createCustomer in interface CustomerServicepublic Customer createCustomerFromId(Long customerId)
CustomerServiceCustomer by first looking in the database, otherwise creating a new non-persisted CustomercreateCustomerFromId in interface CustomerServicecustomerId - the id of the customer to lookuppublic Long findNextCustomerId()
CustomerServicefindNextCustomerId in interface CustomerServicepublic Customer createNewCustomer()
CustomerServiceCustomer. Typically used with registering a new customer.createNewCustomer in interface CustomerServicepublic void deleteCustomer(Customer customer)
CustomerServicedeleteCustomer in interface CustomerServicecustomer - the customer entity to removepublic Customer readCustomerByUsername(String username)
readCustomerByUsername in interface CustomerServicepublic Customer readCustomerByUsername(String username, Boolean cacheable)
readCustomerByUsername in interface CustomerServicepublic Customer readCustomerById(Long id)
readCustomerById in interface CustomerServicepublic Customer readCustomerByExternalId(String userExternalId)
readCustomerByExternalId in interface CustomerServicepublic void setCustomerDao(CustomerDao customerDao)
public String encodePassword(String rawPassword)
CustomerService
This method can only be called once per password. The salt is randomly generated internally in the PasswordEncoder
and appended to the hash to provide the resulting encoded password. Once this has been called on a password,
going forward all checks for authenticity must be done by CustomerService.isPasswordValid(String, String) as encoding the
same password twice will result in different encoded passwords.
encodePassword in interface CustomerServicerawPassword - the unencoded passwordpublic boolean isPasswordValid(String rawPassword, String encodedPassword)
CustomerServicePasswordEncoder.
This method must always be called to verify if a password is valid after the original encoded password is generated
due to PasswordEncoder randomly generating salts internally and appending them to the resulting hash.
isPasswordValid in interface CustomerServicerawPassword - the unencoded passwordencodedPassword - the encoded password to compare againstpublic boolean customerPassesCustomerRule(Customer customer, CustomerRuleHolder customerRuleHolder)
CustomerServicecustomerPassesCustomerRule in interface CustomerServicecustomerRuleHolder - an MVEL rule targeting Customerspublic List<PasswordUpdatedHandler> getPasswordResetHandlers()
getPasswordResetHandlers in interface CustomerServicepublic void setPasswordResetHandlers(List<PasswordUpdatedHandler> passwordResetHandlers)
setPasswordResetHandlers in interface CustomerServicepublic List<PasswordUpdatedHandler> getPasswordChangedHandlers()
getPasswordChangedHandlers in interface CustomerServicepublic void setPasswordChangedHandlers(List<PasswordUpdatedHandler> passwordChangedHandlers)
setPasswordChangedHandlers in interface CustomerService@Transactional(value="blTransactionManager") public GenericResponse sendForgotUsernameNotification(String emailAddress)
CustomerServiceCustomer and emails the address on file with
the associated username.sendForgotUsernameNotification in interface CustomerServiceemailAddress - user's email address@Transactional(value="blTransactionManager") public GenericResponse sendForgotPasswordNotification(String username, String resetPasswordUrl)
CustomerServicesendForgotPasswordNotification in interface CustomerServiceusername - - the user to send a reset password email to.resetPasswordUrl - - Base url to include in the email.@Transactional(value="blTransactionManager") public GenericResponse sendForcedPasswordChangeNotification(String username, String resetPasswordUrl)
CustomerServicesendForcedPasswordChangeNotification in interface CustomerServiceusername - - the user to send a reset password email to.resetPasswordUrl - - Base url to include in the email.public GenericResponse checkPasswordResetToken(String token, Customer customer)
CustomerServicecheckPasswordResetToken in interface CustomerServicetoken - password reset tokencustomer - Customer who owns the tokenprotected CustomerForgotPasswordSecurityToken checkPasswordResetToken(String token, Customer customer, GenericResponse response)
@Transactional(value="blTransactionManager") public GenericResponse resetPasswordUsingToken(String username, String token, String password, String confirmPassword)
CustomerServiceresetPasswordUsingToken in interface CustomerServiceusername - Username of the customertoken - Valid reset tokenpassword - new passwordprotected void invalidateAllTokensForCustomer(Customer customer)
protected void checkCustomer(Customer customer, GenericResponse response)
protected void checkPassword(String password, String confirmPassword, GenericResponse response)
protected boolean isTokenExpired(CustomerForgotPasswordSecurityToken fpst)
protected void sendEmail(String emailAddress, EmailInfo emailInfo, Map<String,Object> props)
public int getTokenExpiredMinutes()
public void setTokenExpiredMinutes(int tokenExpiredMinutes)
public int getPasswordTokenLength()
public void setPasswordTokenLength(int passwordTokenLength)
public EmailInfo getForgotPasswordEmailInfo()
public void setForgotPasswordEmailInfo(EmailInfo forgotPasswordEmailInfo)
public EmailInfo getForgotUsernameEmailInfo()
public void setForgotUsernameEmailInfo(EmailInfo forgotUsernameEmailInfo)
public EmailInfo getRegistrationEmailInfo()
public void setRegistrationEmailInfo(EmailInfo registrationEmailInfo)
public EmailInfo getChangePasswordEmailInfo()
public void setChangePasswordEmailInfo(EmailInfo changePasswordEmailInfo)
public List<Customer> readBatchCustomers(int start, int pageSize)
readBatchCustomers in interface CustomerServicepublic Long readNumberOfCustomers()
readNumberOfCustomers in interface CustomerServiceCopyright © 2018. All rights reserved.