Interface CustomerService
- All Known Implementing Classes:
CustomerServiceImpl
public interface CustomerService
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddPostRegisterListener(PostRegistrationObserver postRegisterListeners) changePassword(PasswordChange passwordChange) checkPasswordResetToken(String token, Customer customer) Verifies that a customer has a valid token.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.booleanisPasswordValid(String rawPassword, String encodedPassword) Determines if a password is valid by comparing it to the encoded string, salting is handled internally to thePasswordEncoder.readBatchCustomers(int start, int pageSize) readCustomerByEmail(String emailAddress) readCustomerByExternalId(String userExternalId) readCustomerById(Long userId) readCustomerByUsername(String customerName) 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 forgotPasswordUrl) Generates an access token and then emails the user.sendForgotPasswordNotification(String userName, String forgotPasswordUrl) 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.voidsetPasswordChangedHandlers(List<PasswordUpdatedHandler> passwordChangedHandlers) voidsetPasswordResetHandlers(List<PasswordUpdatedHandler> passwordResetHandlers)
-
Method Details
-
saveCustomer
-
saveCustomer
-
registerCustomer
-
readCustomerByUsername
-
readCustomerByUsername
-
readCustomerByEmail
-
changePassword
-
readCustomerById
-
readCustomerByExternalId
-
createCustomer
Customer createCustomer() -
createCustomerWithNullId
Customer createCustomerWithNullId()Returns 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. -
deleteCustomer
Delete the customer entity from the persistent store- Parameters:
customer- the customer entity to remove
-
detachCustomer
Detaches the given Customer instance from the entity manager.- Parameters:
customer-
-
createCustomerFromId
Returns aCustomerby first looking in the database, otherwise creating a new non-persistedCustomer- Parameters:
customerId- the id of the customer to lookup
-
createNewCustomer
Deprecated.usecreateCustomer()orcreateCustomerWithNullId()} instead.Returns a non-persistedCustomer. -
createRegisteredCustomerRoles
Subclassed implementations can assign unique roles for various customer types- Parameters:
customer-Customerto create roles for
-
addPostRegisterListener
-
removePostRegisterListener
-
resetPassword
-
getPasswordResetHandlers
List<PasswordUpdatedHandler> getPasswordResetHandlers() -
setPasswordResetHandlers
-
getPasswordChangedHandlers
List<PasswordUpdatedHandler> getPasswordChangedHandlers() -
setPasswordChangedHandlers
-
sendForgotUsernameNotification
Looks up the correspondingCustomerand emails the address on file with the associated username.- Parameters:
emailAddress- user's email address- Returns:
- Response can contain errors including (notFound)
-
sendForgotPasswordNotification
Generates an access token and then emails the user.- Parameters:
userName- - the user to send a reset password email to.forgotPasswordUrl- - Base url to include in the email.- Returns:
- Response can contain errors including (invalidEmail, invalidUsername, inactiveUser)
-
sendForcedPasswordChangeNotification
Generates an access token and then emails the user.- Parameters:
userName- - the user to send a reset password email to.forgotPasswordUrl- - Base url to include in the email.- Returns:
- Response can contain errors including (invalidEmail, invalidUsername, inactiveUser)
-
resetPasswordUsingToken
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.- Parameters:
username- Username of the customertoken- Valid reset tokenpassword- new password- Returns:
- Response can contain errors including (invalidUsername, inactiveUser, invalidToken, invalidPassword, tokenExpired)
-
checkPasswordResetToken
Verifies that a customer has a valid token.- Parameters:
token- password reset tokencustomer-Customerwho owns the token- Returns:
- Response can contain errors including (invalidToken, tokenUsed, and tokenExpired)
-
findNextCustomerId
Long findNextCustomerId()Allow customers to call from subclassed service.- Returns:
- the next customerId to be used
-
encodePassword
Encodes 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 byisPasswordValid(String, String)as encoding the same password twice will result in different encoded passwords.- Parameters:
rawPassword- the unencoded password- Returns:
- the encoded password
-
isPasswordValid
Determines 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.- Parameters:
rawPassword- the unencoded passwordencodedPassword- the encoded password to compare against- Returns:
- true if the unencoded password matches the encoded password, false otherwise
-
customerPassesCustomerRule
Determines if the given customer passes the MVEL customer rule- Parameters:
customer-customerRuleHolder- an MVEL rule targeting Customers- Returns:
- true if the customer passes the rule, false otherwise
-
readBatchCustomers
-
readNumberOfCustomers
Long readNumberOfCustomers()
-
createCustomer()orcreateCustomerWithNullId()} instead.