Commit 72344ad0 authored by Randeep's avatar Randeep
parent e1c1b0fc
......@@ -75,7 +75,7 @@
"sct": 1,
"owned": true,
"deviceuuid": "61646D69-6E44-6576-6963-655575696430",
"x.com.samsung.dpc": false,
"x.org.iotivity.dpc": false,
"devowneruuid": "61646D69-6E44-6576-6963-655575696430",
"rowneruuid": "61646D69-6E44-6576-6963-655575696430"
}
......
......@@ -77,7 +77,7 @@
"deviceuuid": "32323232-3232-3232-3232-323232323232",
"devowneruuid": "32323232-3232-3232-3232-323232323232",
"rowneruuid": "32323232-3232-3232-3232-323232323232",
"x.com.samsung.dpc": false
"x.org.iotivity.dpc": false
},
"cred": {
"creds": [
......
......@@ -101,7 +101,7 @@
"deviceuuid": "31313131-3131-3131-3131-313131313131",
"devowneruuid": "32323232-3232-3232-3232-323232323232",
"rowneruuid": "31313131-3131-3131-3131-313131313131",
"x.com.samsung.dpc": false
"x.org.iotivity.dpc": false
},
"cred": {
"creds": [
......
......@@ -72,11 +72,12 @@ OCStackResult CBORPayloadToDoxm(const uint8_t *cborPayload, size_t size,
* @note Caller needs to invoke OCFree after done using the return pointer.
* @param cborPayload is the payload of the cbor.
* @param cborSize is the size of the cbor payload. Passed parameter should not be NULL.
* @param rwOnly indicates whether convertingpayload has all properties or read-write properties only.
*
* @return ::OC_STACK_OK for Success, otherwise some error value.
*/
OCStackResult DoxmToCBORPayload(const OicSecDoxm_t * doxm, uint8_t **cborPayload,
size_t *cborSize);
size_t *cborSize, bool rwOnly);
/**
* This method returns the SRM device ID for this device.
......
......@@ -50,7 +50,7 @@ OCStackResult DeInitPstatResource();
* @return ::OC_STACK_OK for Success, otherwise some error value.
*/
OCStackResult PstatToCBORPayload(const OicSecPstat_t *pstat, uint8_t **cborPayload,
size_t *cborSize);
size_t *cborSize, bool writableOnly);
/**
* This method converts cbor into PSTAT data.
......
......@@ -80,6 +80,6 @@
"owned": false,
"deviceuuid": "646F6F72-4465-7669-6365-555549443030",
"rowneruuid": "646F6F72-4465-7669-6365-555549443030",
"x.com.samsung.dpc": false
"x.org.iotivity.dpc": false
}
}
......@@ -80,6 +80,6 @@
"owned": false,
"deviceuuid": "6C696768-7444-6576-6963-655555494430",
"rowneruuid": "6C696768-7444-6576-6963-655555494430",
"x.com.samsung.dpc": false
"x.org.iotivity.dpc": false
}
}
......@@ -63,6 +63,6 @@
"deviceuuid": "61646D69-6E44-6576-6963-655575696430",
"devowneruuid": "61646D69-6E44-6576-6963-655575696430",
"rowneruuid": "61646D69-6E44-6576-6963-655575696430",
"x.com.samsung.dpc": false
"x.org.iotivity.dpc": false
}
}
\ No newline at end of file
......@@ -37,7 +37,11 @@
#define MAX_URI_LENGTH (64)
#define MAX_PERMISSION_LENGTH (5)
#define MAX_ACL_LENGTH 100
#define MAX_ACE_LENGTH (100)
#define MAX_INTERFACE_LENGTH (10)
#define MAX_RESOURCETYPE_LENGTH (10)
#define MAX_STRING_INPUT_BUFFER_SIZE (256)
#define CREATE (1)
#define READ (2)
#define UPDATE (4)
......@@ -65,29 +69,6 @@ typedef enum
provisionCrlDone = 1 << 6
} StateManager;
/**
* Perform cleanup for ACL
* @param[in] ACL
*/
static void deleteACL(OicSecAcl_t *acl)
{
if (acl && MAX_ACL_LENGTH > acl->resourcesLen)
{
/* Clean Resources */
for (size_t i = 0; i < (acl)->resourcesLen; i++)
{
OICFree((acl)->resources[i]);
}
OICFree((acl)->resources);
/* Clean ACL node itself */
OICFree((acl));
acl = NULL;
}
}
void deleteCrl(OicSecCrl_t *crl)
{
if (crl)
......@@ -179,9 +160,19 @@ static int InputACL(OicSecAcl_t *acl)
char temp_id [UUID_LENGTH + 4] = {0,};
char temp_rsc[MAX_URI_LENGTH + 1] = {0,};
char temp_pms[MAX_PERMISSION_LENGTH + 1] = {0,};
char input_buffer[MAX_STRING_INPUT_BUFFER_SIZE] = {0};
OicSecAce_t* ace = (OicSecAce_t*)OICCalloc(1, sizeof(OicSecAce_t));
if(!ace)
{
printf("Failed to memory allocation\n");
return -1;
}
LL_APPEND(acl->aces, ace);
printf("******************************************************************************\n");
printf("-Set ACL policy for target device\n");
printf("******************************************************************************\n");
//Set Subject.
printf("-URN identifying the subject\n");
printf("ex) doorDeviceUUID00 (16 Numbers except to '-')\n");
......@@ -208,62 +199,135 @@ static int InputACL(OicSecAcl_t *acl)
printf("Invalid input\n");
return -1;
}
acl->subject.id[j++] = temp_id[i];
ace->subjectuuid.id[j++] = temp_id[i];
}
}
//Set Resource.
printf("Num. of Resource : \n");
ret = scanf("%zu", &acl->resourcesLen);
if(-1 == ret || MAX_ACL_LENGTH < acl->resourcesLen)
size_t inputLen = 0;
ret = scanf("%zu", &inputLen);
if(-1 == ret || MAX_ACE_LENGTH < inputLen)
{
printf("Error while input\n");
return -1;
}
printf("-URI of resource\n");
printf("ex) /a/light (Max_URI_Length: 64 Byte )\n");
acl->resources = (char **)OICCalloc(acl->resourcesLen, sizeof(char *));
if (NULL == acl->resources)
{
OIC_LOG(ERROR, TAG, "Error while memory allocation");
return -1;
}
for (size_t i = 0; i < acl->resourcesLen; i++)
for(size_t i = 0; i < inputLen; i++)
{
OicSecRsrc_t* rsrc = (OicSecRsrc_t*)OICCalloc(1, sizeof(OicSecRsrc_t));
if(!rsrc)
{
printf("Failed to memory allocation\n");
return -1;
}
LL_APPEND(ace->resources, rsrc);
//Input the resource URI for each resource
printf("[%zu]Resource : ", i + 1);
char *ptr_tempRsc = NULL;
ret = scanf("%64ms", &ptr_tempRsc);
ret = scanf("%s", input_buffer);
if (1==ret)
{
OICStrcpy(temp_rsc, sizeof(temp_rsc), ptr_tempRsc);
OICFree(ptr_tempRsc);
rsrc->href = OICStrdup(input_buffer);
if(!rsrc->href)
{
printf("Failed to OICStrdup\n");
return -1;
}
}
else
{
printf("Error while input\n");
return -1;
}
acl->resources[i] = OICStrdup(temp_rsc);
if (NULL == acl->resources[i])
//Input the interface name of resource
printf("Num. of Interface of [%s] (Max value : %d) : \n", rsrc->href, MAX_INTERFACE_LENGTH);
ret = scanf("%zu", &rsrc->interfaceLen);
if(-1 == ret || MAX_INTERFACE_LENGTH < rsrc->interfaceLen)
{
printf("Error while input\n");
return -1;
}
printf("-Interface of [%s] resource\n", rsrc->href);
printf("ex) oic.if.baseline (Max Length: 64 Byte )\n");
rsrc->interfaces = (char**)OICCalloc(rsrc->interfaceLen, sizeof(char*));
if(!rsrc->interfaces)
{
OIC_LOG(ERROR, TAG, "Error while memory allocation");
printf("Failed to memory allocation\n");
return -1;
}
for(size_t j = 0; j < rsrc->interfaceLen; j++)
{
printf("Interface[%zu] : ", j + 1);
ret = scanf("%s", input_buffer);
if(1 == ret)
{
rsrc->interfaces[i] = OICStrdup(input_buffer);
if(!rsrc->interfaces[i])
{
printf("Failed to OICStrdup\n");
return -1;
}
}
else
{
printf("Error while input\n");
return -1;
}
}
//Input the resource type of resource
printf("Num. of ResourceType of [%s] (Max value : %d) : \n", rsrc->href, MAX_RESOURCETYPE_LENGTH);
ret = scanf("%zu", &rsrc->typeLen);
if(-1 == ret || MAX_RESOURCETYPE_LENGTH < rsrc->typeLen)
{
printf("Error while input\n");
return -1;
}
printf("-Resource Type of [%s] resource\n", rsrc->href);
printf("ex) oic.core (Max Length: 64 Byte )\n");
rsrc->types = (char**)OICCalloc(rsrc->typeLen, sizeof(char*));
if(!rsrc->types)
{
printf("Failed to memory allocation\n");
return -1;
}
for(size_t j = 0; j < rsrc->typeLen; j++)
{
printf("Resource type[%zu] : ", j + 1);
ret = scanf("%s", input_buffer);
if(1 == ret)
{
rsrc->types[i] = OICStrdup(input_buffer);
if(!rsrc->types[i])
{
printf("Failed to OICStrdup\n");
return -1;
}
}
else
{
printf("Error while input\n");
return -1;
}
}
}
// Set Permission
do
{
printf("-Set the permission(C,R,U,D,N)\n");
printf("ex) CRUDN, CRU_N,..(5 Charaters)\n");
printf("Permission : ");
char *ptr_temp_pms = NULL;
ret = scanf("%5ms", &ptr_temp_pms);
ret = scanf("%s", &input_buffer);
if(1 == ret)
{
OICStrcpy(temp_pms, sizeof(temp_pms), ptr_temp_pms);
OICFree(ptr_temp_pms);
OICStrcpy(temp_pms, sizeof(temp_pms), input_buffer);
}
else
{
......@@ -271,36 +335,13 @@ static int InputACL(OicSecAcl_t *acl)
return -1;
}
}
while (0 != CalculateAclPermission(temp_pms, &(acl->permission)) );
// Set Rowner
printf("-URN identifying the rowner\n");
printf("ex) lightDeviceUUID0 (16 Numbers except to '-')\n");
while (0 != CalculateAclPermission(temp_pms, &(ace->permission)) );
printf("Rowner : ");
char *ptr_temp_id = NULL;
ret = scanf("%19ms", &ptr_temp_id);
if (1 == ret)
{
OICStrcpy(temp_id, sizeof(temp_id), ptr_temp_id);
OICFree(ptr_temp_id);
}
else
{
printf("Error while input\n");
return -1;
}
j = 0;
for (int k = 0; temp_id[k] != '\0'; k++)
{
if (DASH != temp_id[k])
{
acl->rownerID.id[j++] = temp_id[k];
}
}
return 0;
}
//FILE *client_fopen(const char *path, const char *mode)
FILE *client_fopen(const char* UNUSED_PARAM , const char *mode)
{
......@@ -481,10 +522,15 @@ static int InputCRL(OicSecCrl_t *crlRes)
PRINT_BYTE_ARRAY("CRL:\n",crl);
CHECK_CALL(SetCertificateRevocationList, &crl);
crlRes->CrlData = crl;
crlRes->ThisUpdate.data = uint8ThisUpdateTime;
crlRes->ThisUpdate.data = OICStrdup(uint8ThisUpdateTime);
crlRes->ThisUpdate.len = DATE_LENGTH;
crlRes->CrlId = 1;
if(NULL == crlRes->ThisUpdate.data)
{
printf("OICStrdup failed\n");
return PKI_MEMORY_ALLOC_FAILED;
}
FUNCTION_CLEAR(
//OICFree(crl.data);
......@@ -739,7 +785,8 @@ int main()
}
error:
deleteACL(gAcl);
DeleteACLList(gAcl);
deleteCrl(gCrl);
OCDeleteDiscoveredDevices(pDeviceList);
OCDeleteDiscoveredDevices(pOwnedList);
......
......@@ -80,6 +80,6 @@
"deviceuuid": "61646d69-6e44-6576-6963-655555494430",
"devowneruuid": "61646d69-6e44-6576-6963-655555494430",
"rowneruuid": "61646d69-6e44-6576-6963-655555494430",
"x.com.samsung.dpc": false
"x.org.iotivity.dpc": false
}
}
\ No newline at end of file
......@@ -38,6 +38,16 @@ extern "C" {
*/
OCStackResult PDMInit(const char* dbPath);
/**
* This method is used by provisioning manager to check whether device is stale or not with PDM.
*
* @param[in] uuid information about the target device's uuid.
* @param[out] result true in case device is stale.
*
* @return OC_STACK_OK in case of success and other value otherwise.
*/
OCStackResult PDMIsDeviceStale(const OicUuid_t *uuid, bool *result);
/**
* This method is used by provisioning manager to check duplication of device's Device ID with
* provisioning database.
......
......@@ -152,6 +152,22 @@ OCStackResult SRPRemoveDevice(void* ctx,
const OCProvisionDev_t* pTargetDev,
OCProvisionResultCB resultCallback);
/*
* Function to device revocation
* This function will remove credential of target device from all devices in subnet.
*
* @param[in] ctx Application context would be returned in result callback
* @param[in] pOwnedDevList List of owned devices
* @param[in] pTargetDev Device information to be revoked.
* @param[in] resultCallback callback provided by API user, callback will be called when
* credential revocation is finished.
* @return OC_STACK_OK in case of success and other value otherwise.
* If OC_STACK_OK is returned, the caller of this API should wait for callback.
* OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
*/
OCStackResult SRPRemoveDeviceWithoutDiscovery(void* ctx, const OCProvisionDev_t* pOwnedDevList,
const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
/*
* Function to sync-up credential and ACL of the target device.
* This function will remove credential and ACL of target device from all devices in subnet.
......
......@@ -202,7 +202,24 @@ OCStackResult OCRemoveDevice(void* ctx,
unsigned short waitTimeForOwnedDeviceDiscovery,
const OCProvisionDev_t* pTargetDev,
OCProvisionResultCB resultCallback);
/**
/*
* Function to device revocation
* This function will remove credential of target device from all devices in subnet.
*
* @param[in] ctx Application context would be returned in result callback
* @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
* @param[in] pTargetDev Device information to be revoked.
* @param[in] resultCallback callback provided by API user, callback will be called when
* credential revocation is finished.
* @return OC_STACK_OK in case of success and other value otherwise.
*/
OCStackResult OCRemoveDeviceWithUuid(void* ctx,
unsigned short waitTimeForOwnedDeviceDiscovery,
const OicUuid_t* pTargetUuid,
OCProvisionResultCB resultCallback);
/**
* API to get status of all the devices in current subnet. The status include endpoint information
* and doxm information which can be extracted duing owned and unowned discovery. Along with this
* information. The API will provide information about devices' status
......@@ -213,8 +230,8 @@ OCStackResult OCRemoveDevice(void* ctx,
* variables pOwnedDevList and pUnownedDevList.
*
* @param[in] waitime Wait time for the API. The wait time will be divided by 2, and half of wait time
* will be used for unowned discovery and remaining half for owned discovery. So the wait time should be
* equal to or more than 2.
* will be used for unowned discovery and remaining half for owned discovery. So the wait time should be
* equal to or more than 2.
* @param[out] pOwnedDevList list of owned devices.
* @param[out] pUnownedDevList list of unowned devices.
* @return OC_STACK_OK in case of success and other value otherwise.
......@@ -253,7 +270,7 @@ void OCDeleteUuidList(OCUuidList_t* pList);
*
* @param pAcl Pointer to OicSecAcl_t structure.
*/
void OCDeleteACLList(OicSecAcl_t* pAcl);
void OCDeleteACLList(OicSecAcl_t* pAcl);
/**
* This function deletes PDACL data.
......@@ -261,21 +278,21 @@ void OCDeleteACLList(OicSecAcl_t* pAcl);
* @param pPdAcl Pointer to OicSecPdAcl_t structure.
*/
void OCDeletePdAclList(OicSecPdAcl_t* pPdAcl);
#ifdef __WITH_X509__
/**
* this function sends CRL information to resource.
*
* @param[in] ctx Application context would be returned in result callback.
* @param[in] selectedDeviceInfo Selected target device.
* @param[in] crl CRL to provision.
* @param[in] resultCallback callback provided by API user, callback will be called when provisioning
request recieves a response from resource server.
* @return OC_STACK_OK in case of success and other value otherwise.
*/
OCStackResult OCProvisionCRL(void* ctx, const OCProvisionDev_t *selectedDeviceInfo, OicSecCrl_t *crl,
OCProvisionResultCB resultCallback);
#endif // __WITH_X509__
#ifdef __WITH_X509__
/**
* this function sends CRL information to resource.
*
* @param[in] ctx Application context would be returned in result callback.
* @param[in] selectedDeviceInfo Selected target device.
* @param[in] crl CRL to provision.
* @param[in] resultCallback callback provided by API user, callback will be called when provisioning
request recieves a response from resource server.
* @return OC_STACK_OK in case of success and other value otherwise.
*/
OCStackResult OCProvisionCRL(void* ctx, const OCProvisionDev_t *selectedDeviceInfo, OicSecCrl_t *crl,
OCProvisionResultCB resultCallback);
#endif // __WITH_X509__
#ifdef __cplusplus
......
......@@ -79,7 +79,7 @@
"sct": 1,
"owned": true,
"deviceuuid": "61646D69-6E44-6576-6963-655575696430",
"x.com.samsung.dpc": false,
"x.org.iotivity.dpc": false,
"devowneruuid": "61646D69-6E44-6576-6963-655575696430",
"rowneruuid": "61646D69-6E44-6576-6963-655575696430"
}
......
......@@ -105,6 +105,6 @@
"deviceuuid": "",
"devowneruuid": "",
"rowneruuid": "",
"x.com.samsung.dpc": true
"x.org.iotivity.dpc": true
}
}
......@@ -105,6 +105,6 @@
"deviceuuid": "6A757374-776F-726B-4465-765575696430",
"devowneruuid": "",
"rowneruuid": "6A757374-776F-726B-4465-765575696430",
"x.com.samsung.dpc": true
"x.org.iotivity.dpc": true
}
}
......@@ -105,6 +105,6 @@
"deviceuuid": "72616E64-5069-6E44-6576-557569643030",
"devowneruuid": "",
"rowneruuid": "72616E64-5069-6E44-6576-557569643030",
"x.com.samsung.dpc": true
"x.org.iotivity.dpc": true
}
}
......@@ -43,21 +43,22 @@ extern "C"
// declaration(s) for provisioning client using C-level provisioning API
// user input definition for main loop on provisioning client
#define _10_DISCOV_ALL_DEVS_ 10
#define _11_DISCOV_UNOWN_DEVS_ 11
#define _12_DISCOV_OWN_DEVS_ 12
#define _20_REGIST_DEVS_ 20
#define _30_PROVIS_PAIR_DEVS_ 30
#define _31_PROVIS_CRED_ 31
#define _32_PROVIS_ACL_ 32
#define _33_PROVIS_DP_ 33
#define _34_CHECK_LINK_STATUS_ 34
#define _40_UNLINK_PAIR_DEVS_ 40
#define _50_REMOVE_SELEC_DEV_ 50
#define _51_RESET_SELEC_DEV_ 51
#define _60_GET_CRED_ 60
#define _61_GET_ACL_ 61
#define _99_EXIT_PRVN_CLT_ 99
#define _10_DISCOV_ALL_DEVS_ 10
#define _11_DISCOV_UNOWN_DEVS_ 11
#define _12_DISCOV_OWN_DEVS_ 12
#define _20_REGIST_DEVS_ 20
#define _30_PROVIS_PAIR_DEVS_ 30
#define _31_PROVIS_CRED_ 31