Skip to Content.
Sympa Menu

mace-opensaml-users - Re: [OpenSAML] OpenSAML 2.0 custom data type help

Subject: OpenSAML user discussion

List archive

Re: [OpenSAML] OpenSAML 2.0 custom data type help


Chronological Thread 
  • From: Brent Putman <>
  • To:
  • Subject: Re: [OpenSAML] OpenSAML 2.0 custom data type help
  • Date: Mon, 09 Feb 2009 15:52:42 -0500



Neill Miller wrote:
> Hello,
>
> To make the question more clear (hopefully), how about this:
>
> https://spaces.internet2.edu/display/OpenSAML/OSTwoUsrManJavaAnyTypes#OSTwoUsrManJavaAnyTypes-AttributeValues
>
> This page has a code snippet that properly builds the AttributeValue
> element inside of the Attribute tag. This example works great for me, but
> now I'm creating my own type instead of an XSString.
>
> So I want to do something like this instead:
>
> -------------------------
> Attribute attribute;
> XSMyTypeBuilder = (XSMyTypeBuilder)
> Configuration.getBuilderFactory().getBuilder(XSMyType.TYPE_NAME);
>
> // build custom type for method 1 (below): NOTE this way avoids the
> xsi:type emission
> XSMyType myTypeValue =
> myTypeBuilder.buildObject("http://www.myns.org","myType","myns";);
> // OR
> // build custom type for method 2 (below)
> XSMyType myTypeValue =
> myTypeBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME,
> XSMyType.TYPE_NAME);
>
> myTypeValue.setParam1("foo");
> myTypeValue.setParam2("bar");
> attribute.getAttributeValues().add(myTypeValue);
> -------------------------
>

Partially where you're getting tripped up I think is that you are
overloading what you are calling QName "myns:myType". It can' be both a
type and an element.

If I may use different names: you have a type that you want to
represent as the AttributeValue that is "myns:FooType". That content
model is a complex type that contains (based on what you've illustrated)
a child element, let us call it "myns:Bar". That Bar element has a
content model that contains 2 attributes "param1" and "param2".

So you need 2 XMLObject provider sets, one that implements the
myns:FooType content model, the other which implements the myns:Bar
content model.

And then in your runtime code, you create a a FooType instance, that
has the element name of "AttributeValue" (based on how you call the
builder), and then a Bar instance, and set Bar as a child of the
FooType/AttributeValue.

Make sense?

--Brent






Archive powered by MHonArc 2.6.16.

Top of Page