Skip to content

Commit

Permalink
Check that ukfedlabel elements appear at most once per entity
Browse files Browse the repository at this point in the history
Resolves ukf/ukf-meta#42.
  • Loading branch information
iay committed Apr 11, 2017
1 parent 723c01f commit 7bfc57b
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 12 deletions.
2 changes: 2 additions & 0 deletions mdx/uk/beans.xml
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@

<ref bean="checkSchemas"/>
<ref bean="CHECK_std"/>
<bean id="check_ukfedlabel" parent="XSLValidationStage"
p:XSLResource="classpath:uk/check_ukfedlabel.xsl"/>
<ref bean="check_ukreg"/>
<ref bean="check_owner"/>
<ref bean="check_uk_keydesc_key"/>
Expand Down
74 changes: 74 additions & 0 deletions mdx/uk/check_ukfedlabel.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
check_ukfedlabel.xsl
Checking ruleset for the ukfedlabel namespace.
-->
<xsl:stylesheet version="1.0"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:ukfedlabel="http://ukfederation.org.uk/2006/11/label"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns="urn:oasis:names:tc:SAML:2.0:metadata">

<!--
Common support functions.
-->
<xsl:import href="../_rules/check_framework.xsl"/>


<!--
Check for individual elements appearing more than once in
a single entity.
-->
<xsl:template match="md:EntityDescriptor[count(descendant::ukfedlabel:AccountableUsers)>1]">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:text>entity must not have more than one ukfedlabel:AccountableUsers element</xsl:text>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="md:EntityDescriptor[count(descendant::ukfedlabel:ExportOptIn)>1]">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:text>entity must not have more than one ukfedlabel:ExportOptIn element</xsl:text>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="md:EntityDescriptor[count(descendant::ukfedlabel:ExportOptOut)>1]">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:text>entity must not have more than one ukfedlabel:ExportOptOut element</xsl:text>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="md:EntityDescriptor[count(descendant::ukfedlabel:Software)>1]">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:text>entity must not have more than one ukfedlabel:Software element</xsl:text>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="md:EntityDescriptor[count(descendant::ukfedlabel:UKFederationMember)>1]">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:text>entity must not have more than one ukfedlabel:UKFederationMember element</xsl:text>
</xsl:with-param>
</xsl:call-template>
</xsl:template>


<!--
Check for entities which are both opted in to and opted out from export.
-->
<xsl:template match="md:EntityDescriptor/md:Extensions[ukfedlabel:ExportOptIn][ukfedlabel:ExportOptOut]">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:text>entity cannot be both opted in to and opted out from export</xsl:text>
</xsl:with-param>
</xsl:call-template>
</xsl:template>

</xsl:stylesheet>
12 changes: 0 additions & 12 deletions mdx/uk/check_ukreg.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,4 @@
</xsl:call-template>
</xsl:template>


<!--
Check for entities which are both opted in to and opted out from export.
-->
<xsl:template match="md:EntityDescriptor/md:Extensions[ukfedlabel:ExportOptIn][ukfedlabel:ExportOptOut]">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:text>entity cannot be both opted in to and opted out from export</xsl:text>
</xsl:with-param>
</xsl:call-template>
</xsl:template>

</xsl:stylesheet>

0 comments on commit 7bfc57b

Please sign in to comment.