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

/******************************************************************************//**
  * Container class for all certificates on the card
  *********************************************************************************/
public class PTEID_Certificates extends PTEID_Crypto {
  private long swigCPtr;

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

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

	/**
	  * Create a PTEID_Certificates store without any link to a card.
	  * This store is not linked to any card, therefore some methods can not be used
	  * and throw a PTEID_ExBadUsage exception.
	  */
  public PTEID_Certificates() {
    this(pteidlibJava_WrapperJNI.new_PTEID_Certificates(), true);
  }

	/** The number of certificates that were read from the card */
	public long countFromCard() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Certificates_countFromCard(swigCPtr, this);
  }
	/** The total number of certificates in the container (from a card or not) */
  public long countAll() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Certificates_countAll(swigCPtr, this);
  }

	/**
	  * Get a certificate from the card by index
	  * Throw PTEID_ExParamRange exception if the index is out of range
	  */
  public PTEID_Certificate getCertFromCard(long ulIndexCard) throws java.lang.Exception {
    return new PTEID_Certificate(pteidlibJava_WrapperJNI.PTEID_Certificates_getCertFromCard(swigCPtr, this, ulIndexCard), false);
  }

	/**
	  * Get a certificate from the container by index
	  *
	  * ATTENTION ulIndexAll and ulIndexCard are two different indexes
	  * The index will change if new certificates are added with addCert()
	  */
  public PTEID_Certificate getCert(long ulIndexAll) throws java.lang.Exception {
    return new PTEID_Certificate(pteidlibJava_WrapperJNI.PTEID_Certificates_getCert__SWIG_0(swigCPtr, this, ulIndexAll), false);
  }

	/**
	  * Get a certificate by type
	  */
  public PTEID_Certificate getCert(PTEID_CertifType type) throws java.lang.Exception {
    return new PTEID_Certificate(pteidlibJava_WrapperJNI.PTEID_Certificates_getCert__SWIG_1(swigCPtr, this, type.swigValue()), false);
  }

	/** Get the RRN certificate from the card */
  public PTEID_Certificate getRrn() {
    return new PTEID_Certificate(pteidlibJava_WrapperJNI.PTEID_Certificates_getRrn(swigCPtr, this), false);
  }

	/**	 Get the root certificate from the card */
  public PTEID_Certificate getRoot() throws java.lang.Exception {
    return new PTEID_Certificate(pteidlibJava_WrapperJNI.PTEID_Certificates_getRoot(swigCPtr, this), false);
  }

	/** Get the ca certificate from the card */
  public PTEID_Certificate getCA() throws java.lang.Exception {
    return new PTEID_Certificate(pteidlibJava_WrapperJNI.PTEID_Certificates_getCA(swigCPtr, this), false);
  }

	/** Get the signature certificate from the card */
  public PTEID_Certificate getSignature() throws java.lang.Exception {
    return new PTEID_Certificate(pteidlibJava_WrapperJNI.PTEID_Certificates_getSignature(swigCPtr, this), false);
  }

	/** Get the authentication certificate from the card */
  public PTEID_Certificate getAuthentication() throws java.lang.Exception {
    return new PTEID_Certificate(pteidlibJava_WrapperJNI.PTEID_Certificates_getAuthentication(swigCPtr, this), false);
  }

	/**
	  * Add a new certificate to the store
	  */
  public PTEID_Certificate addCertificate(PTEID_ByteArray cert) throws java.lang.Exception {
    return new PTEID_Certificate(pteidlibJava_WrapperJNI.PTEID_Certificates_addCertificate(swigCPtr, this, PTEID_ByteArray.getCPtr(cert), cert), false);
  }

}
