2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file security_logic.cpp
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
19 * @author Ming Jin(ming79.jin@samsung.com)
21 * @brief Implementation file for security logic
23 #include <ace/PolicyEnforcementPoint.h>
34 #include <dpl/assert.h>
35 #include <dpl/exception.h>
36 #include <dpl/log/log.h>
38 #include <ace/PolicyEvaluatorFactory.h>
39 #include <ace/PolicyResult.h>
40 #include <ace/Request.h>
42 PolicyEnforcementPoint::PolicyEnforcementPoint() :
50 void PolicyEnforcementPoint::terminate()
52 LogInfo("PolicyEnforcementPoint is being deinitialized.");
66 PolicyEnforcementPoint::~PolicyEnforcementPoint()
68 Assert((m_sys == 0) && "You must run "
69 "PolicyEnforcementPoint::Deinitialize before exit program!");
72 void PolicyEnforcementPoint::initialize(
74 IResourceInformation *resource,
75 IOperationSystem *operation)
78 ThrowMsg(PEPException::AlreadyInitialized,
79 "Policy Enforcement Point is already initialzed");
86 if (this->m_pip != NULL) {
87 this->m_pip->update(m_wrt, m_res, m_sys);
91 this->m_pip = new PolicyInformationPoint(wrt, m_res, m_sys);
92 this->m_pdp = new PolicyEvaluator(m_pip);
94 if (!this->m_pdp->initPDP()) {
99 ExtendedPolicyResult PolicyEnforcementPoint::check(Request &request)
101 return m_pdp->getPolicyForRequest(request);
104 void PolicyEnforcementPoint::updatePolicy(const std::string &policy)
106 LogDebug("ACE updatePolicy: " << policy);
110 LogError("Evaluator not set. Ignoring message.");
111 Assert(false && "UpdateClient error on receiving event");
113 LogDebug("Emitting update signal.");
114 errorCode = m_pdp->updatePolicy(policy.c_str());
117 LogDebug("Sending reponse: " << errorCode);
120 void PolicyEnforcementPoint::updatePolicy()
122 LogDebug("ACE updatePolicy");
124 LogError("Evaluator not set. Ignoring message.");
126 m_pdp->updatePolicy();
130 OptionalExtendedPolicyResult PolicyEnforcementPoint::checkFromCache(Request &request)
132 return m_pdp->getPolicyForRequestFromCache(request);
135 OptionalExtendedPolicyResult PolicyEnforcementPoint::check(Request &request,
138 return m_pdp->getPolicyForRequest(request, fromCacheOnly);