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 <dpl/ace/PolicyEnforcementPoint.h>
34 #include <dpl/assert.h>
35 #include <dpl/exception.h>
36 #include <dpl/log/log.h>
38 #include <dpl/ace/PolicyEvaluatorFactory.h>
39 #include <dpl/ace/PolicyResult.h>
40 #include <dpl/ace/Request.h>
42 using namespace WrtDB;
44 PolicyEnforcementPoint::PolicyEnforcementPoint() :
52 void PolicyEnforcementPoint::terminate()
54 LogInfo("PolicyEnforcementPoint is being deinitialized.");
68 PolicyEnforcementPoint::~PolicyEnforcementPoint()
70 Assert((m_sys == 0) && "You must run "
71 "PolicyEnforcementPoint::Deinitialize before exit program!");
74 void PolicyEnforcementPoint::initialize(
76 IResourceInformation *resource,
77 IOperationSystem *operation)
80 ThrowMsg(PEPException::AlreadyInitialized,
81 "Policy Enforcement Point is already initialzed");
88 if (this->m_pip != NULL) {
89 this->m_pip->update(m_wrt, m_res, m_sys);
93 this->m_pip = new PolicyInformationPoint(wrt, m_res, m_sys);
94 this->m_pdp = new PolicyEvaluator(m_pip);
96 if (!this->m_pdp->initPDP()) {
101 PolicyResult PolicyEnforcementPoint::check(Request &request)
103 return m_pdp->getPolicyForRequest(request);
106 void PolicyEnforcementPoint::updatePolicy(const std::string &policy)
108 LogDebug("ACE updatePolicy: " << policy);
112 LogError("Evaluator not set. Ignoring message.");
113 Assert(false && "UpdateClient error on receiving event");
115 LogDebug("Emitting update signal.");
116 errorCode = m_pdp->updatePolicy(policy.c_str());
119 LogDebug("Sending reponse: " << errorCode);
122 OptionalPolicyResult PolicyEnforcementPoint::checkFromCache(Request &request)
124 return m_pdp->getPolicyForRequestFromCache(request);
125 // return OptionalPolicyResult();
128 OptionalPolicyResult PolicyEnforcementPoint::check(Request &request,
131 return m_pdp->getPolicyForRequest(request, fromCacheOnly);
132 // return OptionalPolicyResult();