X509Extension.cs :  » PDF » iTextSharp » Org » BouncyCastle » Asn1 » X509 » 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 » Asn1 » X509 » X509Extension.cs
using System;

namespace Org.BouncyCastle.Asn1.X509{
    /**
     * an object for the elements in the X.509 V3 extension block.
     */
    public class X509Extension
    {
        internal bool        critical;
        internal Asn1OctetString  value;

    public X509Extension(
            DerBoolean    critical,
            Asn1OctetString  value)
        {
            if (critical == null)
            {
                throw new ArgumentNullException("critical");
            }

      this.critical = critical.IsTrue;
            this.value = value;
        }

    public X509Extension(
            bool      critical,
            Asn1OctetString  value)
        {
            this.critical = critical;
            this.value = value;
        }

    public bool IsCritical { get { return critical; } }

    public Asn1OctetString Value { get { return value; } }

    public override int GetHashCode()
        {
      int vh = this.Value.GetHashCode();

      return IsCritical ? vh : ~vh;
        }

    public override bool Equals(
            object obj)
        {
            X509Extension other = obj as X509Extension;
            if (other == null)
            {
                return false;
            }

      return Value.Equals(other.Value) && IsCritical == other.IsCritical;
        }

    /// <sumary>Convert the value of the passed in extension to an object.</sumary>
    /// <param name="ext">The extension to parse.</param>
    /// <returns>The object the value string contains.</returns>
    /// <exception cref="ArgumentException">If conversion is not possible.</exception>
    public static Asn1Object ConvertValueToObject(
      X509Extension ext)
    {
      try
      {
        return Asn1Object.FromByteArray(ext.Value.GetOctets());
      }
      catch (Exception e)
      {
        throw new ArgumentException("can't convert extension", e);
      }
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.