Beispiel #1
0
        private async Task GetCertificates()
        {
            try
            {
                using (this.Dialogs.Loading("Progress (No Cancel)"))
                {
                    Certificates.Clear();

                    var buildingUsers = await _buildingService.GetBuildingUsers(BuildingId, false);

                    var cnUsers = buildingUsers.Where(x => x.UserPrivileges.Contains("CN")).ToList();

                    var certsResult = await _certificatesService.GetAllDownloadedCertificates(BuildingId);

                    if (!certsResult.Success)
                    {
                        Dialogs.Toast(certsResult.Message);
                        return;
                    }

                    var certificates = certsResult.ResultObject as List <Certificate>;

                    if (certificates != null && certificates.Any())
                    {
                        certificates = new List <Certificate>(certificates.OrderBy(x => x.CertNumber));

                        foreach (var cert in certificates)
                        {
                            cert.Contractor = cnUsers?.FirstOrDefault(x => x.UserId == cert.ConUserId)?.UserFullname;
                        }

                        Certificates.AddRange(certificates);
                    }
                }
            }
            catch (ServiceAuthenticationException e)
            {
                var result = await TryToLogin();

                if (!result)
                {
                    await NavigationService.NavigateToAsync <LoginViewModel>();
                }
                else
                {
                    await GetCertificates();
                }
            }
            catch (Exception e)
            {
                await ShowErrorAlert(e.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        ///     Initializes a new instance of <strong>SignedCmsBuilder</strong> from existing Signed CMS. Data from existing CMS
        ///     is copied to builder and can be modified.
        /// </summary>
        /// <param name="cms">Existing Signed CMS message.</param>
        /// <exception cref="ArgumentNullException">
        ///     <srong>cms</srong> parameter is null.
        /// </exception>
        public SignedCmsBuilder(DefaultSignedPkcs7 cms)
        {
            if (cms == null)
            {
                throw new ArgumentNullException(nameof(cms));
            }

            _contentType = cms.ContentType;
            _content     = cms.Content;
            DigestAlgorithms.AddRange(cms.DigestAlgorithms);
            Certificates.AddRange(cms.Certificates);
            RevocationLists.AddRange(cms.RevocationLists);
            SignerInfos.AddRange(cms.SignerInfos);
        }
Beispiel #3
0
 // we use this method to add signing certificates to Certificates collection.
 void addCerts(IEnumerable <X509Certificate2> signingCerts)
 {
     if (Certificates.Count == 0)
     {
         Certificates.AddRange(signingCerts.ToArray());
     }
     else
     {
         // we exclude possible certificate duplicates.
         foreach (X509Certificate2 signingCert in signingCerts)
         {
             Int32 index = Certificates.IndexOf(signingCert);
             if (index >= 0)
             {
                 Certificates.RemoveAt(index);
             }
             Certificates.Insert(0, signingCert);
         }
     }
 }