/**
  * End Element handler
  *
  * @param namespaceURI namespace URI
  * @param lName local name
  * @param qName qualified name
  */
 public void endElement(String namespaceURI, String sName, String qName) throws SAXException {
   String tName = qName;
   if (tName.indexOf(":") != -1) tName = qName.substring(tName.indexOf(":") + 1);
   if (m_logger.isDebugEnabled()) m_logger.debug("End Element: " + tName);
   // remove last tag from stack
   String currTag = (String) m_tags.pop();
   //	<KeyName>
   if (tName.equals("KeyName")) {
     checkEncryptedData();
     EncryptedKey ekey = m_doc.getLastEncryptedKey();
     checkEncryptedKey(ekey);
     ekey.setKeyName(m_sbCollectChars.toString());
     m_sbCollectChars = null; // stop collecting
   }
   //	<CarriedKeyName>
   if (tName.equals("CarriedKeyName")) {
     checkEncryptedData();
     EncryptedKey ekey = m_doc.getLastEncryptedKey();
     checkEncryptedKey(ekey);
     ekey.setCarriedKeyName(m_sbCollectChars.toString());
     m_sbCollectChars = null; // stop collecting
   }
   //	<X509Certificate>
   if (tName.equals("X509Certificate")) {
     checkEncryptedData();
     EncryptedKey ekey = m_doc.getLastEncryptedKey();
     checkEncryptedKey(ekey);
     try {
       X509Certificate cert =
           SignedDoc.readCertificate(Base64Util.decode(m_sbCollectChars.toString().getBytes()));
       ekey.setRecipientsCertificate(cert);
     } catch (DigiDocException ex) {
       SAXDigiDocException.handleException(ex);
     }
     m_sbCollectChars = null; // stop collecting
   }
   //	<CipherValue>
   if (tName.equals("CipherValue")) {
     checkEncryptedData();
     if (m_tags.search("EncryptedKey") != -1) { // child of <EncryptedKey>
       EncryptedKey ekey = m_doc.getLastEncryptedKey();
       checkEncryptedKey(ekey);
       ekey.setTransportKeyData(Base64Util.decode(m_sbCollectChars.toString().getBytes()));
     } else { // child of <EncryptedData>
       m_doc.setData(Base64Util.decode(m_sbCollectChars.toString().getBytes()));
       if (m_doc.getMimeType() != null
           && m_doc.getMimeType().equals(EncryptedData.DENC_ENCDATA_MIME_ZLIB))
         m_doc.setDataStatus(EncryptedData.DENC_DATA_STATUS_ENCRYPTED_AND_COMPRESSED);
       else
         m_doc.setDataStatus(EncryptedData.DENC_DATA_STATUS_ENCRYPTED_AND_NOT_COMPRESSED); // ???		
     }
     m_sbCollectChars = null; // stop collecting
   }
   // <EncryptionProperty>
   if (tName.equals("EncryptionProperty")) {
     checkEncryptedData();
     EncryptionProperty eprop = m_doc.getLastProperty();
     try {
       eprop.setContent(m_sbCollectChars.toString());
     } catch (DigiDocException ex) {
       SAXDigiDocException.handleException(ex);
     }
     m_sbCollectChars = null; // stop collecting
   }
 }