#include <iostream>
public:
using AccessControlDefault::AccessControlDefault;
) override {
const bool isAdmin = (token != nullptr && token->getUserName() == "admin");
std::cout << "User has admin rights: " << isAdmin << std::endl;
return AccessControlDefault::activateSession(
session, endpointDescription, secureChannelRemoteCertificate, userIdentityToken
);
}
std::cout <<
"Get user access level of node id " << nodeId.
toString() << std::endl;
std::cout << "Admin rights granted: " << isAdmin << std::endl;
return isAdmin
? AccessLevel::CurrentRead | AccessLevel::CurrentWrite
: AccessLevel::CurrentRead;
}
};
int main() {
AccessControlCustom accessControl(
true,
{
{"admin", "admin"},
{"user", "user"},
}
);
Node(server, ObjectId::ObjectsFolder)
{1, 1000},
"Variable",
.setDataType(DataTypeId::Int32)
.setValueRank(ValueRank::Scalar)
.setValueScalar(0)
);
}
Bitmask using (scoped) enums.
UA_ByteString wrapper class.
UA_EndpointDescription wrapper class.
UA_ExtensionObject wrapper class.
T * getDecodedData() noexcept
Get pointer to the decoded data with given template type.
std::string toString() const
Encode NodeId as a string like ns=1;s=SomeNode.
High-level node class to access node attribute, browse and populate address space.
Node addVariable(const NodeId &id, std::string_view browseName, const VariableAttributes &attributes={}, const NodeId &variableType=VariableTypeId::BaseDataVariableType, const NodeId &referenceType=ReferenceTypeId::HasComponent)
Add variable.
void run()
Run the server's main loop. This method will block until Server::stop is called.
void setAccessControl(AccessControlBase &accessControl)
Set custom access control.
High-level session class to manage client sessions.
void setSessionAttribute(const QualifiedName &key, const Variant &value)
Attach a session attribute as a key-value pair.
Variant getSessionAttribute(const QualifiedName &key)
Get a session attribute by its key.
UA_StatusCode wrapper class.
UA_UserNameIdentityToken wrapper class.
UA_VariableAttributes wrapper class.
auto & setAccessLevel(Bitmask< AccessLevel > accessLevel) noexcept