/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 1.3.35
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

namespace be.portugal.eid {

using System;
using System.Runtime.InteropServices;

/// <summary>Class that represents one CRL.</summary>
public class PTEID_Crl : PTEID_Object {
  private HandleRef swigCPtr;

  internal PTEID_Crl(IntPtr cPtr, bool cMemoryOwn) : base(pteidlib_dotNetPINVOKE.PTEID_CrlUpcast(cPtr), cMemoryOwn) {
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(PTEID_Crl obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }

  ~PTEID_Crl() {
    Dispose();
  }

  public override void Dispose() {
    lock(this) {
      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
        swigCMemOwn = false;
        pteidlib_dotNetPINVOKE.delete_PTEID_Crl(swigCPtr);
      }
      swigCPtr = new HandleRef(null, IntPtr.Zero);
      GC.SuppressFinalize(this);
      base.Dispose();
    }
  }

  /// <summary>
  /// Create a Crl from its uri (without any certificate link).
  /// </summary>
  /// <remarks>
  /// As there is no issuer, this CRL can't be verify and some method are not allowed (ex. getIssuer).
  /// These methods throw PTEID_ExBadUsage exception.
  /// </remarks>
  public PTEID_Crl(string uri)
      : this(pteidlib_dotNetPINVOKE.new_PTEID_Crl(uri), true)
  {
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>Return the uri of the CRL.</summary>
  public string getUri()
  {
    string ret = pteidlib_dotNetPINVOKE.PTEID_Crl_getUri(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Return the name of the issuer of the certificate.</summary>
  public string getIssuerName()
  {
    string ret = pteidlib_dotNetPINVOKE.PTEID_Crl_getIssuerName(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Return the issuer certificate.
  /// </summary>
  /// <remarks>
  /// if there is no issuer (root), PTEID_ExCertNoIssuer exception is thrown.
  /// </remarks>
  public PTEID_Certificate getIssuer()
  {
    PTEID_Certificate ret = new PTEID_Certificate(pteidlib_dotNetPINVOKE.PTEID_Crl_getIssuer(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Return the CRL as a byte array.
  /// </summary>
  /// <remarks>
  /// If it comes from a Certif we verify the signature.
  /// If it's created from the URL only we DON'T verify the signature.
  /// </remarks>
  /// <param name="crl">will content the crl</param>  
  /// <param name="bForceDownload">if true the CRL in the cache is not valid anymore and we force a new download</param>
  public PTEID_CrlStatus getData(PTEID_ByteArray crl, bool bForceDownload)
  {
    PTEID_CrlStatus ret = (PTEID_CrlStatus)pteidlib_dotNetPINVOKE.PTEID_Crl_getData__SWIG_0(swigCPtr, PTEID_ByteArray.getCPtr(crl), bForceDownload);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Return the CRL as a byte array.
  /// </summary>
  /// <remarks>
  /// If it comes from a Certif we verify the signature.
  /// If it's created from the URL only we DON'T verify the signature.
  /// </remarks>
  /// <param name="crl">will content the crl</param>  
  public PTEID_CrlStatus getData(PTEID_ByteArray crl)
  {
    PTEID_CrlStatus ret = (PTEID_CrlStatus)pteidlib_dotNetPINVOKE.PTEID_Crl_getData__SWIG_1(swigCPtr, PTEID_ByteArray.getCPtr(crl));
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}
