<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Hello All,</span><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">I am trying to work with CDATA and encryption in SAML 2.0 assertion and have run into an issue. Would really appreciate if somebody can help me.</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Issue - </div><div style="font-family:arial,sans-serif;font-size:13px"><div><br></div><div>I am trying to create a SAML assertion with CDATA in the attribute value (Example : &lt;saml2:Attribute Name=&quot;someAttribute&quot;&gt;&lt;saml2:AttributeValue&gt;&lt;![CDATA[&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;&lt;a&gt;xyz&lt;/a&gt;]]&gt;&lt;/saml2:AttributeValue&gt;&lt;/saml2:Attribute&gt;)</div><div><br></div><div>I tried various ways to create such an attribute, but found that the CDATA was being escaped (&gt;&amp;lt;![CDATA[&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&amp;gt; ..). </div><div><br></div><div>I could make CDATA not be escaped by OpenSAML when I created the attribute value like below -</div><div><br></div><div><div>XMLObjectBuilder builder = getSAMLBuilder().getBuilder(XSAny.TYPE_NAME);</div><div><br></div><div>XSAny attrValue = (XSAny) builder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSAny.TYPE_NAME);</div><div>            </div><div>Document doc = createEmptyDocument();</div><div>CDATASection cdataSection = doc.createCDATASection(cdataValue);</div><div><br></div><div>Element e = doc.createElement(&quot;saml2:AttributeValue&quot;);</div><div>//e.setAttribute(&quot;xmlns:xsi&quot;, &quot;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&quot;);</div><div>//e.setAttribute(&quot;xsi:type&quot;, &quot;xs:cdata&quot;);</div><div>doc.appendChild(e);</div><div>e.appendChild(cdataSection);</div><div>attrValue.setDOM(e);</div></div><div>attr.getAttributeValues().add(attrValue)</div><div><br></div><div>So, although the assertion with the attribute value above will have unescaped, correct attribute value, when I encrypt an assertion with this attribute value and decrypt the assertion, I find that the attribute value is escaped.</div><div><br></div><div>Does anybody know how to make this work? Am I setting the CDATA correctly? And can CDATA work with encrypting the assertion? Or should I make any changes to the encrypter so that the decrypted assertion has the correct attribute value?</div><div><br></div><div>Thanks!</div></div></div>