/* ----------------------------------------------------------------------------
 * 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 represent one certificate
  *********************************************************************************/
public class PTEID_Certificate extends PTEID_Crypto {
  private long swigCPtr;

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

  protected static long getCPtr(PTEID_Certificate 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_Certificate(swigCPtr);
    }
    swigCPtr = 0;
    super.delete();
  }

	/** Get the label of the certificate */
  public String getLabel() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Certificate_getLabel(swigCPtr, this);
  }

	/** Get the id of the certificate */
  public long getID() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Certificate_getID(swigCPtr, this);
  }

	/**
	  * Get the status of the certificate using the default or configured validation level
	  */
  public PTEID_CertifStatus getStatus() throws java.lang.Exception {
    return PTEID_CertifStatus.swigToEnum(pteidlibJava_WrapperJNI.PTEID_Certificate_getStatus__SWIG_0(swigCPtr, this));
  }

	/**
	  * Get the status of the certificate
	  * @param crl CRL validation level \see PTEID_ValidationLevel
	  * @param ocsp OCSP validation level \see PTEID_ValidationLevel
	  */
  public PTEID_CertifStatus getStatus(PTEID_ValidationLevel crl, PTEID_ValidationLevel ocsp) throws java.lang.Exception {
    return PTEID_CertifStatus.swigToEnum(pteidlibJava_WrapperJNI.PTEID_Certificate_getStatus__SWIG_1(swigCPtr, this, crl.swigValue(), ocsp.swigValue()));
  }

	/** Get the type of the certificate */
  public PTEID_CertifType getType() throws java.lang.Exception {
    return PTEID_CertifType.swigToEnum(pteidlibJava_WrapperJNI.PTEID_Certificate_getType(swigCPtr, this));
  }

	/** Get the content of the certificate */
  public PTEID_ByteArray getCertData() throws java.lang.Exception {
    return new PTEID_ByteArray(pteidlibJava_WrapperJNI.PTEID_Certificate_getCertData(swigCPtr, this), false);
  }

	/** Get the content of the certificate without trailing zero */
  public void getFormattedData(PTEID_ByteArray data) {
    pteidlibJava_WrapperJNI.PTEID_Certificate_getFormattedData(swigCPtr, this, PTEID_ByteArray.getCPtr(data), data);
  }

	/** Get the serial number of the certificate */
  public String getSerialNumber() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Certificate_getSerialNumber(swigCPtr, this);
  }

	  /** Get the name of the owner of the certificate */
  public String getOwnerName() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Certificate_getOwnerName(swigCPtr, this);
  }

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

	/** Get the validity begin date of the certificate */
  public String getValidityBegin() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Certificate_getValidityBegin(swigCPtr, this);
  }

	/** Get the validity end date of the certificate */
  public String getValidityEnd() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Certificate_getValidityEnd(swigCPtr, this);
  }

	/** Get the length of public/private key on the certificate */
  public long getKeyLength() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Certificate_getKeyLength(swigCPtr, this);
  }

	/**
	  * Check if this is a root certificate;
	  */

  public boolean isRoot() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Certificate_isRoot(swigCPtr, this);
  }

	/**
	  * Check if this is a test certificate
	  *
	  * @return true if this is test certificate
	  */
  public boolean isTest() {
    return pteidlibJava_WrapperJNI.PTEID_Certificate_isTest(swigCPtr, this);
  }

	/**
	  * Return true if the certificate chain ends by the pteid root certificate
	  */
  public boolean isFromPteidValidChain() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Certificate_isFromPteidValidChain(swigCPtr, this);
  }

	/**
	  * Return true if this certificate comes from the card
	  */
  public boolean isFromCard() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Certificate_isFromCard(swigCPtr, this);
  }

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

	/**
	  * Get the number of children of this certificate
	  */
  public long countChildren() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Certificate_countChildren(swigCPtr, this);
  }

	/**
	  * Get a child certificate (certificate that has been issued by this one)
	  *
	  * @param ulIndex is the child index (first child is 0).
	  * Throws PTEID_ExParamRange exception if the index is out of range
	  */
  public PTEID_Certificate getChildren(long ulIndex) throws java.lang.Exception {
    return new PTEID_Certificate(pteidlibJava_WrapperJNI.PTEID_Certificate_getChildren(swigCPtr, this, ulIndex), false);
  }

	/**
	  * Get the crl of the certificate;
	  */
  public PTEID_Crl getCRL() throws java.lang.Exception {
    return new PTEID_Crl(pteidlibJava_WrapperJNI.PTEID_Certificate_getCRL(swigCPtr, this), false);
  }

	/**
	  * Return the ocsp response object of the certificate;
	  */
  public PTEID_OcspResponse getOcspResponse() throws java.lang.Exception {
    return new PTEID_OcspResponse(pteidlibJava_WrapperJNI.PTEID_Certificate_getOcspResponse(swigCPtr, this), false);
  }

	/** Verify the certificate trough CRL validation
	  * @param forceDownload if true will force a new download of the CRL, otherwise use the CRL cache
	  */
  public PTEID_CertifStatus verifyCRL(boolean forceDownload) throws java.lang.Exception {
    return PTEID_CertifStatus.swigToEnum(pteidlibJava_WrapperJNI.PTEID_Certificate_verifyCRL__SWIG_0(swigCPtr, this, forceDownload));
  }

	/** Verify the certificate trough CRL validation (uses the CRL cache if possible) */
  public PTEID_CertifStatus verifyCRL() throws java.lang.Exception {
    return PTEID_CertifStatus.swigToEnum(pteidlibJava_WrapperJNI.PTEID_Certificate_verifyCRL__SWIG_1(swigCPtr, this));
  }

	/** Verify the certificate trough OCSP validation */
  public PTEID_CertifStatus verifyOCSP() throws java.lang.Exception {
    return PTEID_CertifStatus.swigToEnum(pteidlibJava_WrapperJNI.PTEID_Certificate_verifyOCSP(swigCPtr, this));
  }

}
