source: examples/python_tests/fruits_rt2/README @ 669b481

mei_rt2mei_rt2_fix_1
Last change on this file since 669b481 was 7211a95, checked in by Mei <mei@…>, 12 years ago

1) add more python examples
2) add the missing linking role and linking oset api calls
3) fix the output of time typed data term/oset obj in typed_string format

(transform back from yap time format to our ddddddddTdddddd format

  • Property mode set to 100755
File size: 4.2 KB
Line 
1#!/bin/sh
2#
3# This demonstrates assigning objects to object sets (osets) based on their
4# membership in other sets.  In this case there are 3 prinicpals. Mary and Bob
5# are encoding what fruits they are willing to eat in the oset Bob.what2eat and
6# Mary.what2eat.  Ralphs is defining the prices of the fruits it sells by
7# assigning them to osets parameterized by price.
8#
9# Credential 1 lays out Mary's policy - she will eat fruits that cost less that
10# or equal to 2.00.  Bob will eat fruits that cost between 1.00 and 5.00, as
11# laid out in Credential 2.  Strictly speaking Bob and Mary's ruls apply to
12# prices assigned by Ralphs.  Credentials 3-6 are Ralph's price assignments:
13#
14# Fruit               Price      Credential
15# apple               1.50       3
16# kiwi                1.50       4
17# black rsaberry      2.50       5
18# navel ornage        0.50       6
19#
20# The attached ./run_query file proves that Mary will eat a naval orange and a kiwi,
21# and that Bob will not eat a navel orange (too cheap).  It also proves a apple
22# is priced at 1.50 and that it cannot prove that a green apple is priced at
23# 1.50 (we don't know anything about green apples).
24
25# fruits_rt2_typed
26
27# mary.what2eat<-?-navel orange  good
28# mary.what2eat<-?-kiwi  good
29# bob.what2eat<-?-navel orange  bad
30# ralphs.fruitprice(1.50)<-?-apple   good
31# ralphs.fruitprice(1.50)<-?-green apple   bad
32
33creddy --generate --cn Mary
34creddy --generate --cn Bob
35creddy --generate --cn Ralphs
36
37mary_keyid=`creddy --keyid --cert Mary_ID.pem`
38bob_keyid=`creddy --keyid --cert Bob_ID.pem`
39ralphs_keyid=`creddy --keyid --cert Ralphs_ID.pem`
40
41fruitprice_qP="fruitprice([float:?P:[..2.00]])"
42fruitprice_qP_2="fruitprice([float:?P:[1.00..5.00]])"
43
44# [keyid:mary].oset:what2eat
45#      <- [keyid:ralphs].oset:fruitprice([float:?P:[..2.00]])
46# Credential 1
47creddy --attribute \
48       --issuer Mary_ID.pem --key Mary_private.pem --oset "what2eat" \
49       --subject-cert Ralphs_ID.pem --subject-oset "$fruitprice_qP" \
50       --out mary_what2eat__ralphs_fruitprice_qP_attr.der
51
52# [keyid:bob].oset:what2eat
53#      <- [keyid:ralphs].oset:fruitprice([float:?P:[1.00..5.00]])
54# Credential 2
55creddy --attribute \
56       --issuer Bob_ID.pem --key Bob_private.pem --oset "what2eat" \
57       --subject-cert Ralphs_ID.pem --subject-oset "$fruitprice_qP_2" \
58       --out bob_what2eat__ralphs_fruitprice_qP_2_attr.der
59
60# [keyid:ralphs].oset:fruitprice([float:1.50]) <- [string:'apple']
61# Credential 3
62creddy --attribute \
63        --issuer Ralphs_ID.pem --key Ralphs_private.pem \
64        --oset "fruitprice([float:1.50])" \
65        --subject-obj "[string:'apple']" \
66        --out Ralphs_fruitprice__apple_attr.der
67
68# [keyid:ralphs].oset:fruitprice([float:1.50]) <- [string:'kiwi']
69# Credential 4
70creddy --attribute \
71        --issuer Ralphs_ID.pem --key Ralphs_private.pem \
72        --oset "fruitprice([float:1.50])" \
73        --subject-obj "[string:'kiwi']" \
74        --out Ralphs_fruitprice__kiwi_attr.der
75
76
77# [keyid:ralphs].oset:fruitprice([float:2.50]) <- [string:'black rasberry']
78# Credential 5
79creddy --attribute \
80        --issuer Ralphs_ID.pem --key Ralphs_private.pem \
81        --oset "fruitprice([float:2.50])" \
82        --subject-obj "[string:'black rasberry']" \
83        --out Ralphs_fruitprice__black_rasberry_attr.der
84
85# [keyid:ralphs].oset:fruitprice([float:0.50]) <- [string:'navel orange']
86# Credential 6
87creddy --attribute \
88        --issuer Ralphs_ID.pem --key Ralphs_private.pem \
89        --oset "fruitprice([float:0.50])" \
90        --subject-obj "[string:'navel orange']" \
91        --out Ralphs_fruitprice__navel_orange_attr.der
92
93#####################################################################
94# mary.what2eat <- ralphs.fruitsprice(?P:[..2.00])
95# [keyid:mary].oset:what2eat
96#      <- [keyid:ralphs].oset:fruitprice([float:?P:[..2.00]])
97#
98# bob.what2eat <- ralphs.fruitsprice(?P:[1.00..5.00])
99# [keyid:bob].oset:what2eat
100#      <- [keyid:ralphs].oset:fruitprice([float:?P:[1.00..5.00]])
101#
102# ralphs.fruitprice(1.50)<-apple
103# [keyid:ralphs].oset:fruitprice([float:1.50]) <- [string:'apple']
104#
105# ralphs.fruitprice(2.50)<-black rasberry
106# [keyid:ralphs].oset:fruitprice([float:2.50]) <- [string:'black rasberry']
107#
108# ralphs.fruitprice(0.50)<-navel orange
109# [keyid:ralphs].oset:fruitprice([float:0.50]) <- [string:'navel orange']
110#
111
Note: See TracBrowser for help on using the repository browser.