Skip to content

Commit

Permalink
Add MDUI statistics for mdx channels.
Browse files Browse the repository at this point in the history
This is currently based on the imported metadata, which may exclude entities which have been filtered out.  Needs to be reworked to operate on the raw aggregates.
  • Loading branch information
iay committed Jun 25, 2011
1 parent bb8ffbc commit c459bfa
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
41 changes: 41 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,30 @@
</sequential>
</macrodef>

<!--
Macro to run the Xalan XSLT engine, taking files from arbitrary
locations. No output specified, so the result of the transform
will be sent to standard output.
-->
<macrodef name="XALAN.noout">
<attribute name="i"/>
<attribute name="x"/>
<sequential>
<java fork="true" maxmemory="${java.max.memory}" failonerror="true" classname="org.apache.xalan.xslt.Process">
<classpath>
<fileset dir="${tools.xalan}/lib">
<include name="*.jar"/>
</fileset>
</classpath>
<jvmarg value="-Djava.endorsed.dirs=${tools.xalan}/endorsed"/>
<arg value="-IN"/>
<arg value="@{i}"/>
<arg value="-XSL"/>
<arg value="@{x}"/>
</java>
</sequential>
</macrodef>

<!--
Macro to run the Xalan XSLT engine, taking files from pre-defined
locations.
Expand Down Expand Up @@ -1187,6 +1211,23 @@
<echo>UK production aggregate flow completed.</echo>
</target>

<!--
*******************************
*** ***
*** M D U I S T A T S ***
*** ***
*******************************
-->

<target name="mdui.stats">
<input addproperty="channel">
Please select the channel to use (e.g., us_incommon):
</input>
<CHANNEL.import channel="${channel}"/>
<XALAN.noout i="${mdx.dir}/${channel}/imported.xml"
x="${build.dir}/statistics_mdui.xsl"/>
</target>

<!--
*******************************
*** ***
Expand Down
76 changes: 76 additions & 0 deletions build/statistics_mdui.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
statistics_mdui.xsl
XSL stylesheet taking a metadata aggregate and giving some statistics about MDUI
element use as textual output.
Author: Ian A. Young <ian@iay.org.uk>
-->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:math="http://exslt.org/math"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:dyn="http://exslt.org/dynamic"
xmlns:set="http://exslt.org/sets"
exclude-result-prefixes="xsl md mdui xsi math date dyn set"
version="1.0">

<xsl:output method="text" omit-xml-declaration="yes"/>

<xsl:template match="/md:EntitiesDescriptor">

<xsl:variable name="entities" select="//md:EntityDescriptor"/>
<xsl:variable name="entityCount" select="count($entities)"/>

<xsl:variable name="idps" select="$entities[md:IDPSSODescriptor]"/>
<xsl:variable name="idpCount" select="count($idps)"/>
<xsl:variable name="sps" select="$entities[md:SPSSODescriptor]"/>
<xsl:variable name="spCount" select="count($sps)"/>
<xsl:variable name="dualEntities" select="$entities[md:IDPSSODescriptor][md:SPSSODescriptor]"/>
<xsl:variable name="dualEntityCount" select="count($dualEntities)"/>

<xsl:text>Total entities: </xsl:text>
<xsl:value-of select="$entityCount"/>
<xsl:text>&#10;</xsl:text>

<xsl:variable name="uiInfoEntities" select="$entities[descendant::mdui:UIInfo]"/>
<xsl:variable name="uiInfoEntitiesCount" select="count($uiInfoEntities)"/>
<xsl:text> mdui:UIInfo: </xsl:text>
<xsl:value-of select="$uiInfoEntitiesCount"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="format-number($uiInfoEntitiesCount div $entityCount, '0.0%')"/>
<xsl:text>)&#10;</xsl:text>

<xsl:text>Identity providers: </xsl:text>
<xsl:value-of select="$idpCount"/>
<xsl:text>&#10;</xsl:text>

<xsl:variable name="idp.uiinfo" select="$idps[descendant::mdui:UIInfo]"/>
<xsl:variable name="idp.uiinfo.count" select="count($idp.uiinfo)"/>
<xsl:text> mdui:UIInfo: </xsl:text>
<xsl:value-of select="$idp.uiinfo.count"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="format-number($idp.uiinfo.count div $idpCount, '0.0%')"/>
<xsl:text>)&#10;</xsl:text>

<xsl:text>Service providers: </xsl:text>
<xsl:value-of select="$spCount"/>
<xsl:text>&#10;</xsl:text>

<xsl:variable name="sp.uiinfo" select="$sps[descendant::mdui:UIInfo]"/>
<xsl:variable name="sp.uiinfo.count" select="count($sp.uiinfo)"/>
<xsl:text> mdui:UIInfo: </xsl:text>
<xsl:value-of select="$sp.uiinfo.count"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="format-number($sp.uiinfo.count div $spCount, '0.0%')"/>
<xsl:text>)&#10;</xsl:text>

</xsl:template>

</xsl:stylesheet>

0 comments on commit c459bfa

Please sign in to comment.