Re: Include signed XML into a single CDATA

2016-09-20 Thread xavi.dive.kite
Returning to writeCData() makes this:

MIIFhDCCA2ygAwIBAgIQUR762xXMDeJWWLNGuZSuszANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQG

Re: Include signed XML into a single CDATA

2016-09-20 Thread Sergey Beryozkin
Then you need to get back to your original code which calls writeCData - 
you say you see multiple CData blocks - but also said that 
writeCharacters() is called only once - something does not add up here - 
because if writeCharacters is called only once how then calling 
writeCData only once can cause multiple blocks written out ?



Sergey

On 20/09/16 13:44, xavi.dive.kite wrote:

The problem is that

super.writeCharacters(string)

Escapes <, > and &... by default, but no way to avoid this behaviour...
Don't know how to use another library there



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Include-signed-XML-into-a-single-CDATA-tp5772863p5772898.html
Sent from the cxf-user mailing list archive at Nabble.com.




--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/


Re: Include signed XML into a single CDATA

2016-09-20 Thread xavi.dive.kite
The problem is that

super.writeCharacters(string)

Escapes <, > and &... by default, but no way to avoid this behaviour...
Don't know how to use another library there



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Include-signed-XML-into-a-single-CDATA-tp5772863p5772898.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Include signed XML into a single CDATA

2016-09-20 Thread Sergey Beryozkin
Well, you'd need to keep experimenting, it's been many years since I 
possibly tried to write something like that, I'm sure the solution exists...


Sergey
On 20/09/16 11:12, xavi.dive.kite wrote:

Sorry but scape characters are coded in my response. I'm getting < as other
representation like glt;



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Include-signed-XML-into-a-single-CDATA-tp5772863p5772894.html
Sent from the cxf-user mailing list archive at Nabble.com.




--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/


Re: Include signed XML into a single CDATA

2016-09-20 Thread xavi.dive.kite
Sorry but scape characters are coded in my response. I'm getting < as other
representation like glt; 



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Include-signed-XML-into-a-single-CDATA-tp5772863p5772894.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Include signed XML into a single CDATA

2016-09-20 Thread xavi.dive.kite
Sounds good but now we are getting: 

  ![CDATA[?

X509Data>X509SubjectName>

and

EwJVWTErMCkGA1UECgwiQURNSU5JU1RSQUNJT04gTkFDSU9OQUwgREUgQ09SUkVPUzEfMB0GA1UE
CwwWU0VSVklDSU9TIEVMRUNUUk9OSUNPUzEdMBsGA1UEAwwUQ29ycmVvIFVydWd1YXlvIC0gQ0Ew
HhcNMTUxMTI3MTk0NzE4WhcNMTYxMTI3MTk0NzE4WjCBmzEmMCQGCSqGSIb3DQEJARYXdml0YW1p
bmljby4wNUBnbWFpbC5jb20xEzARBgNVBAoMClZJVEFNSU5JQ08xEzARBgNVBAgMCk1vbnRldmlk
ZW8xCzAJBgNVBAYTAlVZMRgwFgYDVQQFEw9SVUMyMTUyMTcxOTAwMTUxIDAeBgNVBAMMF1ZJTkFM
UyBJVkFOSUNIIExFT05BUkRPMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6LdZWhEJaqiFa
Zb1VG+o7aEckJT4hkFfTj1FqfBzbS/Ug4uXcESdmOahQPVCpJcG8jgW6HuCO1dlQ9P0Qwsxk+zjC
He+Bm4+lnFQfcn1ClMvkGJzAxE/HJbBXkr1WDpcDKVt4nhMjGYj5w77H1p2Fj3CXC0eMAlf9MpHD

Any idea?



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Include-signed-XML-into-a-single-CDATA-tp5772863p5772893.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Include signed XML into a single CDATA

2016-09-20 Thread Sergey Beryozkin

May be
if (useCData) {
super.writeCharacters(CDataOpen);
super.writeCharacters(text);
super.writeCharacters(CDataClose);
}else {
super.writeCharacters(text);
}

On 20/09/16 10:46, xavi.dive.kite wrote:

We are doing this:

FileConverter converter = new FileConverter();
data.setXmlData(converter.convertToXMLData(filePath));  

Where can I modify the behaviuor the writeCharacters? Because the call is
like:

if (useCData) {
super.writeCData(text);
}else {
super.writeCharacters(text);
}

BR



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Include-signed-XML-into-a-single-CDATA-tp5772863p5772888.html
Sent from the cxf-user mailing list archive at Nabble.com.




--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/


Re: Include signed XML into a single CDATA

2016-09-20 Thread xavi.dive.kite
FileConverter is like:

public class FileConverter {

public FileConverter() { }

public String convertToXMLData(String fileName) throws
FileNotFoundException, IOException {

BufferedReader br;
br = new BufferedReader(new FileReader(fileName));
int c;
StringBuilder response= new StringBuilder();

while ((c = br.read()) != -1) {
response.append( (char)c ) ;
}

String xmlData = response.toString();
//xmlData = xmlData.replace("\n", "").replace("\r",
"").replaceAll("[\\r\\n]+", "");

br.close();
return xmlData;
}
}

If I uncomment 

//xmlData = xmlData.replace("\n", "").replace("\r",
"").replaceAll("[\\r\\n]+", "");

