Esempio n. 1
0
        public async Task <List <PublicServiceData> > GetDataOfAsync(PublicService ps, EidCard eid)
        {
            var lst = new List <PublicServiceData>();

            ps.ContractNames = await GetContractNames(ps);

            foreach (var contractName in ps.ContractNames)
            {
                lst.Add(await GetPSDOfContract(eid.RNN, contractName));
            }
            return(lst);
        }
Esempio n. 2
0
        public void ReadProperties()
        {
            //prep
            EidCard target = (EidCard)readers.ListCards().Where(c => c is EidCard).FirstOrDefault();

            //exec
            X509Certificate2 auth;
            X509Certificate2 sign;
            X509Certificate2 ca;
            X509Certificate2 root;
            X509Certificate2 rrn;
            Image            pic;

            Model.Address  address;
            Model.Identity identity;
            using (target)
            {
                target.Open();
                auth     = target.AuthCert;
                sign     = target.SignCert;
                ca       = target.CaCert;
                root     = target.RootCert;
                rrn      = target.RrnCert;
                pic      = Image.FromStream(new MemoryStream(target.Picture));
                address  = target.Address;
                identity = target.Identity;
            }

            //verify
            Assert.AreNotEqual(auth.Subject, sign.Subject);
            Assert.AreEqual(sign.Issuer, ca.Subject);
            Assert.AreEqual(auth.Issuer, ca.Subject);
            Assert.AreEqual(ca.Issuer, root.Subject);
            Assert.AreEqual(root.Issuer, root.Subject);
            Assert.AreEqual(rrn.Issuer, root.Subject);

            //loads the eID-Viewer export file (put yours in the root if you want to test with your eID)
            XmlDocument eidExp = new XmlDocument();

            eidExp.Load(identity.CardNr + ".eid");

            Image refPic = Image.FromStream(new MemoryStream(Convert.FromBase64String(eidExp.SelectSingleNode("/eid/identity/photo").InnerText)));

            Assert.AreEqual(refPic.Size, pic.Size);

            Assert.AreEqual(eidExp.SelectSingleNode("/eid/address/streetandnumber").InnerText.TrimEnd(), address.StreetAndNumber);
            Assert.AreEqual(eidExp.SelectSingleNode("/eid/address/zip").InnerText, address.Zip);
            Assert.AreEqual(eidExp.SelectSingleNode("/eid/address/municipality").InnerText, address.Municipality);

            Assert.AreEqual(eidExp.SelectSingleNode("/eid/card/@cardnumber").InnerText, identity.CardNr);
            Assert.AreEqual(eidExp.SelectSingleNode("/eid/card/@chipnumber").InnerText, BitConverter.ToString(identity.ChipNr).Replace("-", ""));
            Assert.AreEqual(DateTime.ParseExact(eidExp.SelectSingleNode("/eid/card/@validitydatebegin").InnerText, "yyyyMMdd", CultureInfo.InvariantCulture), identity.ValidityBeginDate);
            Assert.AreEqual(DateTime.ParseExact(eidExp.SelectSingleNode("/eid/card/@validitydateend").InnerText, "yyyyMMdd", CultureInfo.InvariantCulture), identity.ValidityEndDate);
            Assert.AreEqual(eidExp.SelectSingleNode("/eid/card/deliverymunicipality").InnerText, identity.IssuingMunicipality);
            Assert.AreEqual(eidExp.SelectSingleNode("/eid/identity/@nationalnumber").InnerText, identity.NationalNr);
            Assert.AreEqual(eidExp.SelectSingleNode("/eid/identity/name").InnerText, identity.Surname);
            Assert.AreEqual(eidExp.SelectSingleNode("/eid/identity/firstname").InnerText, identity.FirstNames);
            Assert.AreEqual(eidExp.SelectSingleNode("/eid/identity/middlenames").InnerText, identity.FirstLetterOfThirdGivenName);
            Assert.AreEqual(eidExp.SelectSingleNode("/eid/identity/nationality").InnerText, identity.Nationality);
            Assert.AreEqual(eidExp.SelectSingleNode("/eid/identity/placeofbirth").InnerText, identity.LocationOfBirth);
            Assert.AreEqual(DateTime.ParseExact(eidExp.SelectSingleNode("/eid/identity/@dateofbirth").InnerText, "yyyyMMdd", CultureInfo.InvariantCulture), identity.DateOfBirth);

            //TODO, make a little more resilient
            Assert.IsNotNull(identity.Gender);
            Assert.IsNotNull(identity.Nobility);
            Assert.IsNotNull(identity.DocumentType);
            Assert.IsNotNull(identity.SpecialStatus);
        }