public HttpResponseMessage Index(
            [System.Web.Mvc.ModelBinder(typeof(Grit.Utility.Web.Json.JsonNetModelBinder))] Envelope envelope)
        {
            var client = ClientService.GetClient(envelope.Id);

            if (client == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Client not found"));
            }

            var decrypted = EnvelopeService.PublicDecrypt(envelope, client.PublicKey);
            var req       = JsonConvert.DeserializeObject <SettingsRequest>(decrypted);

            if (req.Client != envelope.Id)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid client"));
            }

            var tree = TreeService.GetTree(Constants.TREE_NODE);
            SettingsResponse settings = NodeService.GetClientSettings(client, tree)
                                        .Filter(req.Pattern);

            string json = JsonConvert.SerializeObject(settings);

            Envelope resp = EnvelopeService.Encrypt(client.Name, json, client.PublicKey);

            return(Request.CreateResponse(HttpStatusCode.OK, resp));
        }