xentara-plugin v2.0.3
The Xentara Plugin Framework
Loading...
Searching...
No Matches
xentara::security::Entitlement Class Referencefinal

An entitlement that can be used to restrict access to a protected resource. More...

#include <xentara/security/Entitlement.hpp>

+ Inheritance diagram for xentara::security::Entitlement:

Public Member Functions

constexpr Entitlement (const utils::core::Uuid &uuid, std::string_view name, bool allowedByDefault)
 Constructor.
 
constexpr auto name () const -> const std::string_view &
 Gets the name.
 
constexpr auto uuid () const -> const utils::core::Uuid &
 Gets the UUID.
 
constexpr auto allowedByDefault () const noexcept -> bool
 Determine if the entitlement will be allowed by default.
 
template<std::equality_comparable_with< std::string_view > String>
auto operator== (const String &rhs) const -> bool
 Checks the name of the entitlement.
 

Static Public Attributes

Built-In entitlements
static const Entitlement kRead
 The entitlement for read access.
 
static const Entitlement kWrite
 The entitlement for write access.
 
static const Entitlement KSuspend
 The entitlement for suspend stage.
 
static const Entitlement KShutdown
 The entitlement for shutdown stage.
 
Special entitlements
static const Entitlement kAllow
 An entitlement that is always allowed.
 
static const Entitlement kDeny
 An entitlement that is always denied.
 

Detailed Description

An entitlement that can be used to restrict access to a protected resource.

Constructor & Destructor Documentation

◆ Entitlement()

constexpr xentara::security::Entitlement::Entitlement ( const utils::core::Uuid uuid,
std::string_view  name,
bool  allowedByDefault 
)
constexpr

Constructor.

Parameters
uuidThe UUID of the entitlement
nameThe name of the entitlement, in UTF-8 encoding. The string data the view references to is not copied. It must remain valid for the lifetime of the entitlement.
allowedByDefaulttrue to allow the entitlement by default, or false if the entitlement must be explicitly allowed in an ACL.

Member Function Documentation

◆ allowedByDefault()

constexpr auto xentara::security::Entitlement::allowedByDefault ( ) const -> bool
constexprnoexcept

Determine if the entitlement will be allowed by default.

Returns
Returns true if the entitlement is allowed unless it is explicitly denied in an ACL. If this function returns false, the entitlement is denied unless it is explicitly allowed in an ACL.

◆ name()

constexpr auto xentara::security::Entitlement::name ( ) const -> const std::string_view &
constexpr

Gets the name.

Returns
The name, in UTF-8 encoding

◆ operator==()

template<std::equality_comparable_with< std::string_view > String>
auto xentara::security::Entitlement::operator== ( const String &  rhs) const -> bool

Checks the name of the entitlement.

This is a convenience operator you can use to check the name of an entitlement when resolving it. It is equivalent to name() == rhs.

Returns
Returns true if the entitlement has the given name.

◆ uuid()

constexpr auto xentara::security::Entitlement::uuid ( ) const -> const utils::core::Uuid &
constexpr

Gets the UUID.

Member Data Documentation

◆ kAllow

const Entitlement xentara::security::Entitlement::kAllow
static

An entitlement that is always allowed.

This is a dummy entitlement that is always allowed. The entitlement is not allowed for default constructed authorization objects that have no entitlements whatsoever.

Note
This entitement has no name and no UUID.

◆ kDeny

const Entitlement xentara::security::Entitlement::kDeny
static

An entitlement that is always denied.

This is a dummy entitlement that is always denied.

Note
This entitement has no name and no UUID.

◆ kRead

const Entitlement xentara::security::Entitlement::kRead
static

The entitlement for read access.

◆ KShutdown

const Entitlement xentara::security::Entitlement::KShutdown
static

The entitlement for shutdown stage.

◆ KSuspend

const Entitlement xentara::security::Entitlement::KSuspend
static

The entitlement for suspend stage.

◆ kWrite

const Entitlement xentara::security::Entitlement::kWrite
static

The entitlement for write access.