KeyInfoBuilder in OpenSAML 3
Brent Putman
putmanb at georgetown.edu
Thu Jun 11 13:38:49 EDT 2015
Sorry if I was mis-interpreting what you are originally doing. The
other thread poster was literally new()-ing a AuthnRequestBuilder() or
something, which is bad because as Scott said it's an implementation
class. Casting to KeyInfoBuilder is different, but still discouraged
for the same reasons.
>> Well that makes sense I think. So, more like this then?
>>
>> XMLObjectBuilder<?> kiBuilder =
>> builderFactory.getBuilder(KeyInfo.DEFAULT_ELEMENT_NAME);
>> ki = (KeyInfo) kiBuilder.buildObject(KeyInfo.DEFAULT_ELEMENT_NAME);
> Yes, or cast to the SAMLObjectBuilder specialization, but same difference.
Almost, but have to be careful. The stuff in opensaml-xmlsec-impl
doesn't know anything about SAML. So the builders don't implement
SAMLObjectBuilder. For example, the signature-oriented ones implement
XMLSignatureBuilder, the encryption ones are XMLEncryptionBuilder. What
those interfaces (along with SAMLObjectBuilder) add is the no-arg
buildObject() method. They're all sub-interfaces of XMLObjectBuilder,
which doesn't have such a method, only methods which take element and/or
type QNames (or the constituent inputs). There was a reason why Chad
designed things that way, although off-hand I don't remember.
So the real answer to your original question is either:
1) cast the builder you get to XMLObjectBuilder<KeyInfo>. Then you have
to call buildObject(KeyInfo.DEFAULT_ELEMENT_NAME).
2) cast the builder to XMLSignatureBuilder<KeyInfo>. Then you can just
call buildObject().
>
>> But I wouldn't have thought that based on the example Brent referenced ...
>> // Get the assertion builder based on the assertion element name
>> SAMLObjectBuilder<Assertion> builder = (SAMLObjectBuilder<Assertion>)
>> builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME);
>>
>> // Create the assertion
>> Assertion assertion = builder.buildObject();
Yeah, I guess those examples in the wiki docs are really targeting
SAMLObjects specifically. Per the above, they're not completely
accurate for the non-SAML schemas. The concepts are the same, just not
some of the specifics.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/dev/attachments/20150611/6cfb465b/attachment.html>
More information about the dev
mailing list