Hi,
because I need to write XML streams to binary encrypted files, I made
a custom serializer, which replaces the outputStream with a
CipherOutputStream, based on the code of the XMLSerializer. This seems
to work, however, I got a problem:
it does not receive the last 20 bytes. When decrypting the result, I
get at the end eg.:
</body></SessionIt
at the end, instead of :
</body></SessionItem></MeetingMinutes>.
I 'm not sure if I'm implementing the serializer the wright way...
thx,
Dominique
CODE:
public class EncryptedSerializer extends AbstractTextSerializer {
private Logger log = Logger.getLogger( this.getClass());
public void setOutputStream(OutputStream out) throws IOException {
//this is a replacement of function call, to show the meaning
CipherOutputStream encr_stream = new CipherOutputStream(out,
encrypter);
super.setOutputStream(encr_stream);
log.debug("Setting encrypted stream");
try {
TransformerHandler handler = this.getTransformerHandler();
handler.getTransformer().setOutputProperties(this.format);
handler.setResult(new StreamResult(encr_stream));
this.setContentHandler(handler);
this.setLexicalHandler(handler);
} catch (Exception e) {
final String message = "Cannot set XMLSerializer outputstream";
throw new CascadingIOException(message, e);
}
}
/**
* Set the configurations for this serializer.
*/
public void configure(Configuration conf)
throws ConfigurationException {
super.configure( conf );
this.format.put(OutputKeys.METHOD,"xml");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]