code: public boolean authenticateAndAuthorize(String resource, String credentials, AuthHandler.Permissions level) throws AuthenticationException {
          Preconditions.checkNotNull(credentials, "credentials");
          boolean retVal = false;
          try {
              String[] parts = extractMethodAndToken(credentials);
              String method = parts[0];
              String token = parts[1];
              AuthHandler handler = getHandler(method);
              Preconditions.checkNotNull( handler, "Can not find handler.");
              Principal principal;
              if ((principal = handler.authenticate(token)) == null) {
                  throw new AuthenticationException("Authentication failure");
              }
              retVal = handler.authorize(resource, principal).ordinal() >= level.ordinal();
          } catch (AuthException e) {
              throw new AuthenticationException("Authentication failure");
          }
          return retVal;
      }
docs: API to authenticate and authorize access to a given resource.
  @param resource The resource identifier for which the access needs to be controlled.
  @param credentials  Credentials used for authentication.
  @param level    Expected level of access.
  @return         Returns true if the entity represented by the custom auth headers had given level of access to the resource.
  Returns false if the entity does not have access.
  @throws AuthenticationException if an authentication failure occurred.