示例#1
0
        public async Task TestAddAndGetCertificatesAsync()
        {
            Attribute attr = await DeployAttributeAsync();

            Certificate cert = new Certificate()
            {
                Hash            = "I am a certificate hash",
                Location        = "I am a certificate location",
                OwningAttribute = attr
            };

            Certificate newCert = await _attributeFacade.AddCertificateAsync(attr, cert);

            Dictionary <string, Certificate> certs = await _attributeFacade.GetCertificatesAsync(attr);

            Assert.AreEqual(1, certs.Count);
            Assert.AreEqual(newCert.Address, certs.ToArray()[0].Value.Address);
            Assert.AreEqual(newCert.Location, certs.ToArray()[0].Value.Location);
        }
示例#2
0
        private async Task AddCertificatesToTheAccessibleAttributes(Certificate[] certificates)
        {
            List <Certificate> addedCertificate = new List <Certificate>();

            foreach (Attribute attr in _accessibleAttributes)
            {
                foreach (Certificate cert in certificates)
                {
                    if (attr.Address != cert.OwningAttribute.Address)
                    {
                        continue;
                    }

                    cert.OwningAttribute = attr;

                    //overwrite the old certificate
                    if (attr.Certificates.ContainsKey(cert.Owner))
                    {
                        attr.Certificates.Remove(cert.Owner);
                    }

                    attr.AddCertificate(cert);

                    await _attributeFacade.AddCertificateAsync(attr, cert);

                    addedCertificate.Add(cert);
                }
            }
            _session.Close();
            IssuedCertificatesAddedToIDEvent e = new IssuedCertificatesAddedToIDEvent()
            {
                CertificatesAdded = addedCertificate,
            };

            HandshakeComplete.Invoke(this, e);
        }