ReasonsMask.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 » ReasonsMask.cs
using System;

using Org.BouncyCastle.Asn1.X509;

namespace Org.BouncyCastle.Pkix{
  /// <summary>
  /// This class helps to handle CRL revocation reasons mask. Each CRL handles a
  /// certain set of revocation reasons.
  /// </summary>
  internal class ReasonsMask
  {
    private int _reasons;

    /// <summary>
    /// Constructs are reason mask with the reasons.
    /// </summary>
    /// <param name="reasons">The reasons.</param>
    internal ReasonsMask(
      int reasons)
    {
      _reasons = reasons;
    }

    /// <summary>
    /// A reason mask with no reason.
    /// </summary>
    internal ReasonsMask()
      : this(0)
    {
    }

    /// <summary>
    /// A mask with all revocation reasons.
    /// </summary>
    internal static readonly ReasonsMask AllReasons = new ReasonsMask(
        ReasonFlags.AACompromise | ReasonFlags.AffiliationChanged | ReasonFlags.CACompromise
      |  ReasonFlags.CertificateHold | ReasonFlags.CessationOfOperation
      |  ReasonFlags.KeyCompromise | ReasonFlags.PrivilegeWithdrawn | ReasonFlags.Unused
      |  ReasonFlags.Superseded);

    /**
     * Adds all reasons from the reasons mask to this mask.
     *
     * @param mask The reasons mask to add.
     */
    internal void AddReasons(
      ReasonsMask mask)
    {
      _reasons = _reasons | mask.Reasons.IntValue;
    }

    /// <summary>
    /// Returns <code>true</code> if this reasons mask contains all possible
    /// reasons.
    /// </summary>
    /// <returns>true if this reasons mask contains all possible reasons.
    /// </returns>
    internal bool IsAllReasons
    {
      get { return _reasons == AllReasons._reasons; }
    }

    /// <summary>
    /// Intersects this mask with the given reasons mask.
    /// </summary>
    /// <param name="mask">mask The mask to intersect with.</param>
    /// <returns>The intersection of this and teh given mask.</returns>
    internal ReasonsMask Intersect(
      ReasonsMask mask)
    {
      ReasonsMask _mask = new ReasonsMask();
      _mask.AddReasons(new ReasonsMask(_reasons & mask.Reasons.IntValue));
      return _mask;
    }

    /// <summary>
    /// Returns <c>true</c> if the passed reasons mask has new reasons.
    /// </summary>
    /// <param name="mask">The reasons mask which should be tested for new reasons.</param>
    /// <returns><c>true</c> if the passed reasons mask has new reasons.</returns>
    internal bool HasNewReasons(
      ReasonsMask mask)
    {
      return ((_reasons | mask.Reasons.IntValue ^ _reasons) != 0);
    }

    /// <summary>
    /// Returns the reasons in this mask.
    /// </summary>
    public ReasonFlags Reasons
    {
      get { return new ReasonFlags(_reasons); }
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.