コード例 #1
0
        /// <summary>
        /// Validation Android
        /// </summary>
        /// <param name="param">subumission parameter</param>
        /// <returns>True when successful.</returns>
        public async Task <bool> ValidationAndroid(DiagnosisSubmissionParameter param)
        {
            try
            {
                var token = new JwtSecurityToken(param.DeviceVerificationPayload);

                // TODO: Token Validate

                // request
                var payload = new AndroidPayload()
                {
                    SignedAttestation = param.DeviceVerificationPayload
                };
                var content = new StringContent(JsonConvert.SerializeObject(payload));
                content.Headers.ContentType.MediaType = "application/json";
                var request = new HttpRequestMessage(HttpMethod.Post, UrlAndroid + AndroidBearerToken);

                // response
                var response = await ClientAndroid.SendAsync(request);

                var responseBody = await response.Content.ReadAsStringAsync();

                var result = JsonConvert.DeserializeObject <AndroidResponse>(responseBody);
                return(result.IsValidSignature);
            }
            catch (Exception) { }
            return(false);
        }
コード例 #2
0
        private async Task <AndroidResponse> VerifyAsync(string signedAttestationStatement)
        {
            var payload = new AndroidPayload()
            {
                SignedAttestation = signedAttestationStatement
            };
            var payloadJson = JsonConvert.SerializeObject(payload);
            var response    = await ClientAndroid.PostAsync($"{UrlAndroid}{AndroidSecret}", new StringContent(payloadJson, Encoding.UTF8, "application/json"));

            return(JsonConvert.DeserializeObject <AndroidResponse>(await response.Content.ReadAsStringAsync()));
        }