#!/bin/sh

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

acme=`creddy --keyid --cert $keyloc/Acme_ID.pem`
alice=`creddy --keyid --cert $keyloc/Alice_ID.pem`
bob=`creddy --keyid --cert $keyloc/Bob_ID.pem`
globotron=`creddy --keyid --cert $keyloc/Globotron_ID.pem`

glob_admin="$globotron.admin"
alice_prin="$alice"
bob_prin="$bob"
experiment_create="$acme.experiment_create"

echo " "
echo "===good=============== Globotron.admin <- Alice"
$eloc/abac_prover  --keystore $keyloc \
             --role "$glob_admin" --principal "$alice_prin"

echo " "
echo "===bad=============== Globotron.admin <- Bob"
$eloc/abac_prover  --keystore $keyloc \
             --role "$glob_admin" --principal "$bob_prin"

echo " "
echo "===good=============== Acme.experiment_create <- Bob"
$eloc/abac_prover  --keystore $keyloc \
             --role "$experiment_create" --principal "$bob_prin"


