Org.BouncyCastle.Pkix.PkixBuilderParameters.GetInstance C# (CSharp) Méthode

GetInstance() public static méthode

public static GetInstance ( PkixParameters pkixParams ) : PkixBuilderParameters
pkixParams PkixParameters
Résultat PkixBuilderParameters
		public static PkixBuilderParameters GetInstance(
			PkixParameters pkixParams)
		{
			PkixBuilderParameters parameters = new PkixBuilderParameters(
				pkixParams.GetTrustAnchors(),
				new X509CertStoreSelector(pkixParams.GetTargetCertConstraints()));
			parameters.SetParams(pkixParams);
			return parameters;
		}

Usage Example

        internal static PkixCertPath ProcessAttrCert1(IX509AttributeCertificate attrCert, PkixParameters pkixParams)
        {
            PkixCertPathBuilderResult pkixCertPathBuilderResult = null;
            ISet set = new HashSet();

            if (attrCert.Holder.GetIssuer() != null)
            {
                X509CertStoreSelector x509CertStoreSelector = new X509CertStoreSelector();
                x509CertStoreSelector.SerialNumber = attrCert.Holder.SerialNumber;
                X509Name[] issuer = attrCert.Holder.GetIssuer();
                for (int i = 0; i < issuer.Length; i++)
                {
                    try
                    {
                        x509CertStoreSelector.Issuer = issuer[i];
                        set.AddAll(PkixCertPathValidatorUtilities.FindCertificates(x509CertStoreSelector, pkixParams.GetStores()));
                    }
                    catch (Exception cause)
                    {
                        throw new PkixCertPathValidatorException("Public key certificate for attribute certificate cannot be searched.", cause);
                    }
                }
                if (set.IsEmpty)
                {
                    throw new PkixCertPathValidatorException("Public key certificate specified in base certificate ID for attribute certificate cannot be found.");
                }
            }
            if (attrCert.Holder.GetEntityNames() != null)
            {
                X509CertStoreSelector x509CertStoreSelector2 = new X509CertStoreSelector();
                X509Name[]            entityNames            = attrCert.Holder.GetEntityNames();
                for (int j = 0; j < entityNames.Length; j++)
                {
                    try
                    {
                        x509CertStoreSelector2.Issuer = entityNames[j];
                        set.AddAll(PkixCertPathValidatorUtilities.FindCertificates(x509CertStoreSelector2, pkixParams.GetStores()));
                    }
                    catch (Exception cause2)
                    {
                        throw new PkixCertPathValidatorException("Public key certificate for attribute certificate cannot be searched.", cause2);
                    }
                }
                if (set.IsEmpty)
                {
                    throw new PkixCertPathValidatorException("Public key certificate specified in entity name for attribute certificate cannot be found.");
                }
            }
            PkixBuilderParameters          instance = PkixBuilderParameters.GetInstance(pkixParams);
            PkixCertPathValidatorException ex       = null;

            foreach (X509Certificate certificate in set)
            {
                instance.SetTargetConstraints(new X509CertStoreSelector
                {
                    Certificate = certificate
                });
                PkixCertPathBuilder pkixCertPathBuilder = new PkixCertPathBuilder();
                try
                {
                    pkixCertPathBuilderResult = pkixCertPathBuilder.Build(PkixBuilderParameters.GetInstance(instance));
                }
                catch (PkixCertPathBuilderException cause3)
                {
                    ex = new PkixCertPathValidatorException("Certification path for public key certificate of attribute certificate could not be build.", cause3);
                }
            }
            if (ex != null)
            {
                throw ex;
            }
            return(pkixCertPathBuilderResult.CertPath);
        }
All Usage Examples Of Org.BouncyCastle.Pkix.PkixBuilderParameters::GetInstance