@Deprecated @Override public Object getSalt(Customer customer, String unencodedPassword) { Object salt = null; if (saltSource != null && customer != null) { salt = saltSource.getSalt(new CustomerUserDetails(customer.getId(), customer.getUsername(), unencodedPassword, new ArrayList<GrantedAuthority>())); } return salt; }
@Override public Authentication loginCustomer(Customer customer) { return loginCustomer(customer.getUsername(), customer.getUnencodedPassword()); }
@Override @Transactional(TransactionUtils.DEFAULT_TRANSACTION_MANAGER) public GenericResponse sendForgotUsernameNotification(String emailAddress) { GenericResponse response = new GenericResponse(); List<Customer> customers = null; if (emailAddress != null) { customers = customerDao.readCustomersByEmail(emailAddress); } if (CollectionUtils.isEmpty(customers)) { response.addErrorCode("notFound"); } else { List<String> activeUsernames = new ArrayList<String>(); for (Customer customer : customers) { if (!customer.isDeactivated()) { activeUsernames.add(customer.getUsername()); } } if (activeUsernames.size() > 0) { HashMap<String, Object> vars = new HashMap<String, Object>(); vars.put("userNames", activeUsernames); sendEmail(emailAddress, getForgotUsernameEmailInfo(), vars); } else { // send inactive username found email. response.addErrorCode("inactiveUser"); } } return response; }
String userName = authentication.getName(); customer = (Customer) BroadleafRequestCustomerResolverImpl.getRequestCustomerResolver().getCustomer(request); if (userName != null && (customer == null || !userName.equals(customer.getUsername()))) {
@Test(groups = "createCustomers", dependsOnGroups="createCustomerIdGeneration", dataProvider = "setupCustomers", dataProviderClass = CustomerDataProvider.class) @Rollback(false) public void createCustomer(Customer customerInfo) { Customer customer = customerService.createCustomerFromId(null); customer.setPassword(customerInfo.getPassword()); customer.setUsername(customerInfo.getUsername()); Long customerId = customer.getId(); assert customerId != null; customer = customerService.saveCustomer(customer); assert customer.getId() == customerId; userIds.add(customer.getId()); userNames.add(customer.getUsername()); }
UserDetails principal = userDetailsService.loadUserByUsername(customer.getUsername()); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(principal, principal.getPassword(), auth.getAuthorities());
public String processChangePassword(HttpServletRequest request, Model model, ChangePasswordForm form, BindingResult result, RedirectAttributes redirectAttributes) throws ServiceException { PasswordChange passwordChange = new PasswordChange(CustomerState.getCustomer().getUsername()); passwordChange.setCurrentPassword(form.getCurrentPassword()); passwordChange.setNewPassword(form.getNewPassword()); passwordChange.setNewPasswordConfirm(form.getNewPasswordConfirm()); changePasswordValidator.validate(passwordChange, result); if (result.hasErrors()) { return getChangePasswordView(); } customerService.changePassword(passwordChange); return getChangePasswordRedirect(); }
@Test(groups = "createCustomerFromController", dataProvider = "setupCustomerControllerData", dataProviderClass = RegisterCustomerDataProvider.class, enabled=false) @Transactional @Rollback(false) public void createCustomerFromController(RegisterCustomerForm registerCustomer) { BindingResult errors = new BeanPropertyBindingResult(registerCustomer, "registerCustomer"); MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); registerCustomerController.registerCustomer(registerCustomer, errors, request, response); assert(errors.getErrorCount() == 0); Customer customerFromDb = customerService.readCustomerByUsername(registerCustomer.getCustomer().getUsername()); assert(customerFromDb != null); }
assert(newCustomer != null); ProviderSignInUtils.handlePostSignUp(newCustomer.getUsername(), new ServletWebRequest(request));
public void validate(Object obj, Errors errors, boolean useEmailForUsername) { RegisterCustomerForm form = (RegisterCustomerForm) obj; Customer customerFromDb = customerService.readCustomerByUsername(form.getCustomer().getUsername()); if (customerFromDb != null && customerFromDb.isRegistered()) { if (useEmailForUsername) { errors.rejectValue("customer.emailAddress", "emailAddress.used", null, null); } else { errors.rejectValue("customer.username", "username.used", null, null); } } ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "password.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "passwordConfirm", "passwordConfirm.required"); errors.pushNestedPath("customer"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "firstName.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "lastName.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "emailAddress", "emailAddress.required"); errors.popNestedPath(); if (!errors.hasErrors()) { if (!form.getPassword().matches(getValidatePasswordExpression())) { errors.rejectValue("password", "password.invalid", null, null); } if (!form.getPassword().equals(form.getPasswordConfirm())) { errors.rejectValue("password", "passwordConfirm.invalid", null, null); } if (!GenericValidator.isEmail(form.getCustomer().getEmailAddress())) { errors.rejectValue("customer.emailAddress", "emailAddress.invalid", null, null); } } }
@Override public Order createNewCartForCustomer(Customer customer) { Order order = create(); if (customer.getUsername() == null) { customer.setUsername(String.valueOf(customer.getId())); if (customerDao.readCustomerById(customer.getId()) != null) {
Customer c=null; if(rs.next()){ c = new Customer(rs.getString("username"), rs.getString("name"), rs.getString("email"), rs.getString("address"), rs.getString("creditCardDetails"), rs.getString("password")); } if(null != c && c.getUsername().contains(user)) return c; else return null;
@Override public Authentication loginCustomer(Customer customer) { return loginCustomer(customer.getUsername(), customer.getUnencodedPassword()); }
String userName = authentication.getName(); customer = (Customer) BroadleafRequestCustomerResolverImpl.getRequestCustomerResolver().getCustomer(request); if (userName != null && (customer == null || !userName.equals(customer.getUsername()))) {
@Override public Entity add(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException { Entity entity = persistencePackage.getEntity(); try { PersistencePerspective persistencePerspective = persistencePackage.getPersistencePerspective(); Customer adminInstance = (Customer) Class.forName(entity.getType()[0]).newInstance(); adminInstance.setId(customerService.findNextCustomerId()); Map<String, FieldMetadata> adminProperties = helper.getSimpleMergedProperties(Customer.class.getName(), persistencePerspective); adminInstance = (Customer) helper.createPopulatedInstance(adminInstance, entity, adminProperties, false); if (customerService.readCustomerByUsername(adminInstance.getUsername()) != null) { Entity error = new Entity(); error.addValidationError("username", "nonUniqueUsernameError"); return error; } adminInstance = (Customer) dynamicEntityDao.merge(adminInstance); Entity adminEntity = helper.getRecord(adminProperties, adminInstance, null, null); return adminEntity; } catch (Exception e) { LOG.error("Unable to execute persistence activity", e); throw new ServiceException("Unable to add entity for " + entity.getType()[0], e); } }
@Override public CustomerDto createDto(final Customer customer, final boolean embed, final boolean link) { final CustomerDto customerDto = CustomerDto.builder() .firstName(customer.getFirstName()) .lastName(customer.getLastName()) .username(customer.getUsername()) .email(customer.getEmailAddress()) .locale(Optional.ofNullable(customer.getCustomerLocale()).map(Locale::getLocaleCode).orElse(null)) .addresses( customer.getCustomerAddresses().stream() .collect(toMap( CustomerAddress::getAddressName, customerAddress -> addressConverter.createDto(customerAddress.getAddress(), embed, link) )) ) .build(); customerDto.add(ControllerLinkBuilder.linkTo(methodOn(CustomerController.class).readOneCustomer(null, customer.getId().toString(), null, null)).withSelfRel()); if (link) { customerDto.add(linkTo(methodOn(CustomerController.class).createAuthorizationCode(null, customer.getId().toString())).withRel("authorization")); } return customerDto; }
public UserDetails createCustomerUserDetails(Customer customer) { List<GrantedAuthority> grantedAuthorities = createGrantedAuthorities(roleService.findCustomerRolesByCustomerId(customer.getId())); CustomerUserDetails userDetails = new CustomerUserDetails(customer.getId(), customer.getUsername(), customer.getPassword(), !customer.isDeactivated(), true, !customer.isPasswordChangeRequired(), true, grantedAuthorities); userDetails.eraseCredentials(); return userDetails; }
public void validate(Object obj, Errors errors, boolean useEmailForUsername) { RegisterCustomerForm form = (RegisterCustomerForm) obj; Customer customerFromDb = customerService.readCustomerByUsername(form.getCustomer().getUsername()); if (customerFromDb != null) { if (useEmailForUsername) { errors.rejectValue("customer.emailAddress", "emailAddress.used", null, null); } else { errors.rejectValue("customer.username", "username.used", null, null); } } ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "password.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "passwordConfirm", "passwordConfirm.required"); errors.pushNestedPath("customer"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "firstName.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "lastName.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "emailAddress", "emailAddress.required"); errors.popNestedPath(); if (!errors.hasErrors()) { if (!form.getPassword().matches(getValidatePasswordExpression())) { errors.rejectValue("password", "password.invalid", null, null); } if (!form.getPassword().equals(form.getPasswordConfirm())) { errors.rejectValue("password", "passwordConfirm.invalid", null, null); } if (!GenericValidator.isEmail(form.getCustomer().getEmailAddress())) { errors.rejectValue("customer.emailAddress", "emailAddress.invalid", null, null); } } }