diff options
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | xslt/add-rpi.xsl | 57 | ||||
-rw-r--r-- | xslt/normalize.xsl | 2 |
3 files changed, 68 insertions, 2 deletions
@@ -102,6 +102,7 @@ clean: @rm -f *.xml *.tbs *.n *.sig tidy: + @for x in `find $(SRCDIRS) -name \*.xml`; do xsltproc xslt/add-rpi.xsl $$x > $$x.c && mv $$x.c $$x; done @for x in `find $(SRCDIRS) -name \*.xml`; do xsltproc xslt/clean-entitydescriptor.xsl $$x > $$x.c && mv $$x.c $$x; done testMetadataUsage: @@ -241,7 +242,15 @@ testAttributeInIdP: fi;\ done | grep . && exit 1 || exit 0 -test: syntaxtest testMDUI testOrgData testEntCat testSimpleSign testALlevel testEduGAINchecks testRefedsRnS testGeantCoCo testMetadataUsage testBadStrings testIdPinSP testRoleDescriptor testAttributeInIdP testValidContact +testRegistrationAuthority: + @echo "Check for registrationAuthority="http://www.swamid.se/" in EntityDescriptor/Extensions" + @for x in `find $(SRCDIRS) -name \*.xml`; do \ + if ! cat $$x | sed 's;\(</*\)[a-z0-9]*:;\1;g' | sed 's/xmlns="[^"]*"//' | xmllint --xpath "/EntityDescriptor/Extensions" - 2>/dev/null | grep -q 'registrationAuthority="http://www.swamid.se/"' ; then \ + echo " $$x" | sed 's/.*/[1;31m&[0m/' ;\ + fi;\ + done | grep . && exit 1 || exit 0 + +test: syntaxtest testMDUI testOrgData testEntCat testSimpleSign testALlevel testEduGAINchecks testRefedsRnS testGeantCoCo testMetadataUsage testBadStrings testIdPinSP testRoleDescriptor testAttributeInIdP testValidContact testRegistrationAuthority test2: $(SWAMIDXML) schematest testMDUI testOrgData testEntCat testSimpleSign testALlevel testEduGAINchecks testRefedsRnS testGeantCoCo testMetadataUsage testBadStrings testIdPinSP testRoleDescriptor testAttributeInIdP testValidContact diff --git a/xslt/add-rpi.xsl b/xslt/add-rpi.xsl new file mode 100644 index 00000000..b6686ff1 --- /dev/null +++ b/xslt/add-rpi.xsl @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet version="1.0" + xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:exsl="http://exslt.org/common" + xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi" + xmlns:alg="urn:oasis:names:tc:SAML:metadata:algsupport" + xmlns:ds="http://www.w3.org/2000/09/xmldsig#" + xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui" + extension-element-prefixes="exsl" + xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"> + + <xsl:output method="xml" indent="yes" encoding="UTF-8"/> + + <xsl:template match="md:EntityDescriptor"> + <md:EntityDescriptor> + <xsl:apply-templates select="@*"/> + <xsl:if test="not(md:Extensions)"> + <md:Extensions><xsl:call-template name="add-swamid-ri"/></md:Extensions> + </xsl:if> + <xsl:apply-templates select="text()|comment()|md:Extensions|md:RoleDescriptor|md:IDPSSODescriptor|md:SPSSODescriptor|md:AuthnAuthorityDescriptor|md:AttributeAuthorityDescriptor|md:PDPDescriptor|md:AffiliationDescriptor"/> + <xsl:apply-templates select="md:Organization"/> + <xsl:apply-templates select="md:ContactPerson"/> + <xsl:apply-templates select="md:AdditionalMetadataLocation"/> + </md:EntityDescriptor> + </xsl:template> + + <xsl:template match="md:EntityDescriptor/md:Extensions"> + <md:Extensions> + <xsl:call-template name="add-swamid-ri"/> + <xsl:apply-templates select="text()|comment()|node()"/> + </md:Extensions> + </xsl:template> + + <xsl:template name="add-swamid-ri"> + <xsl:if test="not(mdrpi:RegistrationInfo[@registrationAuthority])"> + <mdrpi:RegistrationInfo registrationAuthority="http://www.swamid.se/"> + <mdrpi:RegistrationPolicy xml:lang="en">https://www.sunet.se/wp-content/uploads/2016/08/SWAMID-Metadata-Registration-Practice-Statement-v2.pdf</mdrpi:RegistrationPolicy> + </mdrpi:RegistrationInfo> + </xsl:if> + </xsl:template> + + <xsl:template match="@xml:base|@ID|@validUntil|@cacheDuration"/> + + <xsl:template match="text()|comment()|@*"> + <xsl:copy/> + </xsl:template> + + <xsl:template match="*"> + <xsl:copy> + <xsl:apply-templates select="node()|@*"/> + </xsl:copy> + </xsl:template> + +</xsl:stylesheet> diff --git a/xslt/normalize.xsl b/xslt/normalize.xsl index 06550345..d407e18f 100644 --- a/xslt/normalize.xsl +++ b/xslt/normalize.xsl @@ -94,7 +94,7 @@ If You do not accept these Terms, then You must not continue to use this Metadat </xsl:template> <xsl:template name="add-swamid-ri"> - <xsl:if test="$rpi='true' and not(mdrpi:RegistrationInfo[@registrationAuthority='http://www.swamid.se/'])"> + <xsl:if test="$rpi='true' and not(mdrpi:RegistrationInfo[@registrationAuthority])"> <mdrpi:RegistrationInfo registrationAuthority="http://www.swamid.se/"> <mdrpi:RegistrationPolicy xml:lang="en">https://www.sunet.se/wp-content/uploads/2016/08/SWAMID-Metadata-Registration-Practice-Statement-v2.pdf</mdrpi:RegistrationPolicy> </mdrpi:RegistrationInfo> |