#!/bin/sh

## trying out different data param types

rm -rf *.der *.pem

creddy --generate --cn Alice
creddy --generate --cn Hatter
creddy --generate --cn MarchHare
creddy --generate --cn Dormouse
creddy --generate --cn Tea
creddy --generate --cn Party 

alice_keyid=`creddy --keyid --cert Alice_ID.pem`
party_keyid=`creddy --keyid --cert Party_ID.pem`
tea_keyid=`creddy --keyid --cert Tea_ID.pem`
hatter_keyid=`creddy --keyid --cert Hatter_ID.pem`
marchhare_keyid=`creddy --keyid --cert MarchHare_ID.pem`
dormouse_keyid=`creddy --keyid --cert Dormouse_ID.pem`

friendof_alice="friendOf([keyid:$alice_keyid])"
friendof_marchhare="friendOf([keyid:$marchhare_keyid])"
guestof_marchhare="guestOf([keyid:$marchhare_keyid])"

about_party="about([keyid:$tea_keyid],[time:20101010T],[boolean:true],[integer:4],[float:-200.0],[float:8],[time:20120205T182930],[string:'guest list'],[urn:'file://usr/local/party/~teaparty'])"

about_other_party="about_other_party([keyid:$tea_keyid],[?],[integer:99],[time:?AAA],[integer:?BBB],[boolean:true])"
about_time="about_time([time:20201101T])"
about_another_time="about_another_time([time:20201101T182930])"
about_key="about_key([keyid:$tea_keyid])"
about_boolean="about_boolean([boolean:true])"
about_integer="about_integer([integer:4])"
about_another_integer="about_another_integer([integer:-7])"
about_float="about_float([float:-200.0])"
about_another_float="about_another_float([float:8])"
about_third_float="about_another_float([float:0.22])"
about_urn="about_urn([urn:'file://user/local/party/~sillyparty'])"
about_string="about_string([string:'a confused party'])"
about_string2="about_string([string:'a mangled \'string\''])"


#[keyid:Party].role:about([keyid:tea],[time:201010],[string:'guest list'],[boolean:true],[integer:4]) <- [keyid:Party].role:guestOf([keyid:MarchHare])
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_party\" --subject-cert Party_ID.pem --subject-role  \"$guestof_marchhare\" --out party_about_party__guestof_marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_party" \
       --subject-cert Party_ID.pem --subject-role  "$guestof_marchhare" \
       --out party_about_party__guestof_marchhare_attr.der
#echo "  "
#echo "double checking with creddy --roles -certs party_about_party__guestof_marchhare_attr.der"
#creddy --roles --cert party_about_party__guestof_marchhare_attr.der

#[keyid:Party].role:about_other_party([keyid:$tea_keyid],[time:?],[boolean:true]) <- [keyid:MarchHare]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_other_party\" --subject-cert MarchHare_ID.pem --out party_about_other_party__marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_other_party" \
       --subject-cert MarchHare_ID.pem \
       --out party_about_other_party__marchhare_attr.der

#[keyid:Party].role:about_string([string:'a confused party']) <- [keyid:MarchHare]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_string\" --subject-cert MarchHare_ID.pem --out party_about_string__marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_string" \
       --subject-cert MarchHare_ID.pem \
       --out party_about_string__marchhare_attr.der

#[keyid:Party].role:about_string2([string:'a mangled \'string\'']) <- [keyid:MarchHare]
#echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_string2\" --subject-cert MarchHare_ID.pem --out party_about_string2__marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_string2" \
       --subject-cert MarchHare_ID.pem \
       --out party_about_string2__marchhare_attr.der

#[keyid:Party].role:about_urn([urn:'file://user/local/party/~sillyparty']) <- [keyid:MarchHare]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_urn\" --subject-cert MarchHare_ID.pem --out party_about_urn__marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_urn" \
       --subject-cert MarchHare_ID.pem \
       --out party_about_urn__marchhare_attr.der

#[keyid:Party].role:about_third_float([float:0.22]) <- [keyid:MarchHare]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_third_float\" --subject-cert MarchHare_ID.pem --out party_about_third_float__marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_third_float" \
       --subject-cert MarchHare_ID.pem \
       --out party_about_third_float__marchhare_attr.der

