Ejemplo n.º 1
0
  /**
   * returns the currently logged in user.
   *
   * @param request the request
   * @return the currently logged user or null (should not happen)
   */
  public final User getCurrentUser(final HttpServletRequest request) {
    Principal principal = request.getUserPrincipal();
    if (principal != null) {
      String name = principal.getName();
      return userService.findByUsername(name);
    }

    return null;
  }
Ejemplo n.º 2
0
 /**
  * checks if a user with the given {@code username} already exists.
  *
  * @param username the username
  * @return trivial
  */
 public final boolean userExists(final String username) {
   User user = userService.findByUsername(username);
   return user != null;
 }