<div dir="ltr">Thank you Brent.<div>I am busy with another task and can't get back to this until the end of the holiday. I will update again if any progress.</div><div><br></div><div>Merry Christmas and happy new year.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Dec 9, 2019 at 9:11 PM Brent Putman <<a href="mailto:putmanb@georgetown.edu">putmanb@georgetown.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p><br>
</p>
<div>On 12/9/19 10:05 AM, Huy Banh wrote:<br>
</div>
<blockquote type="cite">
<pre> am using OpenSaml in a SP project. I want to get IdP metadata, using
the following code snipet:</pre>
</blockquote>
<p>Well, that's not really the best way to obtain and use SAML
Metadata. We have first order support working with metadata via
various implementations of the MetadataResolver interface.</p>
<p>And we also have specific support for working with keys and other
key material from Metadata using the metadata-based impl of
CredentialResolver, called MetadataCredentialResolver.</p>
<p><br>
</p>
<blockquote type="cite">
<pre>final BasicParserPool pool = new BasicParserPool();
pool.initialize();
final String idpUrl = <a href="https://samltest.id/saml/idp" target="_blank">"https://samltest.id/saml/idp"</a>;
final XMLObject xml = XMLObjectSupport.unmarshallFromInputStream(pool,
new URL(idpUrl).openStream());
final IDPSSODescriptor singleSignonDesc = ((EntityDescriptor)
xml).getIDPSSODescriptor(SAMLConstants.SAML20P_NS);
singleSignonDesc
.getKeyDescriptors()
.forEach(k -> System.out.println("Key info: " + k.getKeyInfo()));
All data is retrieved properly, except KeyDescriptor.getKeyInfo(). It
always returns null. Of course there is a key for each in metadata.
Would someone help me?</pre>
</blockquote>
<p>Despite being sub-optimal, I don't see anything wrong with your
code in terms of doing what it purports to do. And it seems to run
correctly for me without modification. It parses and sees all 3
KeyDescriptors' KeyInfo instances. Output is:</p>
<p>Key info: org.opensaml.xmlsec.signature.impl.KeyInfoImpl@dcfda20<br>
Key info: org.opensaml.xmlsec.signature.impl.KeyInfoImpl@6d304f9d<br>
Key info: org.opensaml.xmlsec.signature.impl.KeyInfoImpl@f73dcd6</p>
<p>Make sure that before any of that code, you call
InitializationService.initialize().<br>
</p>
<p>If that's not it, then I think your issue is something
environmental and specific to you. You might turn on DEBUG
logging at various categories and see what it's actually doing.<br>
</p>
<br>
</div>
-- <br>
To unsubscribe from this list send an email to <a href="mailto:dev-unsubscribe@shibboleth.net" target="_blank">dev-unsubscribe@shibboleth.net</a></blockquote></div>