@Override
	public ContainerRequest filter(ContainerRequest containerRequest)
			throws WebApplicationException {

		// GET, POST, PUT, DELETE, ...
		String method = containerRequest.getMethod();

		// /tasks for example
		String path = containerRequest.getPath(true);

		System.out.println(path);

		// We allow login login and registration with POST method
		if ((path.equals("login") || path.equals("login/")
				|| path.equals("register") || path.equals("register/"))
				&& method.equals("POST")) {
			return containerRequest;
		}

		// Otherwise, we check the user token

		// Get the authentification token passed in HTTP headers parameters
		String auth = containerRequest.getHeaderValue("authorization");
		System.out.println(auth);

		// If the user does not have the right (does not provide any HTTP
		// Authentication token)
		if (auth == null) {
			throw new WebApplicationException(Status.UNAUTHORIZED);
		}

		// If login or password fail
		if (UserDatabase.userFromToken(auth) == null) {
			throw new WebApplicationException(Status.UNAUTHORIZED);
		}

		// Allow the request and store the name of the user to be used later
		sr.setAttribute("logged_user", UserDatabase.userFromToken(auth));

		return containerRequest;
	}