Skip to content

Instantly share code, notes, and snippets.

@jm2dev
Created September 4, 2012 23:36
Show Gist options
  • Save jm2dev/3628084 to your computer and use it in GitHub Desktop.
Save jm2dev/3628084 to your computer and use it in GitHub Desktop.
Extract EntityDescriptor from Shibboleth bulk metadata file and remove Extensions nodes
xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";
declare namespace a = "urn:oasis:names:tc:SAML:2.0:metadata";
<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi"
xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui"
xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Name="urn:mace:switch.ch:SWITCHaai"
validUntil="2012-09-09T19:59:01Z"
xsi:schemaLocation="urn:oasis:names:tc:SAML:2.0:metadata saml-schema-metadata-2.0.xsd urn:mace:shibboleth:metadata:1.0 shibboleth-metadata-1.0.xsd urn:oasis:names:tc:SAML:metadata:ui saml-metadata-ui-1.0.xsd http://www.w3.org/2000/09/xmldsig# xmldsig-core-schema.xsd">
{
let $id := "https://aai-login.fh-htwchur.ch/idp/shibboleth"
for $entity in doc()/a:EntitiesDescriptor/a:EntityDescriptor[@entityID = $id]
let $entityId := $entity/@entityID
let $idpssoDescriptor := $entity/IDPSSODescriptor/(@*, * except Extensions)
let $attributeAuthorityDescriptor := $entity/AttributeAuthorityDescriptor/(@*, * except Extensions)
return ($entityId, <IDPSSODescriptor>{$idpssoDescriptor}</IDPSSODescriptor>, <AttributeAuthorityDescriptor>{$attributeAuthorityDescriptor}</AttributeAuthorityDescriptor>)
}</EntityDescriptor>
@jm2dev
Copy link
Author

jm2dev commented Sep 4, 2012

$id should be an input parameter, like the classical bash $1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment