Hello!
some new information:
I try to create the XML fragment via DocumentBuilder:

                                    Element content =
doc.createElementNS(" .... ", "PurposeOfUse");
                                   
content.setAttributeNS("http://www.w3.org/2001/XMLSchema-instance";,
"Type", "CE");
                                    content.setAttributeNS("... <same as
element> ... ","Code",code);
                                   
                                   
                                    XMLObjectBuilderFactory builderFactory =
                                   
XMLObjectProviderRegistrySupport.getBuilderFactory();
                            @SuppressWarnings("unchecked")
                            XMLObjectBuilder<XSAny> xsAnyBuilder =
                               
(XMLObjectBuilder<XSAny>)builderFactory.getBuilder(XSAny.TYPE_NAME);
                            XSAny attributeValue =
                                   
xsAnyBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME);
                           
                            XSAny node = xsAnyBuilder.buildObject(content);
working, but at the response is none of the attributes

then I try to mix it:

                                  Element content =
doc.createElementNS(" .... ", "PurposeOfUse");
                                   
content.setAttributeNS("http://www.w3.org/2001/XMLSchema-instance";,
"Type", "CE");
                                    content.setAttributeNS("... <same as
element> ... ","Code",code);
                                   
                                   
                                    XMLObjectBuilderFactory builderFactory =
                                   
XMLObjectProviderRegistrySupport.getBuilderFactory();
                            @SuppressWarnings("unchecked")
                            XMLObjectBuilder<XSAny> xsAnyBuilder =
                               
(XMLObjectBuilder<XSAny>)builderFactory.getBuilder(XSAny.TYPE_NAME);
                            XSAny attributeValue =
                                   
xsAnyBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME);
                           
                            XSAny node = xsAnyBuilder.buildObject(content);

                            node.getUnknownAttributes().put(new
QName("... <same as element> ...","Code"),code);
                            node.getUnknownAttributes().put(new
QName("http://www.w3.org/2001/XMLSchema-instance","type","xsi";),"CE");

get the error.
If I try to add a prefix to the NameSpace for the QName, the same error.

somehow the
net.shibboleth.utilities.java.support.xml.NamespaceSupport.appendNamespaceDeclaration()
try
to mix the element's Namespace and the attribute's NameSpace, and
because its different I get the error.

any help is welcome
Thanx
Csaba


On 2018.01.29. 19:48, Tóth Csaba wrote:
> Hello!
> Thanx, but look like not helped:
>
>                                 XMLObjectBuilderFactory builderFactory =
>                                        
> XMLObjectProviderRegistrySupport.getBuilderFactory();
>                                 @SuppressWarnings("unchecked")
>                                 XMLObjectBuilder<XSAny> xsAnyBuilder =
>                                    
> (XMLObjectBuilder<XSAny>)builderFactory.getBuilder(XSAny.TYPE_NAME);
>                                 XSAny attributeValue =
>                                        
> xsAnyBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME);
>                                
>                                 XSAny node =
> xsAnyBuilder.buildObject(new QName("... namespace ... "," ... element
> name... "),new QName("http://www.w3.org/2001/XMLSchema-instance","CE";));
>                                
> attributeValue.getUnknownXMLObjects().add(node);
>                                
>                                 node.getUnknownAttributes().put(new
> QName(".. attr namespace...","Code"),code);
>                                 requestClaim.addValue(attributeValue);
>
> but I get an error for the building the SAML, that "Cannot replace an
> element's default namespace"
> Csaba
>
>
> On 2018.01.29. 17:59, Colm O hEigeartaigh wrote:
>> This WSS4J unit test might help you - it shows how to add a custom
>> Attribute:
>>
>> https://github.com/apache/wss4j/blob/94f0e42d03011fa97122bcd495d268ff33a5107f/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java#L578
>>
>> Colm.
>>
>> On Mon, Jan 29, 2018 at 3:42 PM, Tóth Csaba <[email protected]> wrote:
>>
>>> Hello!
>>>
>>> I need to put an XML fragment to one of the SAML Attribute:
>>>
>>> <saml-a:Attribute xmlns:saml-a="urn:oasis:names:tc:SAML:2.0:assertion"
>>> xmlns:wsa="http://www.w3.org/2005/08/addressing";>
>>> <saml-a:AttributeValue xmlns:xsi="http://www.w3.org/
>>> 2001/XMLSchema-instance">
>>>         <PurposeOfUse xmlns=" .... " xsi:type=" ... " attr1=" ... "
>>> attr2=" ... "/>
>>> </saml-a:AttributeValue>
>>> </saml-a:Attribute>
>>>
>>> (the xsi:type is not an standard schema type)
>>>
>>> I get this information from an Claim. I parse already, and I have all
>>> the fields. I need some solution how can I put to the requestClaim ant
>>> the ClaimParser
>>> I try to use the OpenSAML, to create a AttributeValue, but I dont know
>>> how to create the PurposeOfUse element.
>>>
>>> Any idee?
>>> Thanx
>>>
>>> Csaba
>>>
>>>
>>>
>>>
>

Reply via email to