コード例 #1
0
        public static Anchor[] GetOutgoingAnchors(this AnchorStoreClient client, string owner, EntityStatus status)
        {
            CertificateGetOptions options = CertificateExtensions.FullCertData.Clone();

            options.Status = status;
            return(client.GetOutgoingAnchors(owner, options));
        }
コード例 #2
0
        public static Certificate[] GetCertificatesForOwner(this CertificateStoreClient client, string owner, EntityStatus status)
        {
            CertificateGetOptions options = FullCertData.Clone();

            options.Status = status;
            return(client.GetCertificatesForOwner(owner, options));
        }
コード例 #3
0
        public void CertificateByIDGet(string[] args)
        {
            long certificateID            = args.GetRequiredValue <int>(0);
            CertificateGetOptions options = new CertificateGetOptions()
            {
                IncludeData       = args.GetOptionalValue(1, false),
                IncludePrivateKey = args.GetOptionalValue(2, false)
            };

            string outputFile = args.GetOptionalValue(3, string.Empty);

            Certificate certificate = Client.GetCertificate(certificateID, options);

            this.Print(certificate);

            if (certificate == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(outputFile) && certificate.HasData)
            {
                File.WriteAllBytes(outputFile, certificate.Data);
            }
        }
コード例 #4
0
ファイル: AnchorCommands.cs プロジェクト: blinds52/nhind
        public void AnchorByIDGet(string[] args)
        {
            long anchorID = args.GetRequiredValue <int>(0);
            CertificateGetOptions options = new CertificateGetOptions()
            {
                IncludeData       = args.GetOptionalValue(1, false),
                IncludePrivateKey = args.GetOptionalValue(2, false)
            };

            string outputFile = args.GetOptionalValue(3, string.Empty);

            Anchor[] anchors = Client.GetAnchors(new[] { anchorID }, options);
            this.Print(anchors);

            if (anchors.Length < 1)
            {
                return;
            }

            Anchor anchor = anchors[0];

            if (!string.IsNullOrEmpty(outputFile) && anchor.HasData)
            {
                File.WriteAllBytes(outputFile, anchor.Data);
            }
        }
コード例 #5
0
ファイル: AnchorCommands.cs プロジェクト: blinds52/nhind
        public void AnchorsGet(string[] args)
        {
            string owner = args.GetRequiredValue(0);
            CertificateGetOptions options = this.CertCommands.GetOptions(args, 1);

            Anchor[] anchors = Client.GetAnchorsForOwner(owner, options);
            this.Print(anchors);
        }
コード例 #6
0
 public static CertificateGetOptions Clone(this CertificateGetOptions options)
 {
     return(new CertificateGetOptions {
         IncludeData = options.IncludeData,
         IncludePrivateKey = options.IncludePrivateKey,
         Status = options.Status
     });
 }
コード例 #7
0
        public void CertificateGet(string[] args)
        {
            string owner = args.GetRequiredValue(0);
            CertificateGetOptions options = GetOptions(args, 1);

            Certificate[] certs = Client.GetCertificatesForOwner(owner, options);
            this.Print(certs);
        }
コード例 #8
0
        void Search(Func <X509Certificate2, bool> filter)
        {
            CertificateGetOptions getOptions = new CertificateGetOptions()
            {
                IncludeData = true, IncludePrivateKey = false
            };

            Search(Client.EnumerateCertificates(25, getOptions), filter);
        }
コード例 #9
0
ファイル: AnchorCommands.cs プロジェクト: blinds52/nhind
        public void AnchorsList(string[] args)
        {
            CertificateGetOptions options = this.CertCommands.GetOptions(args, 0);

            foreach (Anchor anchor in Client.EnumerateAnchors(10, options))
            {
                this.Print(anchor);
                CommandUI.PrintSectionBreak();
            }
        }
コード例 #10
0
 public static Certificate GetCertificate(this CertificateStoreClient client, long certificateID, CertificateGetOptions options)
 {
     Certificate[] certs = client.GetCertificates(new long[] {certificateID}, options);
     if (certs.IsNullOrEmpty())
     {
         return null;
     }
     
     return certs[0];
 }
コード例 #11
0
        public void CertificateExportAll(string[] args)
        {
            string outputFile = args.GetOptionalValue(0, null);
            int    chunkSize  = args.GetOptionalValue(1, 25);

            CertificateGetOptions options = new CertificateGetOptions {
                IncludeData = true, IncludePrivateKey = false
            };
            IEnumerable <Certificate> certs = Client.EnumerateCertificates(chunkSize, options);

            ExportCerts(certs, outputFile);
        }
コード例 #12
0
        public void CertificateResolve(string[] args)
        {
            MailAddress           owner   = new MailAddress(args.GetRequiredValue(0));
            CertificateGetOptions options = GetOptions(args, 1);

            options.Status = EntityStatus.Enabled;  // We only ever resolve Enabled Certs

            Certificate[] certs = Client.GetCertificatesForOwner(owner.Address, options);
            if (certs.IsNullOrEmpty())
            {
                certs = Client.GetCertificatesForOwner(owner.Host, options);
            }
            this.Print(certs);
        }
コード例 #13
0
ファイル: AnchorCommands.cs プロジェクト: blinds52/nhind
        public void AnchorResolve(string[] args)
        {
            MailAddress           owner   = new MailAddress(args.GetRequiredValue(0));
            CertificateGetOptions options = this.CertCommands.GetOptions(args, 1);

            options.Status = EntityStatus.Enabled;  // We only ever resolve Enabled Anchors

            Anchor[] anchors = Client.GetAnchorsForOwner(owner.Address, options);
            if (anchors.IsNullOrEmpty())
            {
                anchors = Client.GetAnchorsForOwner(owner.Host, options);
            }
            this.Print(anchors);
        }
コード例 #14
0
        public IEnumerable<Certificate> Resolve(string owner, bool showData)
        {
            MailAddress address = new MailAddress(owner);
            var options = new CertificateGetOptions { IncludeData = showData };

            Certificate[] certs = Client.GetCertificatesForOwner(address.Address, options);

            if (certs.IsNullOrEmpty())
            {
                certs = Client.GetCertificatesForOwner(address.Host, options);
            }

            return certs;
        }
コード例 #15
0
        internal CertificateGetOptions GetOptions(string[] args, int firstArg)
        {
            CertificateGetOptions options = new CertificateGetOptions
            {
                IncludeData       = args.GetOptionalValue(firstArg, false),
                IncludePrivateKey = args.GetOptionalValue(firstArg + 1, false)
            };

            if (args.GetValueOrNull(firstArg + 2) != null)
            {
                options.Status = args.GetRequiredEnum <EntityStatus>(firstArg + 2);
            }

            return(options);
        }
コード例 #16
0
        public void CertificateListAll(string[] args)
        {
            string outputFile = args.GetOptionalValue(0, null);
            int    chunkSize  = args.GetOptionalValue(1, 25);

            CertificateGetOptions options = new CertificateGetOptions {
                IncludeData = true, IncludePrivateKey = false
            };
            IEnumerable <Certificate> certs = Client.EnumerateCertificates(chunkSize, options);

            foreach (Certificate cert in certs)
            {
                this.Print(cert);
                CommandUI.PrintSectionBreak();
            }
        }
コード例 #17
0
        public IEnumerable <Certificate> Resolve(string owner, bool showData)
        {
            MailAddress address = new MailAddress(owner);
            var         options = new CertificateGetOptions {
                IncludeData = showData
            };

            Certificate[] certs = Client.GetCertificatesForOwner(address.Address, options);

            if (certs.IsNullOrEmpty())
            {
                certs = Client.GetCertificatesForOwner(address.Host, options);
            }

            return(certs);
        }
コード例 #18
0
        public void CertificateExport(string[] args)
        {
            string owner      = args.GetRequiredValue(0);
            string outputFile = args.GetOptionalValue(1, null);

            CertificateGetOptions options = new CertificateGetOptions {
                IncludeData = true, IncludePrivateKey = false
            };

            Certificate[] certs = Client.GetCertificatesForOwner(owner, options);
            if (certs.IsNullOrEmpty())
            {
                WriteLine("No certificates found");
                return;
            }
            ExportCerts(certs, outputFile);
        }
コード例 #19
0
        public static Certificate GetCertificate(this CertificateStoreClient client, long certificateID, CertificateGetOptions options)
        {
            Certificate[] certs = client.GetCertificates(new long[] { certificateID }, options);
            if (certs.IsNullOrEmpty())
            {
                return(null);
            }

            return(certs[0]);
        }
コード例 #20
0
        public static IEnumerable <Anchor> EnumerateAnchors(this AnchorStoreClient client, int chunkSize, CertificateGetOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (chunkSize < 1)
            {
                throw new ArgumentException("value was less than 1", "chunkSize");
            }

            long lastID = -1;

            Anchor[] anchors;
            while (true)
            {
                anchors = client.EnumerateAnchors(lastID, chunkSize, options);
                if (anchors == null || anchors.Length == 0)
                {
                    yield break;
                }
                for (int i = 0; i < anchors.Length; ++i)
                {
                    yield return(anchors[i]);
                }
                lastID = anchors[anchors.Length - 1].ID;
            }
        }