#[keyid:Party].role:about_another_float([float:8]) <- [keyid:MarchHare]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_another_float\" --subject-cert MarchHare_ID.pem --out party_about_another_float__marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_another_float" \
       --subject-cert MarchHare_ID.pem \
       --out party_about_another_float__marchhare_attr.der

#[keyid:Party].role:about_float([float:-200.0]) <- [keyid:MarchHare]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_float\" --subject-cert MarchHare_ID.pem --out party_about_float__marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_float" \
       --subject-cert MarchHare_ID.pem \
       --out party_about_float__marchhare_attr.der

#[keyid:Party].role:about_another_integer([integer:-7]) <- [keyid:MarchHare]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_another_integer\" --subject-cert MarchHare_ID.pem --out party_about_another_integer__marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_another_integer" \
       --subject-cert MarchHare_ID.pem \
       --out party_about_another_nteger__marchhare_attr.der

#[keyid:Party].role:about_integer([integer:4]) <- [keyid:MarchHare]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_integer\" --subject-cert MarchHare_ID.pem --out party_about_integer__marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_integer" \
       --subject-cert MarchHare_ID.pem \
       --out party_about_integer__marchhare_attr.der

#[keyid:Party].role:about_boolean([boolean:true]) <- [keyid:MarchHare]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_boolean\" --subject-cert MarchHare_ID.pem --out party_about_boolean__marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_boolean" \
       --subject-cert MarchHare_ID.pem \
       --out party_about_boolean__marchhare_attr.der

#[keyid:Party].role:about_key([keyid:$tea_keyid]) <- [keyid:MarchHare]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_key\" --subject-cert MarchHare_ID.pem --out party_about_key__marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_key" \
       --subject-cert MarchHare_ID.pem \
       --out party_about_key__marchhare_attr.der

#[keyid:Party].role:about_another_time([time:20201101T182930]) <- [keyid:MarchHare]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_another_time\" --subject-cert MarchHare_ID.pem --out party_about_another_time__marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_another_time" \
       --subject-cert MarchHare_ID.pem \
       --out party_about_another_time__marchhare_attr.der

#[keyid:Party].role:about_time([time:20201101T]) <- [keyid:MarchHare]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$about_time\" --subject-cert MarchHare_ID.pem --out party_about_time__marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$about_time" \
       --subject-cert MarchHare_ID.pem \
       --out party_about_time__marchhare_attr.der

#[keyid:Party].role:guestof([principal:?V]) <- [keyid:Party].role:friendOf([principal:?V])
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role 'guestOf([principal:?V])' --subject-cert Party_ID.pem --subject-role 'friendOf([principal:?V])' --out party_guestof_qV__party_friendof_qV_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role 'guestOf([principal:?V])' \
       --subject-cert Party_ID.pem --subject-role  'friendOf([principal:?V])' \
       --out party_guestof_qV__party_friendof_qV_attr.der

#[keyid:Party].role:guests <- [keyid:Party].role:friendOf([keyid:MarchHare])
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role guests --subject-cert Party_ID.pem --subject-role  \"$friendof_marchhare\" --out party_guests__party_friendof_marchhare_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role guests \
       --subject-cert Party_ID.pem --subject-role  "$friendof_marchhare" \
       --out party_guests__party_friendof_marchhare_attr.der

#[keyid:Party].role:friendOf([keyid:MarchHare]) <- [keyid:Dormouse]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$friendof_marchhare\" --subject-cert Dormouse_ID.pem --out party_friendof_marchhare__dormouse_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$friendof_marchhare" \
       --subject-cert Dormouse_ID.pem \
       --out party_friendof_marchhare__dormouse_attr.der

#[keyid:Party].role:friendOf([keyid:Alice]) <- [keyid:Hatter]
echo "creddy --attribute --issuer Party_ID.pem --key Party_private.pem --role \"$friendof_alice\" --subject-cert Hatter_ID.pem --out party_friendof_alice__hatter_attr.der"
creddy --attribute \
       --issuer Party_ID.pem --key Party_private.pem --role "$friendof_alice" \
       --subject-cert Hatter_ID.pem \
       --out party_friendof_alice__hatter_attr.der


