logo       

Still stuck with problem. Re: Problem decrypting elements: msg#00029

Subject: Still stuck with problem. Re: Problem decrypting elements
Hello all,

I'm still stuck with this problem and don't know what else to try.  I'm
basically using the sample code with some modifications to handle multiple
elements.

Encryption works fine with child elements or contents both when a single or
multiple elements with the same name are encrypted.  However, decryption
only works when there is a single element or content node to decrypt.  If
there are more, an exception is thrown:

  Oct 30, 2007 2:28:18 PM org.apache.xml.security.encryption.XMLCipher
    decryptToByteArray
  SEVERE: XMLCipher::decryptElement called without a key and unable to
    resolve Exception in thread "main"
    org.apache.xml.security.encryption.XMLEncryptionException: No Key
    Encryption Key loaded and cannot determine using key resolvers

Stepping through the code in my IDE, I can see that the key gets loaded. 
What is missing, though, is the KeyInfo.  Method
decryptToByteArray(Element element) in class XMLCipher tries to get the
KeyInfo:

   KeyInfo ki = encryptedData.getKeyInfo();

When ki gets evaluated it is null, however, and the exception is thrown. 
Again, it only happens when multiple elements are encrypted.

Obviously, I'm missing something here but neither the documentation nor the
email archive have given me any clues on how to solve this.  Any help will
be greatly appreciated.

Thanks,
Wolfgang







Quoting Wolfgang Freis <wolfgang.freis@xxxxxxxx>:

> Hello,
>
> I'm new to working with XML encryption and have come across a problem.
> Neither the email archive nor have brought me closer to a solution.
>
> Google Starting with the sample files Encrypter.java and Decrypter.java
> I
> have managed to en- and decrypt elements by name.  However, decryption
> works only when there is only one element encrypted.  If I encrypt
> multiple elements by name--as siblings or as children of different
> parents--the decryptor throws an exception:
>
> Oct 26, 2007 3:56:45 PM org.apache.xml.security.encryption.XMLCipher
>     decryptToByteArray
> SEVERE: XMLCipher::decryptElement called without a key and unable to
>     resolve
> Exception in thread "main"
> org.apache.xml.security.encryption.XMLEncryptionException:
>     No Key Encryption Key loaded and cannot determine using key
> resolvers
>
> My IDE tells that the key file was loaded and, as I said, the decryption
> works fine when only one element of the XML is encrypted.  I tried
> decrypting by iterating over the NodeList returned from
> getElementsByTagNameNS(namespaceURI, localName) and trying to just grab
> the first item.  Both generate the same exception.  From what I can see
> in
> the IDE is that the method decryptToByteArray(Element element) called
> from
> doFinal( document, encryptedDataElement) throws the exception, but it
> escapes me why that happens.
>
> Any help will be greatly appreciated.
>
> Thanks,
> Wolfgang
>
>
>





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe