summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorBjörn Mattsson <bjorn@sunet.se>2022-11-18 13:54:15 +0100
committerBjörn Mattsson <bjorn@sunet.se>2022-11-18 13:54:15 +0100
commit7a91e93a308425e869fc6f28c3f317413eea2129 (patch)
treefca5d74793c1e074d6fa273c0be202c673b51e12 /scripts
parent65081e7eba296b4ba54a8ae6c9ce4dc9c206ea7e (diff)
Uppdated scripts to support new directorys
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/create_mxml.sh81
-rwxr-xr-xscripts/get-metadata.sh36
2 files changed, 90 insertions, 27 deletions
diff --git a/scripts/create_mxml.sh b/scripts/create_mxml.sh
new file mode 100755
index 00000000..f0fd139f
--- /dev/null
+++ b/scripts/create_mxml.sh
@@ -0,0 +1,81 @@
+#!/bin/bash
+# Creates MXML files to be used in signing of Metadata
+if ! test -d swamid-2.0 ; then
+ echo "Script should be run from base directory of swamid-metadata"
+ exit
+fi
+
+ls swamid-2.0/ swamid-testing/ swamid-edugain | egrep -v "/:|^$" | sort | uniq -c | awk '$1 > 1 {print $2, "exists in more than one feed"}'
+
+#
+# eduGAIN
+#
+cat << EOF > swamid-edugain-idp-1.0.mxml
+<?xml version="1.0" encoding="UTF-8"?>
+<md:EntitiesDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ Name="http://md.swamid.se/md/swamid-idp-2.0.xml">
+EOF
+grep -l IDPSSO swamid-edugain/*.xml | while read file; do
+ echo " <xi:include href=\"$file\"/>" >> swamid-edugain-idp-1.0.mxml
+done
+echo "</md:EntitiesDescriptor>" >> swamid-edugain-idp-1.0.mxml
+
+cat << EOF > swamid-edugain-sp-1.0.mxml
+<?xml version="1.0" encoding="UTF-8"?>
+<md:EntitiesDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:shibmeta="urn:mace:shibboleth:metadata:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:shibmd="urn:mace:shibboleth:metadata:1.0">
+EOF
+grep -l SPSSO swamid-edugain/*.xml | grep -v "`grep -l IDPSSO swamid-edugain/*.xml`" | while read file; do
+ echo " <xi:include href=\"$file\"/>" >> swamid-edugain-sp-1.0.mxml
+done
+echo "</md:EntitiesDescriptor>" >> swamid-edugain-sp-1.0.mxml
+
+#
+# Swamid-2.0
+#
+cat << EOF > swamid-idp-2.0.mxml
+<?xml version="1.0" encoding="UTF-8"?>
+<md:EntitiesDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ Name="http://md.swamid.se/md/swamid-idp-2.0.xml">
+ <xi:include href="swamid-edugain-idp-1.0.mxml" xpointer="xpointer(//*[@entityID])"/>
+
+ <!-- Opt-out from eduGAIN IDP:s -->
+EOF
+grep -l IDPSSO swamid-2.0/*.xml | while read file; do
+ echo " <xi:include href=\"$file\"/>" >> swamid-idp-2.0.mxml
+done
+echo "</md:EntitiesDescriptor>" >> swamid-idp-2.0.mxml
+
+cat << EOF > swamid-sp-2.0.mxml
+<?xml version="1.0" encoding="UTF-8"?>
+<md:EntitiesDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:shibmeta="urn:mace:shibboleth:metadata:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:shibmd="urn:mace:shibboleth:metadata:1.0">
+ <xi:include href="swamid-edugain-idp-1.0.mxml" xpointer="xpointer(//*[@entityID])"/>
+
+ <!-- Opt-out from eduGAIN SP:s -->
+EOF
+grep -l SPSSO swamid-2.0/*.xml | grep -v "`grep -l IDPSSO swamid-2.0/*.xml`" | while read file; do
+ echo " <xi:include href=\"$file\"/>" >> swamid-sp-2.0.mxml
+done
+echo "</md:EntitiesDescriptor>" >> swamid-sp-2.0.mxml
+
+#
+# Swamid-testing
+#
+cat << EOF > swamid-testing-idp-1.0.mxml
+<?xml version="1.0"?>
+<EntitiesDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:xi="http://www.w3.org/2001/XInclude" Name="http://md.swamid.se/md/swamid-testing-idp-1.0.xml">
+EOF
+egrep -l "AttributeAuthorityDescriptor|IDPSSODescriptor" swamid-testing/*.xml | while read file; do
+ echo " <xi:include href=\"$file\"/>" >> swamid-testing-idp-1.0.mxml
+done
+echo "</EntitiesDescriptor>" >> swamid-testing-idp-1.0.mxml
+
+cat << EOF > swamid-testing-sp-1.0.mxml
+<?xml version="1.0"?>
+<EntitiesDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:xi="http://www.w3.org/2001/XInclude" Name="http://md.swamid.se/md/swamid-testing-sp-1.0.xml">
+EOF
+grep -l SPSSO swamid-testing/*.xml | grep -v "`egrep -l "AttributeAuthorityDescriptor|IDPSSODescriptor" swamid-testing/*.xml`" | while read file; do
+ echo " <xi:include href=\"$file\"/>" >> swamid-testing-sp-1.0.mxml
+done
+echo "</EntitiesDescriptor>" >> swamid-testing-sp-1.0.mxml
diff --git a/scripts/get-metadata.sh b/scripts/get-metadata.sh
index c3be62a4..c26262ba 100755
--- a/scripts/get-metadata.sh
+++ b/scripts/get-metadata.sh
@@ -22,13 +22,7 @@ EOF
exit 1
fi
-script_cwd=`dirname "$0"`
-if test -d swamid-2.0 ; then
- echo "Moving into swamid-2.0/"
- cd swamid-2.0
- echo "$script_cwd" | grep -q ^/ || script_cwd=../$script_cwd
-fi
-
+xmldir=swamid-2.0
update_xml=true
if echo "$metadataurl" | grep -qE '^http://|^https://' ; then
metadata=`curl -L -s -k -f "$metadataurl"`
@@ -42,6 +36,7 @@ else
else
case $metadataurl in
[0-9][0-9]*)
+ xmldir=$(curl -L -m 5 -s -k -f "https://metadata.swamid.se/?show=feed&id=${metadataurl}")
urls="https://metadata.swamid.se/?rawXML=${metadataurl}"
update_xml=false
;;
@@ -60,6 +55,13 @@ else
fi
[ -n "$metadata" ] || error "Failed to fetch metadata from $metadataurl"
+script_cwd=`dirname "$0"`
+if test -d $xmldir ; then
+ echo "Moving into $xmldir/"
+ cd $xmldir
+ echo "$script_cwd" | grep -q ^/ || script_cwd=../$script_cwd
+fi
+
entityid=`echo "$metadata" | sed -n 's/.*entityID=['\''"]\([^"]*\)['\''"].*/\1/p'`
[ -n "$entityid" ] || error "Failed to find entityID in metadata"
[ `echo "$entityid" | wc -l` = 1 ] || error "Multiple entityid:s found: `echo $entityid`"
@@ -79,25 +81,6 @@ fi
read x
case $x in
Y|y|"")
- if $new ; then
- echo -n "Add swamid-2.0/$entityidfn to swamid-sp-2.0.mxml [Y/n]? "
- read x
- case $x in
- Y|y|"")
- sed -i.bak "s;^</md:EntitiesDescriptor>; <xi:include href=\"swamid-2.0/$entityidfn\"/>\n&;" ../swamid-sp-2.0.mxml
- if [ -f ../swamid-sp-2.0.mxml.bak ]; then
- rm ../swamid-sp-2.0.mxml.bak
- fi
- echo --
- tail -n 10 ../swamid-sp-2.0.mxml | sed 's/^/ /'
- echo --
- ;;
- *)
- echo "Not added"
- ;;
- esac
- fi
-
echo "$metadata" > $entityidfn
tmp=`mktemp`
if $update_xml ; then
@@ -122,4 +105,3 @@ case $x in
echo "Nothing done"
;;
esac
-