private ResourceSet parseResourceSet(String jsonString) {

    try {
      JsonElement el = parser.parse(jsonString);

      if (el.isJsonObject()) {
        JsonObject o = el.getAsJsonObject();

        ResourceSet rs = new ResourceSet();
        rs.setId(getAsLong(o, "_id"));
        rs.setName(getAsString(o, "name"));
        rs.setIconUri(getAsString(o, "icon_uri"));
        rs.setType(getAsString(o, "type"));
        rs.setScopes(getAsStringSet(o, "scopes"));
        rs.setUri(getAsString(o, "uri"));

        return rs;
      }

      return null;

    } catch (JsonParseException e) {
      return null;
    }
  }
  /**
   * Make sure the resource set doesn't have any restricted or reserved scopes.
   *
   * @param rs
   */
  private ResourceSet validateScopes(ResourceSet rs) {
    // scopes that the client is asking for
    Set<SystemScope> requestedScopes = scopeService.fromStrings(rs.getScopes());

    // the scopes that the resource set can have must be a subset of the dynamically allowed scopes
    Set<SystemScope> allowedScopes =
        scopeService.removeRestrictedAndReservedScopes(requestedScopes);

    rs.setScopes(scopeService.toStrings(allowedScopes));

    return rs;
  }