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
26 #include "policyengine.h"
27 #include "securevirtualresourcetypes.h"
28 #include "cainterface.h"
32 typedef struct PEContext PEContext_t;
34 * @brief The AMS context..
36 typedef struct AmsMgrContext
38 OicUuid_t amsDeviceId; /**< DeviceID of the oic.sec.ams service. */
39 CAEndpoint_t *endpoint;
40 CARequestInfo_t *requestInfo;
45 * @brief This method updates AmsMgr context's endpoint & requestInfo
47 * @param context Policy engine context.
48 * @param endpoint CA Endpoint info of the requester
49 * @param requestInfo CA RequestInfo of the requester
51 OCStackResult UpdateAmsMgrContext(PEContext_t *context, const CAEndpoint_t *endpoint,
52 const CARequestInfo_t *requestInfo);
56 * This method is called by PolicyEngine to Discover AMS service.
57 * It sends muticast discovery request such as
58 * /oic/sec/doxm?deviceid="AMSSrvcDeviceID" to discover AMS service
59 * with deviceId="AMSSrvcDeviceID"
61 * @param context Policy engine context.
64 * OC_STACK_OK If able to successfully send multicast discovery request.
65 * OC_STACK_ERROR If unable to successfully send multicast discovery request due to error.
68 OCStackResult DiscoverAmsService(PEContext_t *context);
73 * This method sends unicast request to retrieve the secured port info of the
74 * discovered AMS service. It sends unicast discovery request such as
75 * /oic/res?rt="oic.sec.doxm" to the discovered AMS service
77 * @param context Policy engine context.
80 * OC_STACK_OK If able to successfully send unicast discovery request
81 * OC_STACK_ERROR If unable to successfully send unicast discovery request due to error
84 OCStackResult SendUnicastSecurePortDiscovery(PEContext_t *context,OCDevAddr *devAddr,
85 OCConnectivityType connType);
90 * This method sends unicast request to AMS service to get ACL for
91 * the Subject and/or Resource. It sends unicast request such as
92 * /oic/sec/acl?sub="subjectId";rsrc="/a/led" to get the ACL for
93 * the subject & resource
95 * @param context Policy engine context.
98 * OC_STACK_OK If able to successfully send unicast ACL request
99 * OC_STACK_ERROR If unable to successfully send unicast ACL request due to error
102 OCStackResult SendAclReq(PEContext_t *context, OCDevAddr *devAddr, OCConnectivityType connType,
103 uint16_t securedPort);
107 * Cleanup CARequestInfo_t object
108 * @param requestInfo pointer to RequestInfo_t object
110 void FreeCARequestInfo(CARequestInfo_t *requestInfo);
114 * This method is used by Policy engine to checks Amacl resource.
115 * If Amacl is found then it fills up context->amsMgrContext->amsDeviceId
116 * with amsID of the Amacl else leaves it empty.
118 * @param context Policy engine context.
120 * @return true if AMacl for the resource is found
121 * false if AMacl for the resource is not found
123 bool FoundAmaclForRequest(PEContext_t *context);
127 * This method is used by Policy engine to process AMS request
129 * @param context Policy engine context.
132 void ProcessAMSRequest(PEContext_t *context);
136 * This method is used by Policy engine to free AMS context requestInfo
138 * @param requestInfo pointer to CARequestInfo_t.
141 void FreeCARequestInfo(CARequestInfo_t *requestInfo);
143 #endif //IOTVT_SRM_AMSMGR_H