code: private Function<HttpRequestContext, String> createQuerySubstitution(final String param) {
          return new Function<HttpRequestContext, String>() {
              @Override
              public String apply(HttpRequestContext request) {
                  MultivaluedMap<String, String> params = request.getQueryParameters();
                  if (!params.containsKey(param)) {
                      throw new IllegalStateException("Parameter required for authentication is missing: " + param);
                  }
                  List<String> values = params.get(param);
                  if (values.size() != 1) {
                      throw new IllegalStateException("Exactly one parameter expected for authentication: " + param);
                  }
                  return values.get(0);
              }
          };
      }
docs: Creates a substitution function for query param values, such as
  <code>@RequiresPermission("resource|update|{?id}")</code>