PkixBuilderParameters.cs :  » PDF » iTextSharp » Org » BouncyCastle » Pkix » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » PDF » iTextSharp 
iTextSharp » Org » BouncyCastle » Pkix » PkixBuilderParameters.cs
using System;
using System.Text;

using Org.BouncyCastle.Security;
using Org.BouncyCastle.X509.Store;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.Utilities.Collections;

namespace Org.BouncyCastle.Pkix{
  /// <summary>
    /// Summary description for PkixBuilderParameters.
  /// </summary>
  public class PkixBuilderParameters
    : PkixParameters
  {
    private int maxPathLength = 5;

    private ISet excludedCerts = new HashSet();

    /**
    * Returns an instance of <code>PkixBuilderParameters</code>.
    * <p>
    * This method can be used to get a copy from other
    * <code>PKIXBuilderParameters</code>, <code>PKIXParameters</code>,
    * and <code>ExtendedPKIXParameters</code> instances.
    * </p>
    *
    * @param pkixParams The PKIX parameters to create a copy of.
    * @return An <code>PkixBuilderParameters</code> instance.
    */
    public static PkixBuilderParameters GetInstance(
      PkixParameters pkixParams)
    {
      PkixBuilderParameters parameters = new PkixBuilderParameters(
        pkixParams.GetTrustAnchors(),
        new X509CertStoreSelector(pkixParams.GetTargetCertConstraints()));
      parameters.SetParams(pkixParams);
      return parameters;
    }

    public PkixBuilderParameters(
      ISet      trustAnchors,
      IX509Selector  targetConstraints)
      : base(trustAnchors)
    {
      SetTargetCertConstraints(targetConstraints);
    }

    public virtual int MaxPathLength
    {
      get { return maxPathLength; }
      set
      {
        if (value < -1)
        {
          throw new InvalidParameterException(
            "The maximum path length parameter can not be less than -1.");
        }
        this.maxPathLength = value;
      }
    }

    /// <summary>
    /// Excluded certificates are not used for building a certification path.
    /// </summary>
    /// <returns>the excluded certificates.</returns>
    public virtual ISet GetExcludedCerts()
    {
      return new HashSet(excludedCerts);
    }

    /// <summary>
    /// Sets the excluded certificates which are not used for building a
    /// certification path. If the <code>ISet</code> is <code>null</code> an
    /// empty set is assumed.
    /// </summary>
    /// <remarks>
    /// The given set is cloned to protect it against subsequent modifications.
    /// </remarks>
    /// <param name="excludedCerts">The excluded certificates to set.</param>
    public virtual void SetExcludedCerts(
      ISet excludedCerts)
    {
      if (excludedCerts == null)
      {
        excludedCerts = new HashSet();
      }
      else
      {
        this.excludedCerts = new HashSet(excludedCerts);
      }
    }

    /**
    * Can alse handle <code>ExtendedPKIXBuilderParameters</code> and
    * <code>PKIXBuilderParameters</code>.
    * 
    * @param params Parameters to set.
    * @see org.bouncycastle.x509.ExtendedPKIXParameters#setParams(java.security.cert.PKIXParameters)
    */
    protected override void SetParams(
      PkixParameters parameters)
    {
      base.SetParams(parameters);
      if (parameters is PkixBuilderParameters)
      {
        PkixBuilderParameters _params = (PkixBuilderParameters) parameters;
        maxPathLength = _params.maxPathLength;
        excludedCerts = new HashSet(_params.excludedCerts);
      }
    }

    /**
    * Makes a copy of this <code>PKIXParameters</code> object. Changes to the
    * copy will not affect the original and vice versa.
    *
    * @return a copy of this <code>PKIXParameters</code> object
    */
    public override object Clone()
    {
      PkixBuilderParameters parameters = new PkixBuilderParameters(
        GetTrustAnchors(), GetTargetCertConstraints());
      parameters.SetParams(this);
      return parameters;
    }

    public override string ToString()
    {
      string nl = Platform.NewLine;
      StringBuilder s = new StringBuilder();
      s.Append("PkixBuilderParameters [" + nl);
      s.Append(base.ToString());
      s.Append("  Maximum Path Length: ");
      s.Append(MaxPathLength);
      s.Append(nl + "]" + nl);
      return s.ToString();
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.