KeyDescriptor.getKeyInfo() always returns null

Huy Banh huy.banh at userful.com
Fri Dec 13 18:21:33 EST 2019


Thank you Brent.
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.

Merry Christmas and happy new year.

On Mon, Dec 9, 2019 at 9:11 PM Brent Putman <putmanb at georgetown.edu> wrote:

>
> On 12/9/19 10:05 AM, Huy Banh wrote:
>
>  am using OpenSaml in a SP project. I want to get IdP metadata, using
> the following code snipet:
>
> 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.
>
> 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.
>
>
> final BasicParserPool pool = new BasicParserPool();
> pool.initialize();
>
> final String idpUrl = "https://samltest.id/saml/idp" <https://samltest.id/saml/idp>;
> 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?
>
> 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:
>
> Key info: org.opensaml.xmlsec.signature.impl.KeyInfoImpl at dcfda20
> Key info: org.opensaml.xmlsec.signature.impl.KeyInfoImpl at 6d304f9d
> Key info: org.opensaml.xmlsec.signature.impl.KeyInfoImpl at f73dcd6
>
> Make sure that before any of that code, you call
> InitializationService.initialize().
>
> 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.
>
> --
> To unsubscribe from this list send an email to
> dev-unsubscribe at shibboleth.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/dev/attachments/20191213/1bfa656b/attachment.html>


More information about the dev mailing list