• If your xmllint supports XPath (it should), I would do something like xmllint --xpath 'string(/*[local-name()="EntityDescriptor" and namespace-uri()="urn:oasis:names:tc:SAML:2.0:metadata"]/@entityID)' $@ to get the entityID rather than xmllint --format, grep, and sed.

  • I've replaced xmllint, grep and sed with xmlstarlet, leaving the previous use of line-based processing tools as a comment in line 20, for use on old systems.

    Edited by peter
  • Note that the invocation of xmlstarlet above will only work if the XML documents have set the SAML 2.0 Metadata URI as default namespace, which I ensure by curating the XML carefully:

    <EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" ...

    Otherwise the XPath used by xmlstarlet would have to be changed to match whatever is the XML namespace prefix used within the metadata document, such as md: (shown below) or ns0: or whatever:

    -    $(eval ENTITY = $(shell xmlstarlet sel -t -v '//_:EntityDescriptor/@entityID' -n $@)) 
    +    $(eval ENTITY = $(shell xmlstarlet sel -t -v '//md:EntityDescriptor/@entityID' -n $@)) 

    OTOH the example invocation for xmllint provided by @icb should work in all cases, default namespace or not.

    Edited by peter
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment