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 SECURITYRESOURCEMANAGER_H_
22 #define SECURITYRESOURCEMANAGER_H_
24 #include "securevirtualresourcetypes.h"
31 * Register Persistent storage callback.
33 * @param persistentStorageHandler [IN] Pointers to open, read, write, close & unlink handlers.
35 * @return ::OC_STACK_OK is no errors and successful. ::OC_STACK_INVALID_PARAM for invalid parameter.
37 OCStackResult SRMRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler);
40 * Get Persistent storage handler pointer.
42 * @return The pointer to Persistent Storage callback handler.
44 OCPersistentStorage* SRMGetPersistentStorageHandler();
47 * Register request and response callbacks. Requests and responses are delivered in these callbacks.
49 * @param reqHandler Request handler callback ( for GET,PUT ..etc)
50 * @param respHandler Response handler callback.
51 * @param errHandler Error handler callback.
53 * @return ::OC_STACK_OK is no errors and successful. ::OC_STACK_INVALID_PARAM for invalid parameter.
55 OCStackResult SRMRegisterHandler(CARequestCallback reqHandler,
56 CAResponseCallback respHandler,
57 CAErrorCallback errHandler);
60 * Initialize all secure resources ( /oic/sec/cred, /oic/sec/acl, /oic/sec/pstat etc).
61 * @return ::OC_STACK_OK for Success, otherwise some error value.
63 OCStackResult SRMInitSecureResources();
66 * Perform cleanup for secure resources ( /oic/sec/cred, /oic/sec/acl, /oic/sec/pstat etc).
68 void SRMDeInitSecureResources();
71 * Initialize Policy Engine context.
73 * @return ::OC_STACK_OK for Success, otherwise some error value.
75 OCStackResult SRMInitPolicyEngine();
78 * Cleanup Policy Engine context.
80 void SRMDeInitPolicyEngine();
83 * Provisioning API response callback.
85 * @param object endpoint instance.
86 * @param responseInfo instance of CAResponseInfo_t structure.
88 * @return true if received response is for provisioning API false otherwise.
90 typedef bool (*SPResponseCallback) (const CAEndpoint_t *object,
91 const CAResponseInfo_t *responseInfo);
94 * Function to register provisoning API's response callback.
96 * @param respHandler response handler callback.
98 void SRMRegisterProvisioningResponseHandler(SPResponseCallback respHandler);
101 * Check the security resource URI.
102 * @param uri Pointers to security resource URI.
103 * @return true if the URI is one of security resources, otherwise false.
105 bool SRMIsSecurityResourceURI(const char* uri);
108 * Check whether persistent storage is valid
109 * @return OC_STACK_OK if valid, other errors otherwise;
111 OCStackResult CheckPersistentStorage(OCPersistentStorage* persistentStorageHandler);
114 * Get the resource type from the URI.
115 * @param uri [IN] Pointers to security resource URI.
116 * @return SVR type (note that "NOT_A_SVR_RESOURCE" is returned if not a SVR)
118 OicSecSvrType_t GetSvrTypeFromUri(const char* uri);
122 * @param resposeVal SRMAccessResponse_t value
125 void SRMSendResponse(SRMAccessResponse_t responseVal);
132 #endif /* SECURITYRESOURCEMANAGER_H_ */