コード例 #21
0
        public static IEnumerable<Certificate> EnumerateCertificates(this CertificateStoreClient client, int chunkSize, CertificateGetOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (chunkSize < 1)
            {
                throw new ArgumentException("value was less than 1", "chunkSize");
            }

            long lastID = -1;

            Certificate[] certs;
            while (true)
            {
                certs = client.EnumerateCertificates(lastID, chunkSize, options);
                if (certs.IsNullOrEmpty())
                {
                    yield break;
                }
                
                for (int i = 0; i < certs.Length; ++i)
                {
                    yield return certs[i];
                }
                lastID = certs[certs.Length - 1].ID;
            }
        }
コード例 #22
0
ファイル: AnchorExtensions.cs プロジェクト: DM-TOR/nhin-d
        public static IEnumerable<Anchor> EnumerateAnchors(this AnchorStoreClient client, int chunkSize, CertificateGetOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (chunkSize < 1)
            {
                throw new ArgumentException("value was less than 1", "chunkSize");
            }

            long lastID = -1;

            Anchor[] anchors;
            while (true)
            {
                anchors = client.EnumerateAnchors(lastID, chunkSize, options);
                if (anchors == null || anchors.Length == 0)
                {
                    yield break;
                }
                for (int i = 0; i < anchors.Length; ++i)
                {
                    yield return anchors[i];
                }
                lastID = anchors[anchors.Length - 1].ID;
            }
        }
コード例 #23
0
 public virtual async Task <Response <Certificate> > GetAsync(string thumbprintAlgorithm, string thumbprint, CertificateGetOptions certificateGetOptions, CancellationToken cancellationToken = default)
 {
     return(await RestClient.GetAsync(thumbprintAlgorithm, thumbprint, certificateGetOptions, cancellationToken).ConfigureAwait(false));
 }
コード例 #24
0
 /// <summary>
 /// Gets information about the specified Certificate.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='thumbprintAlgorithm'>
 /// The algorithm used to derive the thumbprint parameter. This must be sha1.
 /// </param>
 /// <param name='thumbprint'>
 /// The thumbprint of the Certificate to get.
 /// </param>
 /// <param name='certificateGetOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static Certificate Get(this ICertificateOperations operations, string thumbprintAlgorithm, string thumbprint, CertificateGetOptions certificateGetOptions = default(CertificateGetOptions))
 {
     return(operations.GetAsync(thumbprintAlgorithm, thumbprint, certificateGetOptions).GetAwaiter().GetResult());
 }
コード例 #25
0
        public static IEnumerable <Certificate> EnumerateCertificates(this CertificateStoreClient client, int chunkSize, CertificateGetOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (chunkSize < 1)
            {
                throw new ArgumentException("value was less than 1", "chunkSize");
            }

            long lastID = -1;

            Certificate[] certs;
            while (true)
            {
                certs = client.EnumerateCertificates(lastID, chunkSize, options);
                if (certs.IsNullOrEmpty())
                {
                    yield break;
                }

                for (int i = 0; i < certs.Length; ++i)
                {
                    yield return(certs[i]);
                }
                lastID = certs[certs.Length - 1].ID;
            }
        }
コード例 #26
0
 /// <summary>
 /// Gets information about the specified certificate.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='thumbprintAlgorithm'>
 /// The algorithm used to derive the thumbprint parameter. This must be sha1.
 /// </param>
 /// <param name='thumbprint'>
 /// The thumbprint of the certificate to get.
 /// </param>
 /// <param name='certificateGetOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static Certificate Get(this ICertificateOperations operations, string thumbprintAlgorithm, string thumbprint, CertificateGetOptions certificateGetOptions = default(CertificateGetOptions))
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((ICertificateOperations)s).GetAsync(thumbprintAlgorithm, thumbprint, certificateGetOptions), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
コード例 #27
0
 /// <summary>
 /// Gets information about the specified Certificate.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='thumbprintAlgorithm'>
 /// The algorithm used to derive the thumbprint parameter. This must be sha1.
 /// </param>
 /// <param name='thumbprint'>
 /// The thumbprint of the Certificate to get.
 /// </param>
 /// <param name='certificateGetOptions'>
 /// Additional parameters for the operation
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Certificate> GetAsync(this ICertificateOperations operations, string thumbprintAlgorithm, string thumbprint, CertificateGetOptions certificateGetOptions = default(CertificateGetOptions), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetWithHttpMessagesAsync(thumbprintAlgorithm, thumbprint, certificateGetOptions, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
コード例 #28
0
 public virtual Response <Certificate> Get(string thumbprintAlgorithm, string thumbprint, CertificateGetOptions certificateGetOptions, CancellationToken cancellationToken = default)
 {
     return(RestClient.Get(thumbprintAlgorithm, thumbprint, certificateGetOptions, cancellationToken));
 }