<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";
        color:black;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:windowtext">Brent –<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:windowtext">Thanx for the thorough response, I appreciate it!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:windowtext"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:windowtext">Stephen W. Chappell<o:p></o:p></span></b></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:windowtext"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext"> dev [mailto:dev-bounces@shibboleth.net]
<b>On Behalf Of </b>Brent Putman<br>
<b>Sent:</b> Thursday, June 11, 2015 1:39 PM<br>
<b>To:</b> dev@shibboleth.net<br>
<b>Subject:</b> Re: KeyInfoBuilder in OpenSAML 3<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<br>
<br>
<br>
<br>
<br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre>Well that makes sense I think. So, more like this then?<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>XMLObjectBuilder<?> kiBuilder = <o:p></o:p></pre>
<pre>builderFactory.getBuilder(KeyInfo.DEFAULT_ELEMENT_NAME);<o:p></o:p></pre>
<pre>ki = (KeyInfo) kiBuilder.buildObject(KeyInfo.DEFAULT_ELEMENT_NAME);<o:p></o:p></pre>
</blockquote>
<pre><o:p> </o:p></pre>
<pre>Yes, or cast to the SAMLObjectBuilder specialization, but same difference.<o:p></o:p></pre>
<p class="MsoNormal"><br>
<br>
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.<br>
<br>
So the real answer to your original question is either:<br>
<br>
1) cast the builder you get to XMLObjectBuilder<KeyInfo>.  Then you have to call buildObject(KeyInfo.DEFAULT_ELEMENT_NAME).<br>
<br>
2) cast the builder to XMLSignatureBuilder<KeyInfo>.  Then you can just call buildObject().<br>
<br>
<br>
<br>
<br>
<br>
<o:p></o:p></p>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre>But I wouldn't have thought that based on the example Brent referenced ...<o:p></o:p></pre>
</blockquote>
<pre><o:p> </o:p></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre>// Get the assertion builder based on the assertion element name<o:p></o:p></pre>
<pre>SAMLObjectBuilder<Assertion> builder = (SAMLObjectBuilder<Assertion>) <o:p></o:p></pre>
<pre>builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME);<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>// Create the assertion<o:p></o:p></pre>
<pre>Assertion assertion = builder.buildObject();<o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"><br>
<br>
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.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>