hi guys,

thx for the tips. I now switched to inherit from
EncodingSerializer.java (in the block/serializers part). This gives me
me more easy access to the flushing behaviour.
I solved the problem for now by putting 25 Newline characters add the
end, because after trying for hours I think I'm in kind of a deadlock:

It is only untill after out.flush() has occurred, that the
crypto.doFinal() gives me the ending
part that I'm missing. Yet after this flush, the output has been streamed and
then I can not add anything to it.
I wanted to manually trigger the following behaviour  from the Java
API of  CipherOutputStream.close()
"This method invokes the doFinal method of the encapsulated cipher
object, which causes any bytes buffered by the encapsulated cipher to
be processed. The result is written out by calling the flush method of
this output stream."
(No source code available for javax.crypto unfortunatly)
.
I tried puting write, flush statements at all kind of places (using
the different streams) but nothing seems to work.

this is a code snippet (which does not work !)

public void endDocument() throws SAXException {

        log.debug("end document...");
        try {
                
        this.writeln();
        this.flush();
        byte[] result = crypto.doFinal();
        byte[] decrypted = decrypto.doFinal(result);
        String firstResult = new String (decrypted);
        log.debug("This is my result" + firstResult);
        this.write(firstResult);
        this.flush();
        
        }
        catch (Exception e) {
                        log.error("Error flushing !" + e.getMessage(), e);
                }

   }




On 06/09/06, Ard Schrijvers <[EMAIL PROTECTED]> wrote:

> Hi Ard !
>
> >  Think the flush() and doFinal() things are not the problem
> (look at
> > the XMLSerializer, Dominique is doing more or less the same)
>
> Still think so! Made a giant effort and took a look at the doc :
>
> public void close() :
> ...
> This method invokes the doFinal method of the encapsulated cipher
> object, which causes any bytes buffered by the encapsulated
> cipher to be
> processed.
> ...
>
> So if we don't call close() on the stream, the necessary
> doFinal() will
> not be called. As we are not allowed to call close(), maybe it's a
> workaround to call doFinal() on the underrlying Cipher object. But
> that's a wierd hack ...

Sounds pretty convincing! If only Dominique could post wether it works :-)

Ard

>
> A call to flush() is not sufficient.
>
> Greetings
>
> Andreas
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to