works fine but breaks the XML signature (changes the signed XML)



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Include-signed-XML-into-a-single-CDATA-tp5772863p5772889.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Include signed XML into a single CDATA

2016-09-20 Thread xavi.dive.kite
We are doing this:

FileConverter converter = new FileConverter();
data.setXmlData(converter.convertToXMLData(filePath));  

Where can I modify the behaviuor the writeCharacters? Because the call is
like:

if (useCData) { 
super.writeCData(text);
}else { 
super.writeCharacters(text); 
} 

BR



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Include-signed-XML-into-a-single-CDATA-tp5772863p5772888.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Include signed XML into a single CDATA

2016-09-20 Thread Sergey Beryozkin
Hi, it might be something to do with writeCData vs writeCharacters, not 
really sure.
I guess the easiest way is, if you detect it should be CData, simply 
write CData decorations manually as part of writeCharacters


Sergey

EwJVWTErMCkGA1UECgwiQURNSU5JU1RSQUNJT04gTkFDSU9OQUwgREUgQ09SUkVPUzEfMB0GA1UE
CwwWU0VSVklDSU9TIEVMRUNUUk9OSUNPUzEdMBsGA1UEAwwUQ29ycmVvIFVydWd1YXlvIC0gQ0Ew
HhcNMTUxMTI3MTk0NzE4WhcNMTYxMTI3MTk0NzE4WjCBmzEmMCQGCSqGSIb3DQEJARYXdml0YW1p
bmljby4wNUBnbWFpbC5jb20xEzARBgNVBAoMClZJVEFNSU5JQ08xEzARBgNVBAgMCk1vbnRldmlk
ZW8xCzAJBgNVBAYTAlVZMRgwFgYDVQQFEw9SVUMyMTUyMTcxOTAwMTUxIDAeBgNVBAMMF1ZJTkFM
UyBJVkFOSUNIIExFT05BUkRPMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6LdZWhEJaqiFa
Zb1VG+o7aEckJT4hkFfTj1FqfBzbS/Ug4uXcESdmOahQPVCpJcG8jgW6HuCO1dlQ9P0Qwsxk+zjC
He+Bm4+lnFQfcn1ClMvkGJzAxE/HJbBXkr1WDpcDKVt4nhMjGYj5w77H1p2Fj3CXC0eMAlf9MpHD
gFy7pwIDAQABo4IBZjCCAWIwIgYDVR0RBBswGYEXdml0YW1pbmljby4wNUBnbWFpbC5jb20wDAYD[..]

And getting the output:

MIIFhDCCA2ygAwIBAgIQUR762xXMDeJWWLNGuZSuszANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQG

Re: Include signed XML into a single CDATA

2016-09-20 Thread xavi.dive.kite
Sergey,

I have debugged and there is only one call to
CDataXMLStreamWriter.writeCharacters(text). But, for example, in the text We
have the certificate used to sign the XML:

MIIFhDCCA2ygAwIBAgIQUR762xXMDeJWWLNGuZSuszANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQG
EwJVWTErMCkGA1UECgwiQURNSU5JU1RSQUNJT04gTkFDSU9OQUwgREUgQ09SUkVPUzEfMB0GA1UE
CwwWU0VSVklDSU9TIEVMRUNUUk9OSUNPUzEdMBsGA1UEAwwUQ29ycmVvIFVydWd1YXlvIC0gQ0Ew
HhcNMTUxMTI3MTk0NzE4WhcNMTYxMTI3MTk0NzE4WjCBmzEmMCQGCSqGSIb3DQEJARYXdml0YW1p
bmljby4wNUBnbWFpbC5jb20xEzARBgNVBAoMClZJVEFNSU5JQ08xEzARBgNVBAgMCk1vbnRldmlk
ZW8xCzAJBgNVBAYTAlVZMRgwFgYDVQQFEw9SVUMyMTUyMTcxOTAwMTUxIDAeBgNVBAMMF1ZJTkFM
UyBJVkFOSUNIIExFT05BUkRPMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6LdZWhEJaqiFa
Zb1VG+o7aEckJT4hkFfTj1FqfBzbS/Ug4uXcESdmOahQPVCpJcG8jgW6HuCO1dlQ9P0Qwsxk+zjC
He+Bm4+lnFQfcn1ClMvkGJzAxE/HJbBXkr1WDpcDKVt4nhMjGYj5w77H1p2Fj3CXC0eMAlf9MpHD
gFy7pwIDAQABo4IBZjCCAWIwIgYDVR0RBBswGYEXdml0YW1pbmljby4wNUBnbWFpbC5jb20wDAYD[..]

And getting the output:

MIIFhDCCA2ygAwIBAgIQUR762xXMDeJWWLNGuZSuszANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQG

Re: Include signed XML into a single CDATA

