* @param eos OutputStream
* @throws IOException
*/
public void encryptData(OutputStream eos) throws IOException{
try{
OutputStreamWrapper outputStream = new OutputStreamWrapper(eos);
if(encryptedDataCV != null){
outputStream.write(encryptedDataCV);
return;
}
// Thread.dumpStack();
if(cipher == null){
initCipher();
}
//Base64OutputStream bos = new Base64OutputStream(outputStream);
//TODO :: Wrap outputstream with base64 encoder
CipherOutputStream cos = new CipherOutputStream(outputStream,cipher);
//BufferedStreamWriter bsw = new BufferedStreamWriter(cos);
byte [] iv = cipher.getIV();
outputStream.write(iv);
outputStream.flush();
if(data instanceof JAXBData){
((JAXBData)data).writeTo(cos);// write in chucks
}else if(data instanceof StreamWriterData){
StAXC14nCanonicalizerImpl exc14n = new StAXEXC14nCanonicalizerImpl();
//((StAXEXC14nCanonicalizerImpl)exc14n).setInclusivePrefixList(new ArrayList());