PLCnext API Documentation 25.0.2.69
SecurityToken.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
7#ifndef ARP_USE_ARP_SYSTEM_SECURITY
8#include "Arp/Base/Commons/Security/SecurityContext.hpp"
10{
12}
13#else
14#include "Arp/System/Core/Arp.h"
15namespace Arp { namespace System { namespace Security
16{
17
18class ARP_EXPORT SecurityToken
19{
20public: // usings
21 using Value = uint32;
22
23public: // static fields
24 const static Value None = 0;
25 const static size_t Size = sizeof(Value);
26
27public: // construction
28 SecurityToken(Value value = None);
29 SecurityToken(const SecurityToken& arg);
30 SecurityToken(SecurityToken&& arg) = default;
31 SecurityToken& operator=(const SecurityToken& arg);
32 SecurityToken& operator=(SecurityToken&& arg) = default;
33 ~SecurityToken() = default;
34
35public: // global operators
36 friend bool operator<(const SecurityToken& lhs, const SecurityToken& rhs);
37 friend bool operator==(const SecurityToken& lhs, const SecurityToken& rhs);
38
39public: // getter/setter
40 bool HasValue(void)const;
41 Value GetValue(void)const;
42
43public: // operations
44 String ToString(void)const;
45
46private: // fields
47 Value value;
48};
49
51// inline methods of class SecurityToken
52inline SecurityToken::SecurityToken(Value valueArg)
53 : value(valueArg)
54{
55}
56
57inline SecurityToken::SecurityToken(const SecurityToken& arg)
58 : value(arg.value)
59{
60}
61
62inline SecurityToken& SecurityToken::operator=(const SecurityToken& arg)
63{
64 this->value = arg.value;
65 return *this;
66}
67
68inline bool SecurityToken::HasValue()const
69{
70 return this->value != None;
71}
72
73inline SecurityToken::Value SecurityToken::GetValue()const
74{
75 return this->value;
76}
77
79// inline global operators of class SecurityToken
80inline bool operator<(const SecurityToken& lhs, const SecurityToken& rhs)
81{
82 return lhs.GetValue() < rhs.GetValue();
83}
84
85inline bool operator==(const SecurityToken& lhs, const SecurityToken& rhs)
86{
87 return lhs.GetValue() == rhs.GetValue();
88}
89
90}}} // end of namespace Arp::System::Security
91#endif // ndef ARP_USE_ARP_SYSTEM_SECURITY
This class is used for authorization of arbitrary operations.
Definition: SecurityToken.hpp:18
SecurityToken(Value value=GetNone())
Constructs a SecurityToken instance.
Definition: SecurityToken.cpp:55
std::uint32_t uint32
The Arp unsigned integer type of 4 byte size.
Definition: PrimitiveTypes.hpp:33
Namepsace for classes used in the RSC security implementation
Root namespace for the PLCnext API