olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
AuthorizeResult.h
1/*
2 * Copyright (C) 2020 HERE Europe B.V.
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 * License-Filename: LICENSE
18 */
19
20#pragma once
21
22#include <memory>
23#include <vector>
24
25#include <olp/authentication/AuthenticationApi.h>
26
27namespace olp {
28namespace authentication {
29
33enum class DecisionType { kAllow, kDeny };
34
39class AUTHENTICATION_API Permission {
40 public:
46 void SetAction(std::string action) { action_ = std::move(action); }
47
53 const std::string& GetAction() const { return action_; }
54
60 void SetResource(std::string resource) { resource_ = std::move(resource); }
61
67 const std::string& GetResource() const { return resource_; }
68
74 void SetDecision(DecisionType decision) { decision_ = decision; }
75
81 DecisionType GetDecision() const { return decision_; }
82
83 private:
84 std::string action_;
85 std::string resource_;
86 DecisionType decision_{DecisionType::kDeny};
87};
88
96class AUTHENTICATION_API ActionResult {
97 public:
105 const DecisionType& GetDecision() const { return decision_; }
106
112 void SetDecision(DecisionType decision) { decision_ = decision; }
113
129 const std::vector<Permission>& GetPermissions() const { return permissions_; }
130
136 void SetPermissions(std::vector<Permission> permissions) {
137 permissions_ = std::move(permissions);
138 }
139
140 private:
141 DecisionType decision_{DecisionType::kDeny};
142 std::vector<Permission> permissions_;
143};
144
154class AUTHENTICATION_API AuthorizeResult {
155 public:
163 const DecisionType& GetDecision() const { return policy_decision_; }
164
170 void SetDecision(DecisionType decision) { policy_decision_ = decision; }
171
177 const std::string& GetClientId() const { return client_id_; }
178
184 void SetClientId(std::string client_id) { client_id_ = std::move(client_id); }
185
194 const std::vector<ActionResult>& GetActionResults() const {
195 return actions_results_;
196 }
197
203 void SetActionResults(std::vector<ActionResult> actions) {
204 actions_results_ = std::move(actions);
205 }
206
207 private:
208 DecisionType policy_decision_{DecisionType::kDeny};
209 std::string client_id_;
210 std::vector<ActionResult> actions_results_;
211};
212
213} // namespace authentication
214} // namespace olp
Represents each action-resource pair response with an individual policy decision for that action: DEN...
Definition AuthorizeResult.h:96
void SetDecision(DecisionType decision)
Sets the policy decision.
Definition AuthorizeResult.h:112
const std::vector< Permission > & GetPermissions() const
Gets the list of permissions that are evaluated against the action and resource.
Definition AuthorizeResult.h:129
void SetPermissions(std::vector< Permission > permissions)
Sets the list of permissions.
Definition AuthorizeResult.h:136
const DecisionType & GetDecision() const
Gets the overall policy decision.
Definition AuthorizeResult.h:105
Represents the policy decision for a given request context against the HERE Service.
Definition AuthorizeResult.h:154
const std::vector< ActionResult > & GetActionResults() const
Gets the list of results for each action.
Definition AuthorizeResult.h:194
const std::string & GetClientId() const
Gets the client ID.
Definition AuthorizeResult.h:177
void SetActionResults(std::vector< ActionResult > actions)
Sets the list of results for each action.
Definition AuthorizeResult.h:203
const DecisionType & GetDecision() const
Gets the overall policy decision.
Definition AuthorizeResult.h:163
void SetClientId(std::string client_id)
Sets the client ID.
Definition AuthorizeResult.h:184
void SetDecision(DecisionType decision)
Sets the overall policy decision.
Definition AuthorizeResult.h:170
Represents the permission with the action, policy decision, and associated resource.
Definition AuthorizeResult.h:39
void SetAction(std::string action)
Sets the action associated with the resource.
Definition AuthorizeResult.h:46
void SetResource(std::string resource)
Sets the resource with which the action and decision are associated.
Definition AuthorizeResult.h:60
const std::string & GetAction() const
Gets the action that is associated with the resource.
Definition AuthorizeResult.h:53
const std::string & GetResource() const
Gets the resource with which the action and decision are associated.
Definition AuthorizeResult.h:67
DecisionType GetDecision() const
Gets the decision associated with the resource.
Definition AuthorizeResult.h:81
void SetDecision(DecisionType decision)
Sets the decision associated with the resource.
Definition AuthorizeResult.h:74
DecisionType
Represents a policy decision: DENY or ALLOW.
Definition AuthorizeResult.h:33
Rules all the other namespaces.
Definition AppleSignInProperties.h:24