From a88dfa00f57be2e4d8d72179f120944b10565089 Mon Sep 17 00:00:00 2001 From: "jaesick.shin" Date: Tue, 23 Aug 2016 18:44:00 +0900 Subject: [PATCH] Restrict topic list control when Provider does not have permission. If provider does not have the comsumer subscription accept capability following topic related API should not work. 1. NSProviderSelectTopic 2. NSProviderUnselectTopic Change-Id: I197a60a0aae5eef3226f3766f1b793594628a9f9 Signed-off-by: jaesick.shin Reviewed-on: https://gerrit.iotivity.org/gerrit/10795 Reviewed-by: Uze Choi Tested-by: Uze Choi --- service/notification/src/provider/NSProviderInterface.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/service/notification/src/provider/NSProviderInterface.c b/service/notification/src/provider/NSProviderInterface.c index 6c9331f..7648278 100644 --- a/service/notification/src/provider/NSProviderInterface.c +++ b/service/notification/src/provider/NSProviderInterface.c @@ -320,10 +320,11 @@ NSResult NSProviderSelectTopic(char *consumerId, char *topicName) NS_LOG(DEBUG, "NSProviderSelectTopics - IN"); pthread_mutex_lock(&nsInitMutex); - if(!consumerId || !topicName) + if(!consumerId || !topicName || !NSGetPolicy()) { + NS_LOG(DEBUG, "consumer id should be set for topic subscription or " + "Configuration must set to true."); pthread_mutex_unlock(&nsInitMutex); - NS_LOG(DEBUG, "consumer id should be set for topic subscription"); return NS_FAIL; } @@ -345,9 +346,10 @@ NSResult NSProviderUnselectTopic(char *consumerId, char *topicName) NS_LOG(DEBUG, "NSProviderUnselectTopics - IN"); pthread_mutex_lock(&nsInitMutex); - if(!consumerId || !topicName) + if(!consumerId || !topicName || !NSGetPolicy()) { - NS_LOG(DEBUG, "consumer id should be set for topic subscription"); + NS_LOG(DEBUG, "consumer id should be set for topic subscription or " + "Configuration must set to true."); pthread_mutex_unlock(&nsInitMutex); return NS_FAIL; } -- 2.7.4