blautenb    2003/07/21 04:30:40

  Modified:    src/org/apache/xml/security/encryption XMLCipher.java
  Log:
  Load a KeyInfo using XMLSignature KeyInfo classes
  
  Revision  Changes    Path
  1.4       +39 -3     
xml-security/src/org/apache/xml/security/encryption/XMLCipher.java
  
  Index: XMLCipher.java
  ===================================================================
  RCS file: 
/home/cvs/xml-security/src/org/apache/xml/security/encryption/XMLCipher.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLCipher.java    15 Jul 2003 12:34:29 -0000      1.3
  +++ XMLCipher.java    21 Jul 2003 11:30:40 -0000      1.4
  @@ -100,6 +100,7 @@
   import org.apache.xml.security.transforms.Transform;
   import org.apache.xml.security.utils.ElementProxy;
   import org.apache.xml.security.exceptions.Base64DecodingException;
  +import org.apache.xml.security.exceptions.XMLSecurityException;
   import org.apache.xml.serialize.OutputFormat;
   import org.apache.xml.serialize.XMLSerializer;
   import org.apache.xml.utils.URI;
  @@ -809,6 +810,34 @@
       }
   
       /**
  +     * Returns an <code>EncryptedData</code> interface. Use this operation if
  +     * you want to load an <code>EncryptedData</code> structure from a DOM 
  +      * structure and manipulate the contents 
  +     *
  +     * @param context the context <code>Document</code>.
  +     * @param element the <code>Element</code> that will be loaded
  +     * @throws XMLEncryptionException.
  +     */
  +    public EncryptedData loadEncryptedData(Document context, Element 
element) 
  +             throws XMLEncryptionException {
  +        logger.info("Loading encrypted element...");
  +        if(null == context)
  +            logger.error("Context document unexpectedly null...");
  +        if(null == element)
  +            logger.error("Element unexpectedly null...");
  +        if(cipherMode != DECRYPT_MODE)
  +            logger.error("XMLCipher unexpectedly not in DECRYPT_MODE...");
  +
  +        instance.contextDocument = context;
  +        EncryptedData encryptedData = factory.newEncryptedData(element);
  +
  +             return (encryptedData);
  +    }
  +
  +
  +
  +
  +    /**
        * Decrypts an <code>EncryptedKey</code> object.
        */
       public EncryptedKey encryptKey(Document context, Element element) throws
  @@ -1437,7 +1466,7 @@
           //     </complexContent>
           // </complexType>
           EncryptedData newEncryptedData(Element element) throws
  -                XMLEncryptionException {
  +                     XMLEncryptionException {
               EncryptedData result = null;
   
               Element dataElement =
  @@ -1472,12 +1501,19 @@
                       encryptionMethodElement));
               }
   
  -            // TODO: Implement
  +            // BFL 16/7/03 - simple implementation
  +                     // TODO: Work out how to handle relative URI
  +
               Element keyInfoElement =
                   (Element) element.getElementsByTagNameNS(
                       Constants.SignatureSpecNS, 
Constants._TAG_KEYINFO).item(0);
               if (null != keyInfoElement) {
  -                result.setKeyInfo(null);
  +                             try {
  +                                     result.setKeyInfo(new 
KeyInfo(keyInfoElement, null));
  +                             } catch (XMLSecurityException xse) {
  +                                     throw new XMLEncryptionException("Error 
loading Key Info", 
  +                                                                             
                         xse);
  +                             }
               }
   
               // TODO: Implement
  
  
  

Reply via email to