-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinitialize.sh
342 lines (285 loc) · 22 KB
/
initialize.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#! /bin/bash
# http api tests : repository creation and content initialization
set -e
if [[ "" == "${STORE_HOST}" ]]
then source ./define.sh
fi
export STORE_TOKEN_ADMIN=`cat ~/.dydra/${STORE_HOST}.token`
# create one account/repository for each of various authorization combinations
#
# $ACCOUNT : the base account
# $ACCOUNT-anon : allowing anonymous access to its profile and repository list
# $ACCOUNT-read : granted read authorization to the -byuser repository
# $ACCOUNT-write : granted write authorization to the -byuser repository
# $ACCOUNT-readwrite : granted read/write authorization to the -byuser repository
# $ACCOUNT/$REPOSITORY : owner authorization for read/write - the normal case
# $ACCOUNT/$REPOSITORY-write : owner authorization for read/write - the normal case (this one is modified)
# $STORE_ACCOUNT/$STORE_REPOSITORY_PUBLIC : owner plus anonymous (agent) read
# $ACCOUNT/$REPOSITORY-user : owner plus authenticated (user) read
# $ACCOUNT/$REPOSITORY-byuser : owner plus access specific to user
# $ACCOUNT/$REPOSITORY-readbyip : owner plus read for $STORE_CLIENT_IP for any agent
# $ACCOUNT/$REPOSITORY-writebyip : owner plus write for $STORE_CLIENT_IP for any user (not just agent)
#
# create repositories to test extensions
#
# $ACCOUNT/tpf
# $ACCOUNT/collation
#
# n.b. creation requires admin priviledges
# $ACCOUNT : the base account
${CURL} -w "%{http_code}\n" -f -s -X POST -H "Content-Type: application/json" --data-binary @- \
-u ":${STORE_TOKEN_ADMIN}" ${STORE_URL}/system/accounts <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
{"account": {"name": "${STORE_ACCOUNT}"} }
EOF
# authorization and metadata :
# add authorization for authenticated users to read the repository list either from both accounts-api and the sesame resources
${CURL} -w "%{http_code}\n" -L -f -s -X POST \
-u ":${STORE_TOKEN_ADMIN}" \
-H "Content-Type: application/n-quads" --data-binary @- \
${STORE_URL}/${STORE_ACCOUNT}/system/service <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
_:aclBase1 <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase1 <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/repositories> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase1 <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase1 <http://www.w3.org/ns/auth/acl#agentClass> <urn:dydra:User> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase2 <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase2 <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/repositories> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase2 <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase2 <http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
EOF
# $ACCOUNT-anon : allowing anonymous profile and repository list access
${CURL} -w "%{http_code}\n" -f -s -X POST -H "Content-Type: application/json" --data-binary @- \
-u ":${STORE_TOKEN_ADMIN}" ${STORE_URL}/system/accounts <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
{"account": {"name": "${STORE_ACCOUNT}-anon"} }
EOF
# authorization and metadata
${CURL} -w "%{http_code}\n" -L -f -s -X POST \
-u ":${STORE_TOKEN_ADMIN}" \
-H "Content-Type: application/n-quads" --data-binary @- \
${STORE_URL}/${STORE_ACCOUNT}-anon/system/service <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
_:acl1 <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}-anon/profile> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}-anon> .
_:acl1 <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}-anon> .
_:acl1 <http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}-anon> .
<http://${STORE_SITE}/accounts/${STORE_ACCOUNT}-anon> <http://purl.org/dc/elements/1.1/description> "An account to test anonymous access its profile" <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}-anon> .
EOF
# $ACCOUNT/$REPOSITORY : owner authorization for read/write - the normal case
# the 'standard' account corresponds to the name in the sesame protocol documentation
# authorization: owner authorization for read/write - the normal case
${CURL} -w "%{http_code}\n" -f -s -X POST -H "Content-Type: application/json" --data-binary @- \
-u ":${STORE_TOKEN_ADMIN}" ${STORE_URL}/system/accounts <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
{"account": {"name": "${STORE_ACCOUNT}"} }
EOF
# the standard repository w/ an extensive configuration
${CURL} -w "%{http_code}\n" -f -s -X POST -H "Content-Type: application/json" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/system/accounts/${STORE_ACCOUNT}/repositories <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
{"repository": {"name": "${STORE_REPOSITORY}"} }
EOF
initialize_repository_configuration | egrep -q "${STATUS_POST_SUCCESS}" ;
initialize_repository_content ;
initialize_repository_public ;
${CURL} -w "%{http_code}\n" -f -s -X POST -H "Content-Type: application/json" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/system/accounts/${STORE_ACCOUNT}/repositories <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
{"repository": {"name": "${STORE_REPOSITORY}-write"} }
EOF
# ${STORE_ACCOUNT}/${STORE_REPOSITORY_PUBLIC} : owner plus anonymous (agent) read
${CURL} -w "%{http_code}\n" -f -s -X POST -H "Content-Type: application/json" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/system/accounts/${STORE_ACCOUNT}/repositories <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
{"repository": {"name": "$STORE_REPOSITORY_PUBLIC"} }
EOF
# (initialize-repository-metadata (repository "${STORE_ACCOUNT}/${STORE_REPOSITORY_PUBLIC}"))
# metadata w/ anonymous read access
${CURL} -w "%{http_code}\n" -L -f -s -X POST \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/${STORE_ACCOUNT}/system/service <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
_:aclAnon <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/${STORE_REPOSITORY_PUBLIC}> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> .
_:aclAnon <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> .
_:aclAnon <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> .
_:aclAnon <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> .
_:aclAnon <http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> .
<http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> <http://purl.org/dc/elements/1.1/description> "An account to test anonymous access to its content" <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> .
EOF
# and minimal data
${CURL} -w "%{http_code}\n" -L -f -s -X PUT \
-H "Accept: application/n-quads" \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/${STORE_ACCOUNT}/${STORE_REPOSITORY_PUBLIC}/service <<EOF \
| egrep -q "${STATUS_PUT_SUCCESS}"
<http://example.com/subject> <http://example.com/predicate> "object" <${STORE_URL}>.
EOF
# $ACCOUNT/$REPOSITORY-user : owner plus authenticated (user) read
${CURL} -w "%{http_code}\n" -f -s -X POST -H "Content-Type: application/json" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/system/accounts/${STORE_ACCOUNT}/repositories <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
{"repository": {"name": "${STORE_REPOSITORY}-user"} }
EOF
# metadata w/ authenticated user read access
${CURL} -w "%{http_code}\n" -L -f -s -X POST \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/${STORE_ACCOUNT}/system/service <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
_:aclUser <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/${STORE_REPOSITORY}-user> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-user> .
_:aclUser <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-user> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-user> .
_:aclUser <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-user> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-user> .
_:aclUser <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-user> .
_:aclUser <http://www.w3.org/ns/auth/acl#agentClass> <urn:dydra:User> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-user> .
<http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-user> <http://purl.org/dc/elements/1.1/description> "An account to test all-user access to its content" <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-user> .
EOF
# and minimal data
${CURL} -w "%{http_code}\n" -L -f -s -X PUT \
-H "Accept: application/n-quads" \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/${STORE_ACCOUNT}/${STORE_REPOSITORY}-user/service <<EOF \
| egrep -q "${STATUS_PUT_SUCCESS}"
<http://example.com/subject> <http://example.com/predicate> "object" <${STORE_URL}>.
EOF
# $ACCOUNT/$REPOSITORY-byuser : owner plus authenticated (user) read
${CURL} -w "%{http_code}\n" -f -s -X POST -H "Content-Type: application/json" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/system/accounts/${STORE_ACCOUNT}/repositories <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
{"repository": {"name": "${STORE_REPOSITORY}-byuser"} }
EOF
# to reset: (initialize-repository-metadata (repository "openrdf-sesame/mem-rdf-byuser"))
# metadata w/ anonymous access specific to user
${CURL} -w "%{http_code}\n" -L -f -s -X POST \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/${STORE_ACCOUNT}/system/service <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
_:aclRead <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/${STORE_REPOSITORY}-byuser> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclRead <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclRead <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclRead <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclRead <http://www.w3.org/ns/auth/acl#agent> <http://${STORE_SITE}/users/${STORE_ACCOUNT}-read> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclWrite <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/${STORE_REPOSITORY}-byuser> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclWrite <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclWrite <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclWrite <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Write> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclWrite <http://www.w3.org/ns/auth/acl#agent> <http://${STORE_SITE}/users/${STORE_ACCOUNT}-write> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclReadWrite <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/${STORE_REPOSITORY}-byuser> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclReadWrite <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclReadWrite <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclReadWrite <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclReadWrite <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Write> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
_:aclReadWrite <http://www.w3.org/ns/auth/acl#agent> <http://${STORE_SITE}/users/${STORE_ACCOUNT}-readwrite> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
<http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> <http://purl.org/dc/elements/1.1/description> "An account to test specific user access to its content" <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> .
EOF
# with the necessary accounts
${CURL} -w "%{http_code}\n" -f -s -X POST -H "Content-Type: application/json" --data-binary @- \
-u ":${STORE_TOKEN_ADMIN}" \
${STORE_URL}/system/accounts <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
{"account": {"name": "${STORE_ACCOUNT}-read"} }
EOF
# to reset: (initialize-account-metadata (account "openrdf-sesame-read"))
${CURL} -w "%{http_code}\n" -f -s -X POST -H "Content-Type: application/json" --data-binary @- \
-u ":${STORE_TOKEN_ADMIN}" \
${STORE_URL}/system/accounts <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
{"account": {"name": "${STORE_ACCOUNT}-write"} }
EOF
# to reset: (initialize-account-metadata (account "openrdf-sesame-write"))
${CURL} -w "%{http_code}\n" -f -s -X POST -H "Content-Type: application/json" --data-binary @- \
-u ":${STORE_TOKEN_ADMIN}" \
${STORE_URL}/system/accounts <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
{"account": {"name": "${STORE_ACCOUNT}-readwrite"} }
EOF
# to reset: (initialize-account-metadata (account "openrdf-sesame-readwrite"))
# and authentication
${CURL} -w "%{http_code}\n" -L -f -s -X POST \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN_ADMIN}" \
${STORE_URL}/system/system/service <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
<http://${STORE_SITE}/accounts/${STORE_ACCOUNT}-read> <urn:dydra:accessToken> "${STORE_TOKEN}_READ" <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}-read> .
<http://${STORE_SITE}/accounts/${STORE_ACCOUNT}-write> <urn:dydra:accessToken> "${STORE_TOKEN}_WRITE" <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}-write> .
<http://${STORE_SITE}/accounts/${STORE_ACCOUNT}-readwrite> <urn:dydra:accessToken> "${STORE_TOKEN}_READWRITE" <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}-readwrite> .
EOF
# and minimal data
${CURL} -w "%{http_code}\n" -L -f -s -X PUT \
-H "Accept: application/n-quads" \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/${STORE_ACCOUNT}/${STORE_REPOSITORY}-byuser/service <<EOF \
| egrep -q "${STATUS_PUT_SUCCESS}"
<http://example.com/subject> <http://example.com/predicate> "object" <${STORE_URL}>.
EOF
# $ACCOUNT/$REPOSITORY-readbyip : owner plus read for $STORE_CLIENT_IP for any agent
${CURL} -w "%{http_code}\n" -f -s -X POST -H "Content-Type: application/json" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/system/accounts/${STORE_ACCOUNT}/repositories <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
{"repository": {"name": "${STORE_REPOSITORY}-readbyip"} }
EOF
# to reset: (initialize-repository-metadata (repository "openrdf-sesame/mem-rdf-readbyip"))
# metadata w/ anonymous access specific to user
${CURL} -w "%{http_code}\n" -L -f -s -X POST \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/${STORE_ACCOUNT}/system/service <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
_:aclReadByIp <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/${STORE_REPOSITORY}-readbyip> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-readbyip> .
_:aclReadByIp <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-readbyip> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-readbyip> .
_:aclReadByIp <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-readbyip> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-readbyip> .
_:aclReadByIp <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-readbyip> .
_:aclReadByIp <http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-readbyip> .
_:aclReadByIp <http://rdfs.org/sioc/ns#ip_address> "${STORE_CLIENT_IP}" <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-readbyip> .
<http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> <http://purl.org/dc/elements/1.1/description> "An account to test ip-restricted read access" <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-readbyip> .
EOF
# and minimal data
${CURL} -w "%{http_code}\n" -L -f -s -X PUT \
-H "Accept: application/n-quads" \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/${STORE_ACCOUNT}/${STORE_REPOSITORY}-readbyip/service <<EOF \
| egrep -q "${STATUS_PUT_SUCCESS}"
<http://example.com/subject> <http://example.com/predicate> "object" <${STORE_URL}>.
EOF
# $ACCOUNT/$REPOSITORY-writebyip : owner plus write for $STORE_CLIENT_IP for any user
${CURL} -w "%{http_code}\n" -f -s -X POST -H "Content-Type: application/json" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/system/accounts/${STORE_ACCOUNT}/repositories <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
{"repository": {"name": "${STORE_REPOSITORY}-writebyip"} }
EOF
# to reset: (initialize-repository-metadata (repository "openrdf-sesame/mem-rdf-writebyip"))
# metadata w/ anonymous access specific to user
${CURL} -w "%{http_code}\n" -L -f -s -X POST \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/${STORE_ACCOUNT}/system/service <<EOF \
| egrep -q "${STATUS_POST_SUCCESS}"
_:aclWriteByIp <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/${STORE_REPOSITORY}-writebyip> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-writebyip> .
_:aclWriteByIp <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-writeby> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-writebyip> .
_:aclWriteByIp <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-writebyip> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-writebyip> .
_:aclWriteByIp <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Write> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-writebyip> .
_:aclWriteByIp <http://www.w3.org/ns/auth/acl#agentClass> <urn:dydra:User> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-writebyip> .
_:aclWriteByIp <http://rdfs.org/sioc/ns#ip_address> "${STORE_CLIENT_IP}" <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-writebyip> .
<http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-byuser> <http://purl.org/dc/elements/1.1/description> "An account to test ip-restricted write access" <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY}-writebyip> .
EOF
# and minimal data
${CURL} -w "%{http_code}\n" -L -f -s -X PUT \
-H "Accept: application/n-quads" \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/${STORE_ACCOUNT}/${STORE_REPOSITORY}-writebyip/service <<EOF \
| egrep -q "${STATUS_PUT_SUCCESS}"
<http://example.com/subject> <http://example.com/predicate> "object" <${STORE_URL}>.
EOF