Exemplo n.º 1
0
        public Task <ETKModel> Get(string type, string value, string applicationId)
        {
            ETKModel result = null;

            if (!_dic.TryGetValue(BuildId(type, value, applicationId), out result))
            {
                return(Task.FromResult(result));
            }

            return(Task.FromResult(result));
        }
Exemplo n.º 2
0
        public async Task <ETKModel> GetETK(ETKIdentifier etkIdentifier)
        {
            var result = await _etkStore.Get(etkIdentifier.Type, etkIdentifier.Value, etkIdentifier.ApplicationId);

            if (result != null)
            {
                return(result);
            }

            var request = new SOAPEnvelope <ETKGetRequestBody>
            {
                Body = new ETKGetRequestBody
                {
                    Request = new ETKGetRequest
                    {
                        SearchCriteria = new ETKSearchCriteria
                        {
                            Identifier = etkIdentifier
                        }
                    }
                }
            };
            var httpResponse = await _soapClient.Send(request, new Uri(_options.EtkUrl), null);

            httpResponse.EnsureSuccessStatusCode();
            var xml = await httpResponse.Content.ReadAsStringAsync();

            var etkResponse = SOAPEnvelope <ETKGetResponseBody> .Deserialize(xml);

            var signedCms = new SignedCms();

            signedCms.Decode(Convert.FromBase64String(etkResponse.Body.GetETKResponse.ETK));
            var cert = new X509Certificate2(signedCms.ContentInfo.Content);
            await _etkStore.Add(etkIdentifier.Type, etkIdentifier.Value, etkIdentifier.ApplicationId, cert, etkResponse.Body.GetETKResponse.ETK);

            result = new ETKModel(cert, etkResponse.Body.GetETKResponse.ETK);
            return(result);
        }