org.broadleafcommerce.profile.core.service
Class CustomerServiceImpl

java.lang.Object
  extended by org.broadleafcommerce.profile.core.service.CustomerServiceImpl
All Implemented Interfaces:
CustomerService

@Service(value="blCustomerService")
public class CustomerServiceImpl
extends Object
implements CustomerService


Field Summary
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.authentication.encoding.PasswordEncoder passwordEncoder
           
protected  List<PasswordUpdatedHandler> passwordResetHandlers
           
protected  int passwordTokenLength
           
protected  List<PostRegistrationObserver> postRegisterListeners
           
protected  EmailInfo registrationEmailInfo
           
protected  RoleDao roleDao
           
protected  String salt
          Optional password salt to be used with the passwordEncoder
protected  int tokenExpiredMinutes
           
 
Constructor Summary
CustomerServiceImpl()
           
 
Method Summary
 void addPostRegisterListener(PostRegistrationObserver postRegisterListeners)
           
 Customer changePassword(PasswordChange passwordChange)
           
protected  void checkCustomer(Customer customer, GenericResponse response)
           
protected  void checkPassword(String password, String confirmPassword, GenericResponse response)
           
 GenericResponse checkPasswordResetToken(String token)
          Verifies that the passed in token is valid.
 Customer createCustomer()
           
 Customer createCustomerFromId(Long customerId)
          Returns a Customer by first looking in the database, otherwise creating a new non-persisted Customer
 Customer createNewCustomer()
          Returns a non-persisted Customer.
protected  void createRegisteredCustomerRoles(Customer customer)
          Subclassed implementations can assign unique roles for various customer types
 Long findNextCustomerId()
          Allow customers to call from subclassed service.
 EmailInfo getChangePasswordEmailInfo()
           
 EmailInfo getForgotPasswordEmailInfo()
           
 EmailInfo getForgotUsernameEmailInfo()
           
 List<PasswordUpdatedHandler> getPasswordChangedHandlers()
           
 List<PasswordUpdatedHandler> getPasswordResetHandlers()
           
 int getPasswordTokenLength()
           
 EmailInfo getRegistrationEmailInfo()
           
 String getSalt()
           
 String getSalt(Customer customer)
          Optionally provide a salt based on a customer.
 int getTokenExpiredMinutes()
           
protected  boolean isTokenExpired(CustomerForgotPasswordSecurityToken fpst)
           
