Package com.sivalabs.springapp.entities

Examples of com.sivalabs.springapp.entities.User


  }
 
  @RequestMapping(value="", method=RequestMethod.POST, produces=MediaType.APPLICATION_JSON_VALUE)
  @ResponseBody
  public ResponseEntity<User> createUser(@RequestBody User user) {
    User savedUser = userService.create(user);
    return new ResponseEntity<User>(savedUser, HttpStatus.CREATED);
  }
View Full Code Here


  }
 
  @RequestMapping(value="", method=RequestMethod.PUT, produces=MediaType.APPLICATION_JSON_VALUE)
  @ResponseBody
  public ResponseEntity<User> updateUser(@RequestBody User user) {
    User savedUser = userService.update(user);
    return new ResponseEntity<User>(savedUser, HttpStatus.OK);
  }
View Full Code Here

     
    Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
      if (principal instanceof UserDetails)
      {
        String email = ((UserDetails) principal).getUsername();
        User loginUser = userService.findUserByEmail(email);
        return new SecurityUser(loginUser);
      }
      return null;
     
    }
View Full Code Here

  private UserService userService;
 
  @Override
  public UserDetails loadUserByUsername(String userName)
      throws UsernameNotFoundException {
    User user = userService.findUserByEmail(userName);
    if(user == null){
      throw new UsernameNotFoundException("UserName "+userName+" not found");
    }
    return new SecurityUser(user);
  }
View Full Code Here

    assertTrue(!users.isEmpty());
  }
 
  @Test
  public void findUserById()  {
    User user = userService.findUserById(1);
    assertNotNull(user);
  }
View Full Code Here

    assertNotNull(user);
  }
 
  @Test
  public void createUser() {
    User user = new User(0, "Siva", "siva@gmail.com", "siva", null);
    User savedUser = userService.create(user);
    User newUser = userService.findUserById(savedUser.getId());
    assertEquals("Siva", newUser.getName());
    assertEquals("siva@gmail.com", newUser.getEmail());
  }
View Full Code Here

  {
    Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
      if (principal instanceof UserDetails)
      {
        String email = ((UserDetails) principal).getUsername();
        User loginUser = userService.findUserByEmail(email);
        return new SecurityUser(loginUser);
      }

      return null;
  }
View Full Code Here

TOP

Related Classes of com.sivalabs.springapp.entities.User

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.