/* ----------------------------------------------------------------------------
 * 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.
 * ----------------------------------------------------------------------------- */

package be.portugal.eid;

/******************************************************************************//**
  * Class that represents a CRL
  *********************************************************************************/
public class PTEID_Crl extends PTEID_Object {
  private long swigCPtr;

  protected PTEID_Crl(long cPtr, boolean cMemoryOwn) {
    super(pteidlibJava_WrapperJNI.SWIGPTEID_CrlUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  protected static long getCPtr(PTEID_Crl obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      pteidlibJava_WrapperJNI.delete_PTEID_Crl(swigCPtr);
    }
    swigCPtr = 0;
    super.delete();
  }

	/**
	  * Create a Crl object from using the uri (without any certificate link);
	  * As there is no issuer, this CRL can't be verify and some methods are not allowed
	  * (ex. getIssuer()).
	  * These methods throw a PTEID_ExBadUsage exception
	  */
  public PTEID_Crl(String uri) {
    this(pteidlibJava_WrapperJNI.new_PTEID_Crl(uri), true);
  }

	/** Return the uri of the CRL */
  public String getUri() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Crl_getUri(swigCPtr, this);
  }

	/** Return the name of the issuer of the certificate */
  public String getIssuerName() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Crl_getIssuerName(swigCPtr, this);
  }

	/**
	  * Return the issuer certificate;
	  *
	  * if there is no issuer (root), a PTEID_ExCertNoIssuer exception is thrown
	  */
  public PTEID_Certificate getIssuer() throws java.lang.Exception {
    return new PTEID_Certificate(pteidlibJava_WrapperJNI.PTEID_Crl_getIssuer(swigCPtr, this), false);
  }

	/**
	  * Return the CRL as a byte array
	  * If the CRL comes from a certificate we verify the signature
	  * If the CRL is created from the URL only we DON'T verify the signature
	  * @param crl will contain the crl
	  * @param bForceDownload if true, a new CRL will be downloaded, otherwise the CRL cache will be used
	  * @return Status of the CRL \see PTEID_CrlStatus
	  */
  public PTEID_CrlStatus getData(PTEID_ByteArray crl, boolean bForceDownload) throws java.lang.Exception {
    return PTEID_CrlStatus.swigToEnum(pteidlibJava_WrapperJNI.PTEID_Crl_getData__SWIG_0(swigCPtr, this, PTEID_ByteArray.getCPtr(crl), crl, bForceDownload));
  }

	/**
	  * Return the CRL as a byte array
	  * If the CRL comes from a certificate we verify the signature
	  * If the CRL is created from the URL only we DON'T verify the signature
	  * @param crl will contain the crl. The CRL cache will be used by default
	  * @return Status of the CRL \see PTEID_CrlStatus
	  */
  public PTEID_CrlStatus getData(PTEID_ByteArray crl) throws java.lang.Exception {
    return PTEID_CrlStatus.swigToEnum(pteidlibJava_WrapperJNI.PTEID_Crl_getData__SWIG_1(swigCPtr, this, PTEID_ByteArray.getCPtr(crl), crl));
  }

}
