Ejemplo n.º 1
0
 /**
  * Method addEncryptedKey
  *
  * @param encryptedKey
  * @throws XMLEncryptionException
  */
 public void add(EncryptedKey encryptedKey) throws XMLEncryptionException {
   if (encryptedKeys == null) {
     encryptedKeys = new ArrayList<EncryptedKey>();
   }
   encryptedKeys.add(encryptedKey);
   XMLCipher cipher = XMLCipher.getInstance();
   this.constructionElement.appendChild(cipher.martial(encryptedKey));
 }
Ejemplo n.º 2
0
  /**
   * Method itemEncryptedKey
   *
   * @param i
   * @return the asked EncryptedKey element, null if the index is too big
   * @throws XMLSecurityException
   */
  public EncryptedKey itemEncryptedKey(int i) throws XMLSecurityException {
    if (encryptedKeys != null) {
      return encryptedKeys.get(i);
    }
    Element e =
        XMLUtils.selectXencNode(
            this.constructionElement.getFirstChild(), EncryptionConstants._TAG_ENCRYPTEDKEY, i);

    if (e != null) {
      XMLCipher cipher = XMLCipher.getInstance();
      cipher.init(XMLCipher.UNWRAP_MODE, null);
      return cipher.loadEncryptedKey(e);
    }
    return null;
  }