Class CustomerServiceImpl
java.lang.Object
org.broadleafcommerce.profile.core.service.CustomerServiceImpl
- All Implemented Interfaces:
CustomerService
@Service("blCustomerService")
public class CustomerServiceImpl
extends Object
implements CustomerService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CustomerAddressDaoprotected CustomerDaoprotected CustomerForgotPasswordSecurityTokenDaoprotected BroadleafApplicationEventPublisherprotected IdGenerationServiceprotected List<PasswordUpdatedHandler>protected org.springframework.security.crypto.password.PasswordEncoderprotected List<PasswordUpdatedHandler>protected intprotected final List<PostRegistrationObserver>protected RoleDaoprotected int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPostRegisterListener(PostRegistrationObserver postRegisterListeners) buildCustomerRuleParams(Customer customer) changePassword(PasswordChange passwordChange) protected voidcheckCustomer(Customer customer, GenericResponse response) protected voidcheckPassword(String password, String confirmPassword, GenericResponse response) checkPasswordResetToken(String token, Customer customer) Verifies that a customer has a valid token.protected CustomerForgotPasswordSecurityTokencheckPasswordResetToken(String token, Customer customer, GenericResponse response) createCustomerFromId(Long customerId) Returns a non-persistedCustomerwith a null id.Deprecated.voidcreateRegisteredCustomerRoles(Customer customer) Subclassed implementations can assign unique roles for various customer typesbooleancustomerPassesCustomerRule(Customer customer, CustomerRuleHolder customerRuleHolder) Determines if the given customer passes the MVEL customer rulevoiddeleteCustomer(Customer customer) Delete the customer entity from the persistent storevoiddetachCustomer(Customer customer) Detaches the given Customer instance from the entity manager.encodePassword(String rawPassword) Encodes the clear text parameter, using the salt provided by PasswordEncoder.Allow customers to call from subclassed service.protected Stringintintprotected voidinvalidateAllTokensForCustomer(Customer customer) booleanisPasswordValid(String rawPassword, String encodedPassword) Determines if a password is valid by comparing it to the encoded string, salting is handled internally to thePasswordEncoder.protected booleanprotected voidnotifyPostRegisterListeners(Customer customer) readBatchCustomers(int start, int pageSize) readCustomerByEmail(String emailAddress) readCustomerByExternalId(String userExternalId) readCustomerById(Long id) readCustomerByUsername(String username) readCustomerByUsername(String username, Boolean cacheable) registerCustomer(Customer customer, String password, String passwordConfirm) voidremovePostRegisterListener(PostRegistrationObserver postRegisterListeners) resetPassword(PasswordReset passwordReset) 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.saveCustomer(Customer customer) saveCustomer(Customer customer, boolean register) sendForcedPasswordChangeNotification(String username, String resetPasswordUrl) Generates an access token and then emails the user.sendForgotPasswordNotification(String username, String resetPasswordUrl) Generates an access token and then emails the user.sendForgotUsernameNotification(String emailAddress) Looks up the correspondingCustomerand emails the address on file with the associated username.voidsetCustomerDao(CustomerDao customerDao) voidsetPasswordChangedHandlers(List<PasswordUpdatedHandler> passwordChangedHandlers) voidsetPasswordResetHandlers(List<PasswordUpdatedHandler> passwordResetHandlers) voidsetPasswordTokenLength(int passwordTokenLength) voidsetTokenExpiredMinutes(int tokenExpiredMinutes)
-
Field Details
-
postRegisterListeners
-
eventPublisher
@Autowired @Qualifier("blApplicationEventPublisher") protected BroadleafApplicationEventPublisher eventPublisher -
customerDao
-
customerAddressDao
-
idGenerationService
-
customerForgotPasswordSecurityTokenDao
-
passwordEncoderBean
protected org.springframework.security.crypto.password.PasswordEncoder passwordEncoderBean -
roleDao
-
tokenExpiredMinutes
protected int tokenExpiredMinutes -
passwordTokenLength
protected int passwordTokenLength -
passwordResetHandlers
-
passwordChangedHandlers
-
-
Constructor Details
-
CustomerServiceImpl
public CustomerServiceImpl()
-
-
Method Details
-
saveCustomer
- Specified by:
saveCustomerin interfaceCustomerService
-
saveCustomer
@Transactional("blTransactionManager") public Customer saveCustomer(Customer customer, boolean register) - Specified by:
saveCustomerin interfaceCustomerService
-
generateSecurePassword
-
registerCustomer
@Transactional("blTransactionManager") public Customer registerCustomer(Customer customer, String password, String passwordConfirm) - Specified by:
registerCustomerin interfaceCustomerService
-
createRegisteredCustomerRoles
Description copied from interface:CustomerServiceSubclassed implementations can assign unique roles for various customer types- Specified by:
createRegisteredCustomerRolesin interfaceCustomerService- Parameters:
customer-Customerto create roles for
-
readCustomerByEmail
- Specified by:
readCustomerByEmailin interfaceCustomerService
-
changePassword
@Transactional("blTransactionManager") public Customer changePassword(PasswordChange passwordChange) - Specified by:
changePasswordin interfaceCustomerService
-
resetPassword
- Specified by:
resetPasswordin interfaceCustomerService
-
addPostRegisterListener
- Specified by:
addPostRegisterListenerin interfaceCustomerService
-
removePostRegisterListener
- Specified by:
removePostRegisterListenerin interfaceCustomerService
-
notifyPostRegisterListeners
-
createCustomer
- Specified by:
createCustomerin interfaceCustomerService
-
createCustomerWithNullId
Description copied from interface:CustomerServiceReturns a non-persistedCustomerwith a null id. Typically used with registering a new customer or creating a new anonymous customer. Creating a customer with null id so that we don't need to query the database for the next id everytime an anonymous customer browses the site.- Specified by:
createCustomerWithNullIdin interfaceCustomerService
-
createCustomerFromId
Description copied from interface:CustomerServiceReturns aCustomerby first looking in the database, otherwise creating a new non-persistedCustomer- Specified by:
createCustomerFromIdin interfaceCustomerService- Parameters:
customerId- the id of the customer to lookup
-
findNextCustomerId
Description copied from interface:CustomerServiceAllow customers to call from subclassed service.- Specified by:
findNextCustomerIdin interfaceCustomerService- Returns:
- the next customerId to be used
-
createNewCustomer
Deprecated.Description copied from interface:CustomerServiceReturns a non-persistedCustomer.- Specified by:
createNewCustomerin interfaceCustomerService
-
deleteCustomer
Description copied from interface:CustomerServiceDelete the customer entity from the persistent store- Specified by:
deleteCustomerin interfaceCustomerService- Parameters:
customer- the customer entity to remove
-
detachCustomer
Description copied from interface:CustomerServiceDetaches the given Customer instance from the entity manager.- Specified by:
detachCustomerin interfaceCustomerService
-
readCustomerByUsername
- Specified by:
readCustomerByUsernamein interfaceCustomerService
-
readCustomerByUsername
- Specified by:
readCustomerByUsernamein interfaceCustomerService
-
readCustomerById
- Specified by:
readCustomerByIdin interfaceCustomerService
-
readCustomerByExternalId
- Specified by:
readCustomerByExternalIdin interfaceCustomerService
-
setCustomerDao
-
encodePassword
Description copied from interface:CustomerServiceEncodes the clear text parameter, using the salt provided by PasswordEncoder. Does not change the customer properties. This method only encodes the password and returns the encoded result.This method can only be called once per password. The salt is randomly generated internally in the
PasswordEncoderand 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 byCustomerService.isPasswordValid(String, String)as encoding the same password twice will result in different encoded passwords.- Specified by:
encodePasswordin interfaceCustomerService- Parameters:
rawPassword- the unencoded password- Returns:
- the encoded password
-
isPasswordValid
Description copied from interface:CustomerServiceDetermines if a password is valid by comparing it to the encoded string, salting is handled internally to thePasswordEncoder.This method must always be called to verify if a password is valid after the original encoded password is generated due to
PasswordEncoderrandomly generating salts internally and appending them to the resulting hash.- Specified by:
isPasswordValidin interfaceCustomerService- Parameters:
rawPassword- the unencoded passwordencodedPassword- the encoded password to compare against- Returns:
- true if the unencoded password matches the encoded password, false otherwise
-
customerPassesCustomerRule
Description copied from interface:CustomerServiceDetermines if the given customer passes the MVEL customer rule- Specified by:
customerPassesCustomerRulein interfaceCustomerServicecustomerRuleHolder- an MVEL rule targeting Customers- Returns:
- true if the customer passes the rule, false otherwise
-
buildCustomerRuleParams
-
getPasswordResetHandlers
- Specified by:
getPasswordResetHandlersin interfaceCustomerService
-
setPasswordResetHandlers
- Specified by:
setPasswordResetHandlersin interfaceCustomerService
-
getPasswordChangedHandlers
- Specified by:
getPasswordChangedHandlersin interfaceCustomerService
-
setPasswordChangedHandlers
- Specified by:
setPasswordChangedHandlersin interfaceCustomerService
-
sendForgotUsernameNotification
@Transactional("blTransactionManager") public GenericResponse sendForgotUsernameNotification(String emailAddress) Description copied from interface:CustomerServiceLooks up the correspondingCustomerand emails the address on file with the associated username.- Specified by:
sendForgotUsernameNotificationin interfaceCustomerService- Parameters:
emailAddress- user's email address- Returns:
- Response can contain errors including (notFound)
-
sendForgotPasswordNotification
@Transactional("blTransactionManager") public GenericResponse sendForgotPasswordNotification(String username, String resetPasswordUrl) Description copied from interface:CustomerServiceGenerates an access token and then emails the user.- Specified by:
sendForgotPasswordNotificationin interfaceCustomerService- Parameters:
username- - the user to send a reset password email to.resetPasswordUrl- - Base url to include in the email.- Returns:
- Response can contain errors including (invalidEmail, invalidUsername, inactiveUser)
-
sendForcedPasswordChangeNotification
@Transactional("blTransactionManager") public GenericResponse sendForcedPasswordChangeNotification(String username, String resetPasswordUrl) Description copied from interface:CustomerServiceGenerates an access token and then emails the user.- Specified by:
sendForcedPasswordChangeNotificationin interfaceCustomerService- Parameters:
username- - the user to send a reset password email to.resetPasswordUrl- - Base url to include in the email.- Returns:
- Response can contain errors including (invalidEmail, invalidUsername, inactiveUser)
-
checkPasswordResetToken
Description copied from interface:CustomerServiceVerifies that a customer has a valid token.- Specified by:
checkPasswordResetTokenin interfaceCustomerService- Parameters:
token- password reset tokencustomer-Customerwho owns the token- Returns:
- Response can contain errors including (invalidToken, tokenUsed, and tokenExpired)
-
checkPasswordResetToken
protected CustomerForgotPasswordSecurityToken checkPasswordResetToken(String token, Customer customer, GenericResponse response) -
resetPasswordUsingToken
@Transactional("blTransactionManager") public GenericResponse resetPasswordUsingToken(String username, String token, String password, String confirmPassword) Description copied from interface:CustomerServiceUpdates the password for the passed in customer only if the passed in token is valid for that customer.- Specified by:
resetPasswordUsingTokenin interfaceCustomerService- Parameters:
username- Username of the customertoken- Valid reset tokenpassword- new password- Returns:
- Response can contain errors including (invalidUsername, inactiveUser, invalidToken, invalidPassword, tokenExpired)
-
invalidateAllTokensForCustomer
-
checkCustomer
-
checkPassword
-
isTokenExpired
-
getTokenExpiredMinutes
public int getTokenExpiredMinutes() -
setTokenExpiredMinutes
public void setTokenExpiredMinutes(int tokenExpiredMinutes) -
getPasswordTokenLength
public int getPasswordTokenLength() -
setPasswordTokenLength
public void setPasswordTokenLength(int passwordTokenLength) -
readBatchCustomers
- Specified by:
readBatchCustomersin interfaceCustomerService
-
readNumberOfCustomers
- Specified by:
readNumberOfCustomersin interfaceCustomerService
-