/* ========================================================================
* Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
using System.Collections.Generic;
namespace Opc.Ua.Server
{
///
/// Immutable snapshot of a role's configuration per OPC UA Part 18 §4.4.
///
///
/// Returned by methods that expose role state to
/// the address-space binding () and to test
/// code. The lists are caller-owned copies; mutating them does not affect
/// the manager.
///
public sealed class RoleEntry
{
internal RoleEntry(
NodeId roleId,
string? browseName,
ushort namespaceIndex,
bool isReserved,
bool isWellKnown,
IReadOnlyList identities,
IReadOnlyList applications,
bool applicationsExclude,
IReadOnlyList endpoints,
bool endpointsExclude,
bool customConfiguration)
{
RoleId = roleId;
BrowseName = browseName;
NamespaceIndex = namespaceIndex;
IsReserved = isReserved;
IsWellKnown = isWellKnown;
Identities = identities;
Applications = applications;
ApplicationsExclude = applicationsExclude;
Endpoints = endpoints;
EndpointsExclude = endpointsExclude;
CustomConfiguration = customConfiguration;
}
///
/// The role's NodeId (e.g. Opc.Ua.ObjectIds.WellKnownRole_Observer).
///
public NodeId RoleId { get; }
///
/// Browse name of the role; null for unnamed dynamic roles where
/// the manager only tracks the NodeId.
///
public string? BrowseName { get; }
///
/// Namespace index for the role's NodeId.
///
public ushort NamespaceIndex { get; }
///
/// True if the role is one of the three reserved well-known roles
/// (Anonymous, AuthenticatedUser, TrustedApplication)
/// that the spec forbids from being modified or removed (Part 18 §4.3).
///
public bool IsReserved { get; }
///
/// True if the role is one of the nine well-known roles defined in
/// OPC UA Part 3 §4.9.2 (Anonymous, AuthenticatedUser, TrustedApplication,
/// Observer, Operator, Engineer, Supervisor, ConfigureAdmin, SecurityAdmin).
///
public bool IsWellKnown { get; }
///
/// Snapshot of identity-mapping rules per Part 18 §4.4.3. Treat as
/// read-only — modifications are not reflected back into the manager.
///
public IReadOnlyList Identities { get; }
///
/// Snapshot of ApplicationUris per Part 18 §4.4.1.
///
public IReadOnlyList Applications { get; }
///
/// True if is an exclude list.
///
public bool ApplicationsExclude { get; }
///
/// Snapshot of endpoints per Part 18 §4.4.1.
///
public IReadOnlyList Endpoints { get; }
///
/// True if is an exclude list.
///
public bool EndpointsExclude { get; }
///
/// True if the role uses vendor-specific configuration (Part 18 §4.4.1).
/// When true, the role may be granted even when
/// is empty.
///
public bool CustomConfiguration { get; }
}
}