PLCnext API Documentation 24.0.0.71
RscServerContext.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Rsc/Services/Rsc.h"
9#include "Arp/System/Rsc/Services/RscReader.hpp"
10#include "Arp/System/Rsc/Services/RscWriter.hpp"
11#include "Arp/System/Rsc/Services/RscChannelInfo.hpp"
12#include "Arp/System/Security/SecurityToken.hpp"
13#include "Arp/System/Security/SecurityContext.hpp"
14
15namespace CommonRemoting
16{
17
18class RemotingServerContext;
19
20}
21
22namespace Arp { namespace System { namespace Security { namespace Services
23{
24
25class PasswordConfigurationService2Impl;
26class PasswordAuthenticationServiceImpl;
27
28}}}} // end of namespace Arp::System::Security::Services
29
30
31namespace Arp { namespace System { namespace Rsc { namespace Services
32{
33
34using namespace CommonRemoting;
35
40class RscServerContext
41{
42 friend class Arp::System::Security::Services::PasswordConfigurationService2Impl;
43 friend class Arp::System::Security::Services::PasswordAuthenticationServiceImpl;
44
45public: // typedefs
46 typedef Arp::System::Security::SecurityToken SecurityToken;
47 typedef Arp::System::Security::SecurityContext SecurityContext;
48
49public: // construction/destruction
51 RscServerContext(RemotingServerContext& remotingServerContext);
53 RscServerContext(const RscServerContext& arg) = default;
55 RscServerContext& operator=(const RscServerContext& arg) = default;
57 ~RscServerContext(void);
58
59public: // static operations
60 static bool HasCurrent(void);
61 static RscServerContext& GetCurrent(void);
62
63public: // setter/getter operations
64 bool IsSecure(void)const;
65 const RscChannelInfo& GetChannelInfo(void)const;
66 SecurityToken GetSecurityToken(void)const;
67 RscReader& GetReader();
68 RscWriter& GetWriter();
69
70public: // operations
71 void AbortRequest(RscErrors errorCode, const char* errorMessage = NULL);
72 void AbortConnection(RscErrors errorCode, const char* errorMessage = NULL);
73 void AbortInvocation(RscErrors errorCode, const char* errorMessage = NULL);
74
75private: // security methods used by PasswordConfigurationService2Impl
76 bool HasSecurityContext(void);
77 bool HasSessionSecurityToken(const SecurityToken& token);
78 bool AddSessionSecurityToken(const SecurityToken& token, uint32 initialTimeoutMs);
79 bool RemoveSessionSecurityToken(const SecurityToken& token);
80
81private: // fields
82 RemotingServerContext& remotingServerContext;
83 RscChannelInfo channelInfo;
84 SecurityToken securityToken; // never remove this, it is passed and stored as ref to security context
85 SecurityContext securityContext;
86 RscReader rscReader;
87 RscWriter rscWriter;
88
89private: // static fields
90 static thread_local RscServerContext* pCurrentServerContext;
91};
92
94// inline methods of class RscServerContext
95inline const RscChannelInfo& RscServerContext::GetChannelInfo(void)const
96{
97 return this->channelInfo;
98}
99
100inline RscReader& RscServerContext::GetReader()
101{
102 return this->rscReader;
103}
104
105inline RscWriter& RscServerContext::GetWriter()
106{
107 return this->rscWriter;
108}
109}}}} // end of namespace Arp::System::Rsc::Services
Definition: SecurityContext.hpp:21
Definition: SecurityToken.hpp:12
std::uint32_t uint32
The Arp unsigned integer type of 4 byte size.
Definition: PrimitiveTypes.hpp:36
Root namespace for the PLCnext API