protected  void notifyPostRegisterListeners(Customer customer)
           
 Customer readCustomerByEmail(String emailAddress)
           
 Customer readCustomerById(Long id)
           
 Customer readCustomerByUsername(String username)
           
 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)
           
 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 setPasswordEncoder(org.springframework.security.authentication.encoding.PasswordEncoder passwordEncoder)
           
 void setPasswordResetHandlers(List<PasswordUpdatedHandler> passwordResetHandlers)
           
 void setPasswordTokenLength(int passwordTokenLength)
           
 void setRegistrationEmailInfo(EmailInfo registrationEmailInfo)
           
 void setSalt(String salt)
           
 void setTokenExpiredMinutes(int tokenExpiredMinutes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

customerDao

protected CustomerDao customerDao

idGenerationService

protected IdGenerationService idGenerationService

customerForgotPasswordSecurityTokenDao

protected CustomerForgotPasswordSecurityTokenDao customerForgotPasswordSecurityTokenDao

passwordEncoder

protected org.springframework.security.authentication.encoding.PasswordEncoder passwordEncoder

salt

protected String salt
Optional password salt to be used with the passwordEncoder


roleDao

protected RoleDao roleDao

emailService

protected EmailService emailService

forgotPasswordEmailInfo

protected EmailInfo forgotPasswordEmailInfo

forgotUsernameEmailInfo

protected EmailInfo forgotUsernameEmailInfo

registrationEmailInfo

protected EmailInfo registrationEmailInfo

changePasswordEmailInfo

protected EmailInfo changePasswordEmailInfo

tokenExpiredMinutes

protected int tokenExpiredMinutes

passwordTokenLength

protected int passwordTokenLength

postRegisterListeners

protected final List<PostRegistrationObserver> postRegisterListeners

passwordResetHandlers

protected List<PasswordUpdatedHandler> passwordResetHandlers

passwordChangedHandlers

protected List<PasswordUpdatedHandler> passwordChangedHandlers
Constructor Detail

CustomerServiceImpl

public CustomerServiceImpl()
Method Detail

saveCustomer

public Customer saveCustomer(Customer customer)
Specified by:
saveCustomer in interface CustomerService

saveCustomer

public Customer saveCustomer(Customer customer,
                             boolean register)
Specified by:
saveCustomer in interface CustomerService

registerCustomer

public Customer registerCustomer(Customer customer,
                                 String password,
                                 String passwordConfirm)
Specified by:
registerCustomer in interface CustomerService

createRegisteredCustomerRoles

protected void createRegisteredCustomerRoles(Customer customer)
Subclassed implementations can assign unique roles for various customer types

Parameters:
customer -

readCustomerByEmail

public Customer readCustomerByEmail(String emailAddress)
Specified by:
readCustomerByEmail in interface CustomerService

changePassword

public Customer changePassword(PasswordChange passwordChange)
Specified by:
changePassword in interface CustomerService

resetPassword

public Customer resetPassword(PasswordReset passwordReset)
Specified by:
resetPassword in interface CustomerService

addPostRegisterListener

public void addPostRegisterListener(PostRegistrationObserver postRegisterListeners)
Specified by:
addPostRegisterListener in interface CustomerService

removePostRegisterListener

public void removePostRegisterListener(PostRegistrationObserver postRegisterListeners)
Specified by:
removePostRegisterListener in interface CustomerService

notifyPostRegisterListeners

protected void notifyPostRegisterListeners(Customer customer)

createCustomer

public Customer createCustomer()
Specified by:
createCustomer in interface CustomerService

createCustomerFromId

public Customer createCustomerFromId(Long customerId)
Description copied from interface: CustomerService
Returns a Customer by first looking in the database, otherwise creating a new non-persisted Customer

Specified by:
createCustomerFromId in interface CustomerService
Parameters:
customerId - the id of the customer to lookup
Returns:
either a Customer from the database if it exists, or a new non-persisted Customer

findNextCustomerId

public Long findNextCustomerId()
Allow customers to call from subclassed service.

Specified by:
findNextCustomerId in interface CustomerService
Returns:

createNewCustomer

public Customer createNewCustomer()
Description copied from interface: CustomerService
Returns a non-persisted Customer. Typically used with registering a new customer.

Specified by:
createNewCustomer in interface CustomerService

readCustomerByUsername

public Customer readCustomerByUsername(String username)
Specified by:
readCustomerByUsername in interface CustomerService

readCustomerById

public Customer readCustomerById(Long id)
Specified by:
readCustomerById in interface CustomerService

setCustomerDao

public void setCustomerDao(CustomerDao customerDao)

setPasswordEncoder

public void setPasswordEncoder(org.springframework.security.authentication.encoding.PasswordEncoder passwordEncoder)

getSalt

public String getSalt(Customer customer)
Optionally provide a salt based on a customer. By default, this returns the salt property

Parameters:
customer -
Returns:
See Also:
CustomerServiceImpl#getSalt()}

getSalt

public String getSalt()

setSalt

public void setSalt(String salt)

getPasswordResetHandlers

public List<PasswordUpdatedHandler> getPasswordResetHandlers()
Specified by:
getPasswordResetHandlers in interface CustomerService

setPasswordResetHandlers

public void setPasswordResetHandlers(List<PasswordUpdatedHandler> passwordResetHandlers)
Specified by:
setPasswordResetHandlers in interface CustomerService

getPasswordChangedHandlers

public List<PasswordUpdatedHandler> getPasswordChangedHandlers()
Specified by:
getPasswordChangedHandlers in interface CustomerService

setPasswordChangedHandlers

public void setPasswordChangedHandlers(List<PasswordUpdatedHandler> passwordChangedHandlers)
Specified by:
setPasswordChangedHandlers in interface CustomerService

sendForgotUsernameNotification

public GenericResponse sendForgotUsernameNotification(String emailAddress)
Description copied from interface: CustomerService
Looks up the corresponding Customer and emails the address on file with the associated username.

Specified by:
sendForgotUsernameNotification in interface CustomerService
Returns:
Response can contain errors including (notFound)

sendForgotPasswordNotification

public GenericResponse sendForgotPasswordNotification(String username,
                                                      String resetPasswordUrl)
Description copied from interface: CustomerService
Generates an access token and then emails the user.

Specified by:
sendForgotPasswordNotification in interface CustomerService
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

public GenericResponse checkPasswordResetToken(String token)
Description copied from interface: CustomerService
Verifies that the passed in token is valid. Returns responseCodes of "invalidToken", "tokenUsed", and "tokenExpired".

Specified by:
checkPasswordResetToken in interface CustomerService
Returns:

resetPasswordUsingToken

public GenericResponse resetPasswordUsingToken(String username,
                                               String token,
                                               String password,
                                               String confirmPassword)
Description copied from interface: CustomerService
Updates the password for the passed in customer only if the passed in token is valid for that customer.

Specified by:
resetPasswordUsingToken in interface CustomerService
Parameters:
username - Username of the customer
token - Valid reset token
password - new password
Returns:
Response can contain errors including (invalidUsername, inactiveUser, invalidToken, invalidPassword, tokenExpired)

checkCustomer

protected void checkCustomer(Customer customer,
                             GenericResponse response)

checkPassword

protected void checkPassword(String password,
                             String confirmPassword,
                             GenericResponse response)

isTokenExpired

protected boolean isTokenExpired(CustomerForgotPasswordSecurityToken fpst)

getTokenExpiredMinutes

public int getTokenExpiredMinutes()

setTokenExpiredMinutes

public void setTokenExpiredMinutes(int tokenExpiredMinutes)

getPasswordTokenLength

public int getPasswordTokenLength()

setPasswordTokenLength

public void setPasswordTokenLength(int passwordTokenLength)

getForgotPasswordEmailInfo

public EmailInfo getForgotPasswordEmailInfo()

setForgotPasswordEmailInfo

public void setForgotPasswordEmailInfo(EmailInfo forgotPasswordEmailInfo)

getForgotUsernameEmailInfo

public EmailInfo getForgotUsernameEmailInfo()

setForgotUsernameEmailInfo

public void setForgotUsernameEmailInfo(EmailInfo forgotUsernameEmailInfo)

getRegistrationEmailInfo

public EmailInfo getRegistrationEmailInfo()

setRegistrationEmailInfo

public void setRegistrationEmailInfo(EmailInfo registrationEmailInfo)

getChangePasswordEmailInfo

public EmailInfo getChangePasswordEmailInfo()

setChangePasswordEmailInfo

public void setChangePasswordEmailInfo(EmailInfo changePasswordEmailInfo)


Copyright © 2013. All Rights Reserved.