#!/bin/sh

#Acme.buy_rockets <- Acme.preferred_customer
#Acme.preferred_customer <- Coyote

rm -rf *.pem *.xml *.out

pwd=`pwd`
eloc=`which creddy | sed 's/\/creddy//'`
if [ "$eloc" = "" ]; then
  echo "ERROR: creddy is not in the search path!!!"
  exit 1
fi

$eloc/creddy --generate --cn Acme
$eloc/creddy --generate --cn Coyote

$eloc/creddy --attribute \
       --issuer Acme_ID.pem --key Acme_private.pem --role buy_rockets \
       --subject-cert Acme_ID.pem --subject-role preferred_customer \
       --out Acme_buy_rockets__Acme_preferred_customer_attr.xml

$eloc/creddy --attribute \
       --issuer Acme_ID.pem --key Acme_private.pem --role preferred_customer \
       --subject-cert Coyote_ID.pem \
       --out Acme_preferred_customer__Coyote_attr.xml

cp not_ss.pem_save not_ss.pem
cp not_ss.xml_save not_ss.xml
cp priv.xml_save priv.xml
cp PGissuer.pem_save PGissuer.pem
cp ProtoGENI.xml_save ProtoGENI.xml

