Skip to Content.
Sympa Menu

mace-opensaml-users - Re: AttributeValue creation

Subject: OpenSAML user discussion

List archive

Re: AttributeValue creation


Chronological Thread 
  • From: "Subash Devkota" <>
  • To: <>
  • Subject: Re: AttributeValue creation
  • Date: Fri, 02 Feb 2007 13:15:52 +0545
  • Importance: normal
  • Organization: D2Hawkeye
  • Priority: normal

Chad,
Thank you so much. :-)


Chad La Joie wrote:
Couple of items. First you get an XSString builder as follows:

buildFactory.getBuilder(XSString.TYPE_NAME);

Then you set the value using the XSString.setValue() method. So your code should look like this:

XMLObjectBuilder<XSString> builder = buildFactory.getBuilder(XSString.TYPE_NAME);

XSString attributeValue = builder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);

attributeValue.setValue("My Attribute Value");

Subash Devkota wrote:
Thank You Chad for your detail reply.

I created the AttributeValue Object but could not find the way for setting values in it.
I am sorry for bothering you again. But, I am new to openSAML and could not find any good document for the help. Could you please refer if any.

I created the AttribueValue using the code:
/XSStringBuilder xsStringBuilder= new XSStringBuilder();//) builderFactory.getBuilder(AttributeValue.DEFAULT_ELEMENT_NAME);
XMLObject attributeValue=xsStringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);/

It created the xml:

/<saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:type="xs:string"/>/

Then this attributeValue object does not have any method to set its value. It has only to set methods: setDOM() and setParent().

I don't think setting DOM is the good solution. Is there any way of adding the value to AttributeValue?

Thank You
Subash

Chad La Joie wrote:
No, you don't have to use the default provider (and probably shouldn't) in order to create attribute values. Instead you'd get the builder for whatever you want to use as an attribute value and build it using the element name AttributeValue. So, for example, lets say you wanted to have a value that is a string. Get the builder for the XSString object (our XMLObject that models the XML schema string type). Then, instead of using the normal buildObject method use one of the ones that takes both the element name AND the schema type, for example buildObject(QName, QName), passing in the AttributeValue qname for the first argument and the XSString type for the second.

This way, when the object is marshalled you end up with something like

<saml2:AttributeValue xsi:type="xs:string">
Some attribute value
</saml2:AttributeValue/>

Note that the proxy element only gets used if the library is unable to determine what the element actually contains. By specifying the schema type (string) the library would appropriately unmarshall the above snippet into an XSString XMLObject. If the type wasn't there it would have no way of knowing the type of the element and would fall back to the proxy.

Subash Devkota wrote:
Hi all,

I am using the latest java-saml2 codes from svn.

I want to build AttributeValue object and append it to Attribute. There is no AttributeValueBuilder.

https://spaces.internet2.edu/display/SHIB/OSTwoUsrManJavaLibIntro page under *Default Object Provider* section states that:

In most cases developer's wont encounter this XMLObject. However, it's common that this object will be used as the container for AttributeValue elements.


Scott and Chad,
Does it mean, we need to use this default object provider for creating AttributeValue object?
I tried it in the following manner.
In common-config.xml file, I found the entry
<BuilderClass className="org.opensaml.xml.ElementProxyBuilder" />
and tried to create the object using the code:

org.opensaml.xml.ElementProxyBuilder proxyBuilder= new org.opensaml.xml.ElementProxyBuilder();
AttributeValue attributeValue= (AttributeValue) proxyBuilder.buildObject(SAMLConstants.SAML20_NS, AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
But, I encounter the ClassCastException in second line.

How can I create AttributeValue object?

Thanks in advance
Subash

PRIVACY NOTICE

This email and any attachments may be confidential and/or privileged. Use of the information contained in this email by anyone other than the intended recipient is strictly prohibited. If you have received this email in error, please notify the sender by replying to this message and delete this email.




PRIVACY NOTICE

This email and any attachments may be confidential and/or privileged. Use of
the information contained in this email by anyone other than the intended
recipient is strictly prohibited. If you have received this email in error,
please notify the sender by replying to this message and delete this email.



Archive powered by MHonArc 2.6.16.

Top of Page