2016-09-20 Thread xavi.dive.kite
HI Sergey,

How can do that? I'm not able to do it.

BR



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Include-signed-XML-into-a-single-CDATA-tp5772863p5772881.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Include signed XML into a single CDATA

2016-09-19 Thread Sergey Beryozkin

Hi

What may be happening is that you have a sequence of writeCharacters 
events - you may need to buffer them and flush as a single CData block 
upon receiving the endofelement event, something like that


Cheers, Sergey
On 19/09/16 15:27, xavi.dive.kite wrote:

I'm consuming a web service using CXF, the thing is that I need to send and
XML inside a CDATA tag. To do it I created an interceptor

public class CDATAInterceptor extends AbstractPhaseInterceptor
{

public CDATAInterceptor() {
super(Phase.MARSHAL);
//addAfter(AttachmentOutInterceptor.class.getName());
}

@Override
public void handleMessage(Message message) {
message.put("disable.outputstream.optimization", Boolean.TRUE);
XMLStreamWriter writer = (XMLStreamWriter)
message.getContent(XMLStreamWriter.class);
if (writer != null && !(writer instanceof CDataXMLStreamWriter)) {
message.setContent(XMLStreamWriter.class, new
CDataXMLStreamWriter(writer));
}
}

public void handleFault(Message messageParam) {
System.out.println(messageParam);
}
}
I am using a custom CDATAXMLStreamWriter defined as follows:

public class CDataXMLStreamWriter extends DelegatingXMLStreamWriter {

private static final Pattern XML_CHARS = Pattern.compile( "[&<>]" );

public CDataXMLStreamWriter(XMLStreamWriter del) {
super(del);
}

@Override
public void writeCharacters(String text) throws XMLStreamException {
boolean useCData = XML_CHARS.matcher( text ).find();
if (useCData) {
super.writeCData(text);
}else {
super.writeCharacters(text);
}
}

public void writeStartElement(String local) throws XMLStreamException {
super.writeStartElement(local);
}
}
I configured this CDATA interceptor as follows

protected void configureCDataInterceptor() {
CDATAInterceptor inter = new CDATAInterceptor();
ClientProxy.getClient(this.clientProxy).getOutInterceptors().add(inter);
}
The issue I have is that the xml inside CDATA is splitted in multiple parts,
somthing like this


I tried getting the XML and removing all the newline characters and the XML
gets inside one CDATA block, but the issue with this is that this XML is
signed, and removing the characters breaks the signature.

I hope this was clear enough, and sorry if the post is hard to understand.
If you can give me one clue to solve this problem it would be great!

Thanks,



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Include-signed-XML-into-a-single-CDATA-tp5772863.html
Sent from the cxf-user mailing list archive at Nabble.com.




--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/


Include signed XML into a single CDATA

2016-09-19 Thread xavi.dive.kite
I'm consuming a web service using CXF, the thing is that I need to send and
XML inside a CDATA tag. To do it I created an interceptor

public class CDATAInterceptor extends AbstractPhaseInterceptor 
  
{

public CDATAInterceptor() {
super(Phase.MARSHAL);
//addAfter(AttachmentOutInterceptor.class.getName());
}

@Override
public void handleMessage(Message message) {
message.put("disable.outputstream.optimization", Boolean.TRUE);
XMLStreamWriter writer = (XMLStreamWriter)
message.getContent(XMLStreamWriter.class);
if (writer != null && !(writer instanceof CDataXMLStreamWriter)) {
message.setContent(XMLStreamWriter.class, new
CDataXMLStreamWriter(writer));
}
}

public void handleFault(Message messageParam) {
System.out.println(messageParam);
}
}
I am using a custom CDATAXMLStreamWriter defined as follows:

public class CDataXMLStreamWriter extends DelegatingXMLStreamWriter {

private static final Pattern XML_CHARS = Pattern.compile( "[&<>]" );

public CDataXMLStreamWriter(XMLStreamWriter del) { 
super(del);
} 

@Override 
public void writeCharacters(String text) throws XMLStreamException { 
boolean useCData = XML_CHARS.matcher( text ).find();
if (useCData) { 
super.writeCData(text);
}else { 
super.writeCharacters(text); 
} 
}

public void writeStartElement(String local) throws XMLStreamException { 
super.writeStartElement(local); 
} 
}
I configured this CDATA interceptor as follows

protected void configureCDataInterceptor() {
CDATAInterceptor inter = new CDATAInterceptor();
ClientProxy.getClient(this.clientProxy).getOutInterceptors().add(inter);
}
The issue I have is that the xml inside CDATA is splitted in multiple parts,
somthing like this


I tried getting the XML and removing all the newline characters and the XML
gets inside one CDATA block, but the issue with this is that this XML is
signed, and removing the characters breaks the signature.

I hope this was clear enough, and sorry if the post is hard to understand.
If you can give me one clue to solve this problem it would be great!

Thanks, 



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Include-signed-XML-into-a-single-CDATA-tp5772863.html
Sent from the cxf-user mailing list archive at Nabble.com.