Exemplo n.º 1
0
        public static string GeneratePresentationRequest(this PresentationRequestConfiguration configuration)
        {
            PresentationRequest_v_1_0 presentationRequest_1_0 = new PresentationRequest_v_1_0()
            {
                Version = configuration.Version,
                Name    = configuration.Name
            };

            configuration.RequestedAttributes.ForEach(delegate(RequestedAttribute reqAttribute)
            {
                presentationRequest_1_0.RequestedAttributes.Add(Guid.NewGuid().ToString(), reqAttribute);
            });

            configuration.RequestedPredicates.ForEach(delegate(RequestedPredicate reqPredicate)
            {
                presentationRequest_1_0.RequestedPredicates.Add(Guid.NewGuid().ToString(), reqPredicate);
            });

            Dictionary <string, PresentationRequest_v_1_0> requestBody = new Dictionary <string, PresentationRequest_v_1_0>()
            {
                { "proof_request", presentationRequest_1_0 }
            };

            return(JsonConvert.SerializeObject(requestBody));
        }
        public static string GeneratePresentationRequest(this PresentationRequestConfiguration configuration)
        {
            PresentationRequest_v_1_0 presentationRequest_1_0 = new PresentationRequest_v_1_0()
            {
                Version = configuration.Version,
                Name    = configuration.Name
                          // NonRevoked = new RevocationInterval()
                          // {
                          //     From = 0,
                          //     To = new DateTimeOffset(DateTime.Now, TimeSpan.Zero).ToUnixTimeSeconds()
                          // }
            };

            configuration.RequestedAttributes.ForEach(delegate(RequestedAttribute reqAttribute)
            {
                string referent    = !String.IsNullOrEmpty(reqAttribute.Label) ? reqAttribute.Label : Guid.NewGuid().ToString();
                reqAttribute.Label = null; // purge unsupported value from object that will be sent to aca-py
                if (!presentationRequest_1_0.RequestedAttributes.ContainsKey(referent))
                {
                    presentationRequest_1_0.RequestedAttributes.Add(referent, reqAttribute);
                }
                else
                {
                    presentationRequest_1_0.RequestedAttributes.Add(disambiguateReferent(referent), reqAttribute);
                }
            });

            configuration.RequestedPredicates.ForEach(delegate(RequestedPredicate reqPredicate)
            {
                string referent    = !String.IsNullOrEmpty(reqPredicate.Label) ? reqPredicate.Label : Guid.NewGuid().ToString();
                reqPredicate.Label = null; // purge unsupported value from object that will be sent to aca-py
                if (!presentationRequest_1_0.RequestedPredicates.ContainsKey(referent))
                {
                    presentationRequest_1_0.RequestedPredicates.Add(referent, reqPredicate);
                }
                else
                {
                    presentationRequest_1_0.RequestedPredicates.Add(disambiguateReferent(referent), reqPredicate);
                }
            });

            Dictionary <string, PresentationRequest_v_1_0> requestBody = new Dictionary <string, PresentationRequest_v_1_0>()
            {
                { "proof_request", presentationRequest_1_0 }
            };

            return(JsonConvert.SerializeObject(requestBody, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
Exemplo n.º 3
0
        public static string GeneratePresentationRequest(this PresentationRequestConfiguration configuration)
        {
            PresentationRequest_v_1_0 presentationRequest_1_0 = new PresentationRequest_v_1_0()
            {
                Version = configuration.Version,
                Name    = configuration.Name
            };

            configuration.RequestedAttributes.ForEach(delegate(RequestedAttribute reqAttribute)
            {
                string referent    = !String.IsNullOrEmpty(reqAttribute.Label) ? reqAttribute.Label : Guid.NewGuid().ToString();
                reqAttribute.Label = null; // purge unsupported value from object that will be sent to aca-py
                if (!presentationRequest_1_0.RequestedAttributes.ContainsKey(referent))
                {
                    presentationRequest_1_0.RequestedAttributes.Add(referent, reqAttribute);
                }
                else
                {
                    presentationRequest_1_0.RequestedAttributes.Add(disambiguateReferent(referent), reqAttribute);
                }
            });

            configuration.RequestedPredicates.ForEach(delegate(RequestedPredicate reqPredicate)
            {
                string referent    = !String.IsNullOrEmpty(reqPredicate.Label) ? reqPredicate.Label : Guid.NewGuid().ToString();
                reqPredicate.Label = null; // purge unsupported value from object that will be sent to aca-py
                if (!presentationRequest_1_0.RequestedPredicates.ContainsKey(referent))
                {
                    presentationRequest_1_0.RequestedPredicates.Add(referent, reqPredicate);
                }
                else
                {
                    presentationRequest_1_0.RequestedPredicates.Add(disambiguateReferent(referent), reqPredicate);
                }
            });

            Dictionary <string, PresentationRequest_v_1_0> requestBody = new Dictionary <string, PresentationRequest_v_1_0>()
            {
                { "proof_request", presentationRequest_1_0 }
            };

            return(JsonConvert.SerializeObject(requestBody));
        }