1 //******************************************************************
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef IOTVT_SRM_AMSMGR_H
22 #define IOTVT_SRM_AMSMGR_H
29 #include "policyengine.h"
30 #include "securevirtualresourcetypes.h"
31 #include "cainterface.h"
33 typedef struct PEContext PEContext_t;
37 typedef struct AmsMgrContext
39 OicUuid_t amsDeviceId; /**< DeviceID of the oic.sec.ams service. */
40 CAEndpoint_t *endpoint;
41 CARequestInfo_t *requestInfo;
45 * This method updates AmsMgr context's endpoint & requestInfo.
47 * @param context is the policy engine context.
48 * @param endpoint is the CA Endpoint info of the requester.
49 * @param requestInfo is the CA RequestInfo of the requester.
51 * @return ::OC_STACK_OK if successful, else other value in case of error.
53 OCStackResult UpdateAmsMgrContext(PEContext_t *context,
54 const CAEndpoint_t *endpoint,
55 const CARequestInfo_t *requestInfo);
58 * This method is called by PolicyEngine to Discover AMS service.
59 * It sends muticast discovery request such as
60 * /oic/sec/doxm?deviceid="AMSSrvcDeviceID" to discover AMS service
61 * with deviceId="AMSSrvcDeviceID".
63 * @param context is the policy engine context.
65 * @return ::OC_STACK_OK,If able to successfully send multicast discovery request.
66 * else ::OC_STACK_ERROR, If unable to successfully send multicast discovery request
69 OCStackResult DiscoverAmsService(PEContext_t *context);
72 * This method sends unicast request to retrieve the secured port info of the
73 * discovered AMS service. It sends unicast discovery request such as
74 * /oic/res?rt="oic.sec.doxm" to the discovered AMS service.
76 * @param context is the policy engine context.
78 * @return ::OC_STACK_OK,If able to successfully send unicast discovery request.
79 * else ::OC_STACK_ERROR, If unable to successfully send unicast discovery request
82 OCStackResult SendUnicastSecurePortDiscovery(PEContext_t *context,
84 OCConnectivityType connType);
87 * This method sends unicast request to AMS service to get ACL for
88 * the Subject and/or Resource. It sends unicast request such as
89 * /oic/sec/acl?sub="subjectId";rsrc="/a/led" to get the ACL for
90 * the subject & resource.
92 * @param context is the policy engine context.
94 * @return ::OC_STACK_OK, If able to successfully send unicast ACL request.
95 * ::OC_STACK_ERROR, If unable to successfully send unicast ACL request due to error.
98 OCStackResult SendAclReq(PEContext_t *context,
100 OCConnectivityType connType,
101 uint16_t securedPort);
104 * Cleanup CARequestInfo_t object.
106 * @param requestInfo is the pointer to @ref CARequestInfo_t.
108 void FreeCARequestInfo(CARequestInfo_t *requestInfo);
111 * This method is used by Policy engine to checks Amacl resource.
112 * If Amacl is found then it fills up context->amsMgrContext->amsDeviceId
113 * with amsID of the Amacl else leaves it empty.
115 * @param context is the policy engine context.
117 * @return true, if Amacl for the resource is found. false, if Amacl for the
118 * resource is not found
120 bool FoundAmaclForRequest(PEContext_t *context);
123 * This method is used by Policy engine to process AMS request.
125 * @param context is the policy engine context.
127 void ProcessAMSRequest(PEContext_t *context);
130 * This method is used by Policy engine to free AMS context requestInfo/
132 * @param requestInfo is the pointer to @ref CARequestInfo_t.
134 void FreeCARequestInfo(CARequestInfo_t *requestInfo);
136 #endif //IOTVT_SRM_AMSMGR_H