[9335cfa] | 1 | #!/bin/sh |
---|
| 2 | |
---|
| 3 | ##################################################################### |
---|
| 4 | # This example demostrates how to use 'this' as a data term of a RT1 |
---|
| 5 | # policy credential where it is implicitly translated to a variable. |
---|
| 6 | # |
---|
| 7 | # Credential 1 is the policy credential with 2 intersecting rules. |
---|
| 8 | # A employee is up for a pay raise if the evaluator of the employee |
---|
| 9 | # affirms his/her good performance and the manager of the employee |
---|
| 10 | # affirms his/her pleasantness. |
---|
| 11 | # |
---|
| 12 | # Credential 2 is the policy credential that states an evaluator of |
---|
| 13 | # an employee is also the manager of the employee. |
---|
| 14 | # |
---|
| 15 | # Credential 3, 4 and 5 state Bob is the evaluator of Maryann and she |
---|
| 16 | # is showing good performance and is a nice coworker. Credential 6 and |
---|
| 17 | # 7 state Bob is also the evaluator of Joe and he is showing good |
---|
| 18 | # performance. But, there is no fact that says Joe is a nice coworker. |
---|
| 19 | # |
---|
| 20 | # The attached ./run_query file asks if a given principal is |
---|
| 21 | # entitled to a pay raise. Maryann is but not Joe, because his manager |
---|
| 22 | # did not affirm his pleasantness(but neither did he deny it) |
---|
| 23 | |
---|
[f824a9e] | 24 | # payraise_rt1 |
---|
[9335cfa] | 25 | |
---|
| 26 | # [keyid:Alpha].role:payRaise <-?- [keyid:Maryann] (yes) |
---|
| 27 | # [keyid:Alpha].role:payRaise <-?- [keyid:Joe] (no) |
---|
| 28 | |
---|
| 29 | creddy --generate --cn Alpha |
---|
| 30 | creddy --generate --cn Bob |
---|
| 31 | creddy --generate --cn Maryann |
---|
| 32 | creddy --generate --cn Joe |
---|
| 33 | |
---|
| 34 | alpha_keyid=`creddy --keyid --cert Alpha_ID.pem` |
---|
| 35 | |
---|
| 36 | bob_keyid=`creddy --keyid --cert Bob_ID.pem` |
---|
| 37 | maryann_keyid=`creddy --keyid --cert Maryann_ID.pem` |
---|
| 38 | joe_keyid=`creddy --keyid --cert Joe_ID.pem` |
---|
| 39 | |
---|
[2efdff5] | 40 | performance_qT="evaluatorOf([principal:?this])" |
---|
| 41 | niceguy_qT="managerOf([principal:?this])" |
---|
[9335cfa] | 42 | |
---|
| 43 | manager_qZ="managerOf([principal:?Z])" |
---|
| 44 | evaluator_qZ="evaluatorOf([principal:?Z])" |
---|
| 45 | |
---|
| 46 | evaluator_m="evaluatorOf([keyid:$maryann_keyid])" |
---|
| 47 | evaluator_j="evaluatorOf([keyid:$joe_keyid])" |
---|
| 48 | |
---|
| 49 | # [keyid:alpha].role:payRaise <- |
---|
| 50 | # [keyid:alpha].role:evaluatorOf([principal:?this]).role:goodPerformance & |
---|
| 51 | # [keyid:alpha].role:managerOf([principal:?this]).role:niceCoworker |
---|
| 52 | # Credential 1 |
---|
| 53 | creddy --attribute \ |
---|
| 54 | --issuer Alpha_ID.pem --key Alpha_private.pem --role payRaise \ |
---|
[2efdff5] | 55 | --subject-cert Alpha_ID.pem --subject-link "$performance_qT" \ |
---|
| 56 | --subject-role goodPerformance \ |
---|
| 57 | --subject-cert Alpha_ID.pem --subject-link "$niceguy_qT" \ |
---|
| 58 | --subject-role niceCoworker \ |
---|
[9335cfa] | 59 | --out Alpha_payraise__Alpha_performance_qT_niceguy_qT_attr.der |
---|
| 60 | |
---|
| 61 | # [keyid:alpha].role:managerOf([principal:?Z])<- |
---|
| 62 | # [keyid:alpha].role:evaluatorOf([principal:?Z]) |
---|
| 63 | # Credential 2 |
---|
| 64 | creddy --attribute \ |
---|
| 65 | --issuer Alpha_ID.pem --key Alpha_private.pem --role "$manager_qZ" \ |
---|
| 66 | --subject-cert Alpha_ID.pem --subject-role "$evaluator_qZ" \ |
---|
| 67 | --out Alpha_manager_qZ__Alpha_evaluator_qZ_attr.der |
---|
| 68 | |
---|
| 69 | # [keyid:alpha].role:evaluatorOf([keyid:Maryann]) <-[keyid:Bob] |
---|
| 70 | # Credential 3 |
---|
| 71 | creddy --attribute \ |
---|
| 72 | --issuer Alpha_ID.pem --key Alpha_private.pem --role "$evaluator_m" \ |
---|
| 73 | --subject-cert Bob_ID.pem \ |
---|
| 74 | --out Alpha_evaluator_m__Bob_attr.der |
---|
| 75 | |
---|
| 76 | # [keyid:Bob].role:goodPerformance <- [keyid:Maryann]) |
---|
| 77 | # Credential 4 |
---|
| 78 | creddy --attribute \ |
---|
| 79 | --issuer Bob_ID.pem --key Bob_private.pem --role goodPerformance \ |
---|
| 80 | --subject-cert Maryann_ID.pem \ |
---|
| 81 | --out Bob_goodperformance__Maryann_attr.der |
---|
| 82 | |
---|
| 83 | # [keyid:Bob].role:niceCoworker <- [keyid:Maryann]) |
---|
| 84 | # Credential 5 |
---|
| 85 | creddy --attribute \ |
---|
| 86 | --issuer Bob_ID.pem --key Bob_private.pem --role niceCoworker \ |
---|
| 87 | --subject-cert Maryann_ID.pem \ |
---|
| 88 | --out Bob_niceworker__Maryann_attr.der |
---|
| 89 | |
---|
| 90 | # [keyid:alpha].role:evaluatorOf([keyid:Joe]) <-[keyid:Bob] |
---|
| 91 | # Credential 6 |
---|
| 92 | creddy --attribute \ |
---|
| 93 | --issuer Alpha_ID.pem --key Alpha_private.pem --role "$evaluator_j" \ |
---|
| 94 | --subject-cert Bob_ID.pem \ |
---|
| 95 | --out Alpha_evaluator_j__Bob_attr.der |
---|
| 96 | |
---|
| 97 | # [keyid:Bob].role:goodPerformance <- [keyid:Joe]) |
---|
| 98 | # Credential 7 |
---|
| 99 | creddy --attribute \ |
---|
| 100 | --issuer Bob_ID.pem --key Bob_private.pem --role goodPerformance \ |
---|
| 101 | --subject-cert Joe_ID.pem \ |
---|
| 102 | --out Bob_goodperformance__Joe_attr.der |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | ##################################################################### |
---|
| 106 | # |
---|
| 107 | # alpha.payRaise <- alpha.evaluatorOf(this).goodPerformance & |
---|
| 108 | # alpha.managerOf(this).niceCoworker |
---|
| 109 | # [keyid:alpha].role:payRaise <- |
---|
| 110 | # [keyid:alpha].role:evaluatorOf([principal:?this]).role:goodPerformance & |
---|
| 111 | # [keyid:alpha].role:managerOf([principal:?this]).role:niceCoworker |
---|
| 112 | # |
---|
| 113 | # alpha.managerOf(this) <- alpha.evaluatorOf(this) |
---|
| 114 | # [keyid:alpha].role:managerOf([principal:?this])<- |
---|
| 115 | # [keyid:alpha].role:evaluatorOf([principal:?this]) |
---|
| 116 | # |
---|
| 117 | # alpha.evaluatorOf(Maryann)<-Bob |
---|
| 118 | # [keyid:alpha].role:evaluatorOf([keyid:Maryann]) <-[keyid:Bob] |
---|
| 119 | # Bob.goodPerformance<-Maryann |
---|
| 120 | # [keyid:Bob].role:goodPerformance <- [keyid:Maryann]) |
---|
| 121 | # Bob.niceCoworker<-Maryann |
---|
| 122 | # [keyid:Bob].role:niceCoworker <- [keyid:Maryann]) |
---|
| 123 | # |
---|
| 124 | # alpha.evaluatorOf(Joe)<-Bob |
---|
| 125 | # [keyid:alpha].role:evaluatorOf([keyid:Joe]) <-[keyid:Bob] |
---|
| 126 | # Bob.goodPerformance<-Joe |
---|
| 127 | # [keyid:Bob].role:goodPerformance <- [keyid:Joe]) |
---|