diff options
author | Fredrik Åslund <fredrik.aslund@umu.se> | 2013-06-18 13:21:55 +0200 |
---|---|---|
committer | Fredrik Åslund <fredrik.aslund@umu.se> | 2013-06-18 13:21:55 +0200 |
commit | 422767de1f2c1a9d585d35d43c6f71ac4c4876a0 (patch) | |
tree | 802ff0aad2e5ff8774fe57a7a780e7d2e1d6b221 /scripts | |
parent | 304aa12af4073bfcb680d710d77b4d8815cc5c86 (diff) |
get-shib-md.sh renamed to get-sp-md.sh
tuned to handle any sp with public metadata
set filename from entityid
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/get-shib-md.sh | 3 | ||||
-rwxr-xr-x | scripts/get-sp-md.sh | 42 |
2 files changed, 42 insertions, 3 deletions
diff --git a/scripts/get-shib-md.sh b/scripts/get-shib-md.sh deleted file mode 100755 index b29bd2dd..00000000 --- a/scripts/get-shib-md.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -wget --no-check-certificate -O$1.xml https://$1/Shibboleth.sso/Metadata diff --git a/scripts/get-sp-md.sh b/scripts/get-sp-md.sh new file mode 100755 index 00000000..4926c010 --- /dev/null +++ b/scripts/get-sp-md.sh @@ -0,0 +1,42 @@ +#!/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://www.mysp.com/Shibboleth.sso/Metadata +EOF + exit 1 +fi + +metadata=`curl -s -k -f $metadataurl` +[ -n "$metadata" ] || error "Failed to fetch metadata from $metadataurl" + +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;https*://;;' | tr 'A-Z' 'a-z' | sed 's;/$;;' | sed 's/[^a-z0-9_.-]/-/g' | sed 's/\.xml$//;s/$/.xml/'` +[ -n "$entityidfn" ] || error "Failed to generate filename from entityid $entityid" + +echo -n "Save metadata into $entityidfn [Y/n]? " +read x +case $x in + Y|y|"") + echo "$metadata" > $entityidfn + echo $entityidfn + ;; + *) + echo "Nothing done" + ;; +esac + |