NSResult NSCreateResource(char *uri)
{
NS_LOG(DEBUG, "NSCreateResource - IN");
+
if (!uri)
{
NS_LOG(NS_ERROR, "Resource URI cannot be NULL");
return NS_ERROR;
}
+ uint8_t resourceProperties;
+
if (strcmp(uri, NS_ROOT_URI) == 0)
{
NotificationResource.policy = true;
NotificationResource.version = VERSION;
NotificationResource.handle = NULL;
+ if(NSGetResourceSecurity())
+ {
+ NS_LOG(DEBUG, "Create secured resource");
+ resourceProperties = OC_DISCOVERABLE | OC_SECURE;
+ }
+ else
+ {
+ resourceProperties = OC_DISCOVERABLE;
+ }
+
if (OCCreateResource(&NotificationResource.handle, NS_ROOT_TYPE, NS_DEFAULT_INTERFACE,
- NS_ROOT_URI, NSEntityHandlerNotificationCb, NULL, OC_DISCOVERABLE) != OC_STACK_OK)
+ NS_ROOT_URI, NSEntityHandlerNotificationCb, NULL, resourceProperties) != OC_STACK_OK)
{
NS_LOG(NS_ERROR, "Fail to Create Notification Resource");
return NS_ERROR;
NotificationMessageResource.topicName = NULL;
NotificationMessageResource.mediaContents = NULL;
+ if(NSGetResourceSecurity())
+ {
+ NS_LOG(DEBUG, "Create secured resource");
+ resourceProperties = OC_OBSERVABLE | OC_SECURE;
+ }
+ else
+ {
+ resourceProperties = OC_OBSERVABLE;
+ }
+
if (OCCreateResource(&NotificationMessageResource.handle, NS_COLLECTION_MESSAGE_TYPE,
NS_DEFAULT_INTERFACE, NS_COLLECTION_MESSAGE_URI, NSEntityHandlerMessageCb, NULL,
- OC_OBSERVABLE) != OC_STACK_OK)
+ resourceProperties) != OC_STACK_OK)
{
NS_LOG(NS_ERROR, "Fail to Create Notification Message Resource");
return NS_ERROR;
NotificationSyncResource.state = NULL;
NotificationSyncResource.handle = NULL;
+ if(NSGetResourceSecurity())
+ {
+ NS_LOG(DEBUG, "Create secured resource");
+ resourceProperties = OC_OBSERVABLE | OC_SECURE;
+ }
+ else
+ {
+ resourceProperties = OC_OBSERVABLE;
+ }
+
if (OCCreateResource(&(NotificationSyncResource.handle), NS_COLLECTION_SYNC_TYPE,
NS_DEFAULT_INTERFACE, NS_COLLECTION_SYNC_URI, NSEntityHandlerSyncCb, NULL,
- OC_OBSERVABLE) != OC_STACK_OK)
+ resourceProperties) != OC_STACK_OK)
{
NS_LOG(NS_ERROR, "Fail to Create Notification Sync Resource");
return NS_ERROR;
NotificationTopicResource.TopicList = NULL;
NotificationTopicResource.handle = NULL;
+ if(NSGetResourceSecurity())
+ {
+ NS_LOG(DEBUG, "Create secured resource");
+ resourceProperties = OC_DISCOVERABLE | OC_SECURE;
+ }
+ else
+ {
+ resourceProperties = OC_DISCOVERABLE;
+ }
+
if (OCCreateResource(&(NotificationTopicResource.handle), NS_COLLECTION_TOPIC_TYPE,
NS_DEFAULT_INTERFACE, NS_COLLECTION_TOPIC_URI, NSEntityHandlerTopicCb, NULL,
- OC_DISCOVERABLE) != OC_STACK_OK)
+ resourceProperties) != OC_STACK_OK)
{
NS_LOG(NS_ERROR, "Fail to Create Notification Sync Resource");
return NS_ERROR;