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_PE_H
22 #define IOTVT_SRM_PE_H
26 #include "securevirtualresourcetypes.h"
27 #include "cainterface.h"
39 typedef struct PEContext
45 bool matchingAclFound;
46 SRMAccessResponse_t retVal;
50 * Check whether a request should be allowed.
52 * @param context Pointer to Policy Engine context to use.
53 * @param subjectId Pointer to Id of the requesting entity.
54 * @param resource Pointer to URI of Resource being requested.
55 * @param permission Requested permission.
57 * @return ACCESS_GRANTED if request should go through,
58 * otherwise some flavor of ACCESS_DENIED
60 SRMAccessResponse_t CheckPermission(
62 const OicUuid_t *subjectId,
64 const uint16_t requestedPermission);
67 * Initialize the Policy Engine. Call this before calling CheckPermission().
68 * TODO Eventually this and DeInit() need to be called from a new
69 * "SRMInit(SRMContext_t *)" function, TBD after BeachHead.
70 * @param context Pointer to Policy Engine context to initialize.
71 * @return OC_STACK_OK for Success, otherwise some error value
73 OCStackResult InitPolicyEngine(PEContext_t *context);
76 * De-Initialize the Policy Engine. Call this before exiting to allow Policy
77 * Engine to do cleanup on context.
78 * @param context Pointer to Policy Engine context to de-initialize.
81 void DeInitPolicyEngine(PEContext_t *context);
84 * Return the uint16_t CRUDN permission corresponding to passed CAMethod_t.
86 uint16_t GetPermissionFromCAMethod_t(const CAMethod_t method);
88 #endif //IOTVT_SRM_PE_H