summaryrefslogtreecommitdiff
path: root/scripts/get-metadata.sh
diff options
context:
space:
mode:
authorBjörn Mattsson <bjorn@sunet.se>2023-03-06 11:22:05 +0100
committerBjörn Mattsson <bjorn@sunet.se>2023-03-06 11:22:05 +0100
commit467dbdbf3d7212e25ee69daeaadd8adba7c7c5b8 (patch)
treed3576d5f2d4b5cc676c0a12ef8f8c3c83b474bf5 /scripts/get-metadata.sh
parentbc1d55080e5d42e6ef2bba892d640aa8f68bbc90 (diff)
Moved files to make ths repo signed
Diffstat (limited to 'scripts/get-metadata.sh')
-rwxr-xr-xscripts/get-metadata.sh111
1 files changed, 0 insertions, 111 deletions
diff --git a/scripts/get-metadata.sh b/scripts/get-metadata.sh
deleted file mode 100755
index 16379681..00000000
--- a/scripts/get-metadata.sh
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/bin/bash
-#
-# Fetch Service Provider metadata and save into entityid filename
-#
-
-error()
-{
- echo "Error: $*" 1>&2
- exit 1
-}
-
-metadataurl=$1
-if [ -z "$metadataurl" ] ; then
- cat <<EOF
-Usage: `basename $0` <metadataurl>
-Ex: `basename $0` https://shibsp.mysite.com/Shibboleth.sso/Metadata
- `basename $0` https://shibidp.mysite.com/idp/profile/Metadata/SAML
- `basename $0` some-downloaded-metadata.xml
- `basename $0` reep:<entityid>
- `basename $0` <hostname> (tries to pull from standard locations)
-EOF
- exit 1
-fi
-
-xmldir=swamid-2.0
-update_xml=true
-if echo "$metadataurl" | grep -qE '^http://|^https://' ; then
- metadata=`curl -L -s -k -f "$metadataurl"`
-elif echo "$metadataurl" | grep -qE '^reep:' ; then
- id=`echo -n "$metadataurl" | sed 's/^reep://' | sha1sum | awk '{print $1}'`
- metadataurl="http://md.reep.refeds.org/entities/%7Bsha1%7D$id"
- metadata=`curl -L -s -k -f "$metadataurl"`
-else
- if [ -s "${metadataurl}" ]; then
- metadata=`cat "$metadataurl"`
- 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
- ;;
- http*)
- urls="$metadataurl"
- ;;
- *)
- urls="https://${metadataurl}/idp/shibboleth https://${metadataurl}/Shibboleth.sso/Metadata https://${metadataurl}/saml/index/sp-metadata https://${metadataurl}/saml/metadata https://${metadataurl}/federationmetadata/2007-06/federationmetadata.xml"
- ;;
- esac
- for i in ${urls}; do
- metadata=`curl -L -m 5 -s -k -f "${i}"`
- [ -n "${metadata}" ] && break
- done
- fi
-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`"
-
-entityidfn=`echo "$entityid" | sed 's;.*://;;' | sed 's/[^a-zwA-ZW0-9_.-]/-/g' | sed 's/$/.xml/'`
-[ -n "$entityidfn" ] || error "Failed to generate filename from entityid $entityid"
-OLDFILE=$(find ../swamid-testing ../swamid-2.0 ../swamid-edugain -name $entityidfn | grep -v $xmldir)
-if [ -n "$OLDFILE" ]; then
- echo "Moving $OLDFILE into $xmldir"
- git mv $OLDFILE $entityidfn
-fi
-[ -r "$entityidfn" ] && new=false || new=true
-if $new ; then
- echo -n "Save metadata into $entityidfn [Y/n]? "
-else
- regdate=$(sed -n 's;.*RegistrationInfo.*registrationInstant="\([^"]*\)".*;\1;p' < "$entityidfn" | head -n 1)
- echo -n "Replace $entityidfn with metadata [Y/n]? "
-fi
-[ -n "$regdate" ] || regdate=$(perl $script_cwd/../scripts/now_date.pl)
-
-read x
-case $x in
- Y|y|"")
- echo "$metadata" > $entityidfn
- tmp=`mktemp`
- if $update_xml ; then
- xsltproc --stringparam regDate "$regdate" $script_cwd/../xslt/add-rpi.xsl ${entityidfn} > ${tmp} && mv ${tmp} ${entityidfn}
- fi
- xsltproc $script_cwd/../xslt/clean-entitydescriptor.xsl ${entityidfn} > ${tmp} && mv ${tmp} ${entityidfn}
-
- if $new ; then
- echo -n "Add ${xmldir}/$entityidfn to git [Y/n]? "
- read x
- case $x in
- Y|y|"")
- git add $entityidfn
- ;;
- *)
- echo "Not added"
- ;;
- esac
- fi
- ;;
- *)
- echo "Nothing done"
- ;;
-esac