Package ua.com.jpy.entity.customer

Examples of ua.com.jpy.entity.customer.Customer


  private ICustomerService customerService;

  @SuppressWarnings("deprecation")
  @RequestMapping(value = {"*", ""}, method = RequestMethod.GET)
  public String homeController(ModelMap modelMap) {
    Customer customer = null;
    if(modelMap.containsKey("customer") && modelMap.get("customer") instanceof Customer) {
      customer = (Customer) modelMap.get("customer");
    } else {
      customer = customerService.getCurrentCustomer();
    }
    if(customer != null) {
      log.info("Customer found, login: " + customer.getLogin());
      modelMap.addAttribute(customer);
      modelMap.addObject(customer);
    } else {
      log.info("Customer was not found, add new instance customer to the session");
    }
View Full Code Here


 
  @SuppressWarnings("deprecation")
  @RequestMapping(value = { "/", "" }, method = RequestMethod.GET)
  public String login(ModelMap modelMap, @RequestParam(value = "loginError", required = false) String loginError) {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    Customer customer = null;
    if(authentication != null) {
      Object principial = authentication.getPrincipal();
      if(principial instanceof Customer) {
        customer = (Customer) authentication.getPrincipal();
        modelMap.addAttribute(customer);
View Full Code Here

      JSONObject json = new JSONObject();
      json.put("result", "success");
      return json;
    } else {
      log.info("Create new customer");
      customer = new Customer();
      customer.setId(new ObjectId());
      customer.setLogin(name);
      customer.setPassword(password);
 
      Role role = new Role();
View Full Code Here

  @Autowired
  private ICustomerDao customerDao;

  @Override
  public UserDetails loadUserByUsername(String username) {
    Customer customer = customerDao.find(username);
    if(customer == null) {
      return null;
    }
    List<Role> roles = customer.getRoles();
    Role role = roles.get(0);
    return new User(customer.getLogin(), customer.getPassword(), customer.isActive(), true, true, true, getAuthorities(role.getRoleInt()));
  }
View Full Code Here

  private ICustomerService customerService;

  @SuppressWarnings("deprecation")
  @RequestMapping(value = "/profile", method = RequestMethod.GET)
  public String profile(ModelMap modelMap) {
    Customer customer = customerService.getCurrentCustomer();
    if(customer != null) {
      modelMap.addAttribute(customer);
      modelMap.addObject(customer);
      log.info("Customer found, login: " + customer.getLogin());
    } else {
      log.info("Customer was not found");
    }
    return "profile";
  }
View Full Code Here

  private PasswordEncoder passwordEncoder;

  @Override
  public IEntity getOrCreate(IEntity entity, ObjectId id) {
    if(entity != null && id == null) {
      Customer customer = (Customer) entity;
      String password = customer.getPassword();
      customer.setPassword(passwordEncoder.encodePassword(password, null));
      entity = customer;
    }
    return customerDao.getOrCreate(entity, id);
  }
View Full Code Here

  public Customer getCurrentCustomer() {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication != null) {
      Object principal = authentication.getPrincipal();
      if (principal instanceof UserDetails) {
        Customer customer = null;
        try {
          User user = (User) principal;
          customer = find(user.getUsername());
          log.info("Customer found in cookie!!!");
        } catch(Exception exc) {
View Full Code Here

TOP

Related Classes of ua.com.jpy.entity.customer.Customer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.