added option for ACL subject (Cloud SID as ACL topic)
@@ -1526,6 +1526,7 @@ provision_ace2(void)
const char *conn_types[2] = { "anon-clear", "auth-crypt" };
int num_resources = 0;
+ char di[OC_UUID_LEN];
device_handle_t *devices[MAX_NUM_DEVICES];
device_handle_t *device = (device_handle_t *)oc_list_head(owned_devices);
@@ -1558,41 +1559,37 @@ provision_ace2(void)
PRINT("\n[0]: %s\n", conn_types[0]);
PRINT("[1]: %s\n", conn_types[1]);
PRINT("[2]: Role\n");
+ PRINT("[3]: Cloud\n");
i = 0;
while (device != NULL) {
- char di[OC_UUID_LEN];
+ //char di[OC_UUID_LEN];
oc_uuid_to_str(&device->uuid, di, OC_UUID_LEN);
- PRINT("[%d]: %s - %s\n", i + 3, di, device->device_name);
+ PRINT("[%d]: %s - %s\n", i + 4, di, device->device_name);
i++;
device = device->next;
if (!device) {
oc_uuid_to_str(oc_core_get_device_id(0), di, OC_UUID_LEN);
- PRINT("[%d]: %s - (OBT)\n", i + 3, di);
+ PRINT("[%d]: %s - (OBT)\n", i + 4, di);
i++;
}
}
PRINT("\nSelect subject: ");
SCANF("%d", &sub);
- if (sub >= (i + 3)) {
+ if ((sub > (i + 3)) || (sub < 0)) {
PRINT("ERROR: Invalid selection\n");
return;
}
oc_sec_ace_t *ace = NULL;
- if (sub > 2) {
- if (sub == (i + 2)) {
- ace = oc_obt_new_ace_for_subject(oc_core_get_device_id(0));
- } else {
- ace = oc_obt_new_ace_for_subject(&devices[sub - 3]->uuid);
- }
- } else {
if (sub == 0) {
ace = oc_obt_new_ace_for_connection(OC_CONN_ANON_CLEAR);
- } else if (sub == 1) {
+ }
+ else if (sub == 1) {
ace = oc_obt_new_ace_for_connection(OC_CONN_AUTH_CRYPT);
- } else {
+ }
+ else if (sub == 2) {
char role[64];
PRINT("\nEnter role: ");
SCANF("%63s", role);
@@ -1604,9 +1601,21 @@ provision_ace2(void)
PRINT("\nEnter Authority: ");
SCANF("%63s", authority);
ace = oc_obt_new_ace_for_role(role, authority);
- } else {
+ }
+ else {
ace = oc_obt_new_ace_for_role(role, NULL);
}
+ } else {
+ if (sub == 3 ) {
+ PRINT("\nEnter Cloud sid: ");
+ SCANF("%63s", di);
+ oc_uuid_t uuid_di;
+ oc_str_to_uuid(di, &uuid_di);
+ ace = oc_obt_new_ace_for_subject(&uuid_di);
+ } else if (sub == (i + 3)) {
+ ace = oc_obt_new_ace_for_subject(oc_core_get_device_id(0));
+ } else {
+ ace = oc_obt_new_ace_for_subject(&devices[sub - 4]->uuid);
}
}
