Esempio n. 1
0
        public static Signature CreateSignature(int version, string edgeIP, string clientIP, DateTimeOffset time, string uniqueId,
                                                string nonce, string nonceValue, string path)
        {
            var data = new G2OData(version, edgeIP, clientIP, time, uniqueId, nonce);

            var sign = G2OAlgorithms.ComputeSignatureValue(data.Version, nonceValue, data.Value, path);

            return(new Signature(data: data.Value, value: sign));
        }
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var signature = G2OData.CreateSignature(
                version: this.Version,
                edgeIP: this.EdgeIP,
                clientIP: this.ClientIP,
                time: DateTimeOffset.UtcNow,
                uniqueId: Guid.NewGuid().ToString(),
                nonce: this.Nonce,
                nonceValue: this.NonceValue,
                path: request.RequestUri.LocalPath);

            request.SetG2OSignatureHeaders(signature);

            return(await base.SendAsync(request, cancellationToken));
        }
Esempio n. 3
0
            public bool Validate(string path, Func <string, string> keyResolver)
            {
                var nonceValue = keyResolver(this.Fields.Nonce);

                var recreatedSignature = G2OData.CreateSignature(
                    version: this.Fields.Version,
                    edgeIP: this.Fields.EdgeIP,
                    clientIP: this.Fields.ClientIP,
                    time: this.Fields.Time,
                    uniqueId: this.Fields.UniqueID,
                    nonce: this.Fields.Nonce,
                    nonceValue: nonceValue,
                    path: path);

                return(this.Value.Equals(recreatedSignature.Value));
            }