olp-cpp-sdk  1.19.0
Public Types | Public Member Functions | List of all members
olp::authentication::AuthorizeRequest Class Referencefinal

Encapsulates the fields required to make a policy decision for a given request context against the HERE Service. More...

#include <AuthorizeRequest.h>

Public Types

enum class  DecisionOperatorType { kAnd , kOr }
 Determines the overall policy decision based on individual decisions for each action. More...
 
using Action = std::pair< std::string, std::string >
 An alias for the action pair. More...
 
using Actions = std::vector< Action >
 An alias for the vector of actions.
 

Public Member Functions

const std::string & GetServiceId () const
 Gets the ID of the requested service. More...
 
AuthorizeRequestWithServiceId (std::string service_id)
 Sets the service ID. More...
 
const boost::optional< std::string > & GetContractId () const
 Gets the contract ID. More...
 
AuthorizeRequestWithContractId (boost::optional< std::string > contract_id)
 Sets the contract ID. More...
 
AuthorizeRequestWithContractId (std::string contract_id)
 Sets the contract ID. More...
 
const ActionsGetActions () const
 Gets all actions. More...
 
AuthorizeRequestWithAction (std::string action, std::string resource="")
 Adds the action-resource pair. More...
 
DecisionOperatorType GetOperatorType () const
 Gets the operator type. More...
 
AuthorizeRequestWithOperatorType (DecisionOperatorType operator_type)
 Sets the operator type for the request. More...
 
bool GetDiagnostics () const
 Gets the diagnostics flag. More...
 
AuthorizeRequestWithDiagnostics (bool diagnostics)
 Sets the diagnostics flag for the request. More...
 
std::string CreateKey () const
 Creates a readable format for the request. More...
 

Detailed Description

Encapsulates the fields required to make a policy decision for a given request context against the HERE Service.

Collects all permissions associated with the authenticated user or application, requested service ID, and requested contract ID. For each action-resource pair in the request, this class determines an individual policy decision: DENY or ALLOW.

Member Typedef Documentation

◆ Action

using olp::authentication::AuthorizeRequest::Action = std::pair<std::string, std::string>

An alias for the action pair.

The first parameter is the type of action. The second one is optional and represents the resource.

Note
Each action-resource pair in the request has an individual policy decision.

Member Enumeration Documentation

◆ DecisionOperatorType

Determines the overall policy decision based on individual decisions for each action.

Note
If the operator is 'or' and ANY actions have an individual policy decision of ALLOW, the overall policy decision returned in the response is ALLOW. If the operator is 'and' or missing (defaults to 'and'), one of the following algorithms is applied:
  • If ANY actions have an individual policy decision of DENY, the overall policy decision returned in the response is DENY.
  • If ALL actions have an individual policy decision of ALLOW, the overall policy decision returned in the response is ALLOW.

Member Function Documentation

◆ CreateKey()

std::string olp::authentication::AuthorizeRequest::CreateKey ( ) const

Creates a readable format for the request.

Returns
A string representation of the request.

◆ GetActions()

const Actions& olp::authentication::AuthorizeRequest::GetActions ( ) const
inline

Gets all actions.

Returns
The vector of the actions (action-resource pairs).

◆ GetContractId()

const boost::optional<std::string>& olp::authentication::AuthorizeRequest::GetContractId ( ) const
inline

Gets the contract ID.

Note
: If the contract ID is not provided in the request, one of the following happens:
  • If you have permissions for a single contract ID associated with the requested service ID, the system automatically determines the contract ID.
  • If you have permissions for multiple contract IDs, the 'Contract Required' error is returned.
Returns
The contract ID or an error.

◆ GetDiagnostics()

bool olp::authentication::AuthorizeRequest::GetDiagnostics ( ) const
inline

Gets the diagnostics flag.

Returns
The diagnostics flag.

◆ GetOperatorType()

DecisionOperatorType olp::authentication::AuthorizeRequest::GetOperatorType ( ) const
inline

Gets the operator type.

If the operator type is not set, the 'and' type is used in the request.

See also
DecisionApiOperatorType for more information.
Returns
The operator type.

◆ GetServiceId()

const std::string& olp::authentication::AuthorizeRequest::GetServiceId ( ) const
inline

Gets the ID of the requested service.

Returns
The service ID.

◆ WithAction()

AuthorizeRequest& olp::authentication::AuthorizeRequest::WithAction ( std::string  action,
std::string  resource = "" 
)
inline

Adds the action-resource pair.

Parameters
[in]actionThe action that is used to determine an individual policy decision.
[in]resourceThe resource that is used to request the decision for the action.
Returns
A reference to the updated DecisionRequest instance.

◆ WithContractId() [1/2]

AuthorizeRequest& olp::authentication::AuthorizeRequest::WithContractId ( boost::optional< std::string >  contract_id)
inline

Sets the contract ID.

See also
GetContractId for information on the contract ID.
Parameters
contract_idYour contract ID.
Returns
A reference to the updated DecisionRequest instance.

◆ WithContractId() [2/2]

AuthorizeRequest& olp::authentication::AuthorizeRequest::WithContractId ( std::string  contract_id)
inline

Sets the contract ID.

See also
GetContractId for information on the contract ID.
Parameters
contract_idYour contract ID.
Returns
A reference to the updated DecisionRequest instance.

◆ WithDiagnostics()

AuthorizeRequest& olp::authentication::AuthorizeRequest::WithDiagnostics ( bool  diagnostics)
inline

Sets the diagnostics flag for the request.

Parameters
diagnosticsThe flag used to turn on or off the diagnostic information in the response.
Returns
A reference to the updated DecisionRequest instance.

◆ WithOperatorType()

AuthorizeRequest& olp::authentication::AuthorizeRequest::WithOperatorType ( DecisionOperatorType  operator_type)
inline

Sets the operator type for the request.

See also
GetOperatorType() for information on usage and format.
Parameters
operator_typeThe DecisionApiOperatorType enum.
Returns
A reference to the updated DecisionRequest instance.

◆ WithServiceId()

AuthorizeRequest& olp::authentication::AuthorizeRequest::WithServiceId ( std::string  service_id)
inline

Sets the service ID.

Parameters
service_idThe service ID.
Returns
A reference to the updated DecisionRequest instance.

The documentation for this class was generated from the following file: