@Override
  public String refreshJWT() throws JWTCreationException {

    User user = Util.getCurrentUser();
    String jwt = null;

    if (user != null) {

      Map<String, List<String>> claims = new HashMap<String, List<String>>();
      List<String> claimStrings = new ArrayList<String>();

      Set<GrantedPermission> permissions = user.getPermissions();

      for (GrantedPermission claim : permissions) {
        claimStrings.add(claim.getAuthority());
      }
      claims.put("Authorities", claimStrings);

      List<String> identity = new ArrayList<String>();

      identity.add(user.getId().toString());
      identity.add(user.getName());
      identity.add(user.getFirstName());
      identity.add(user.getLastName());

      claims.put("Identity", identity);

      jwt = jwtAuthor.createJWT(user.getSubjectName(), claims);
    } else {
      throw new JWTCreationException("Cannot generate token for Anonymous user.");
    }
    return jwt;
  }
  public String getJWT(UserDTO user) throws JWTCreationException {

    String jwt = null;
    Map<String, List<String>> claims = new HashMap<String, List<String>>();
    List<String> claimStrings = new ArrayList<String>();

    Set<UserPermissionDTO> permissions = getUserPermissions(user);

    for (UserPermissionDTO claim : permissions) {
      claimStrings.add(claim.getAuthority());
    }
    claims.put("Authorities", claimStrings);

    List<String> identity = new ArrayList<String>();

    identity.add(user.getId().toString());
    identity.add(user.getName());
    identity.add(user.getFirstName());
    identity.add(user.getLastName());

    claims.put("Identity", identity);

    jwt = jwtAuthor.createJWT(user.getSubjectName(), claims);
    return jwt;
  }