/* ========================================================================
* 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;
using System.Threading;
using System.Threading.Tasks;
using Opc.Ua.Client;
using Opc.Ua.Security.Certificates;
namespace Opc.Ua.Gds.Client
{
///
/// Public surface of . Exposes
/// the asynchronous operations that the push configuration client offers
/// against a connected server implementing the ServerConfiguration model.
///
public interface IServerPushConfigurationClient : IAsyncDisposable
{
/// The application configuration in use.
ApplicationConfiguration Configuration { get; }
/// The message context derived from the configuration.
IServiceMessageContext MessageContext { get; }
/// The administrator credentials used to elevate calls.
IUserIdentity? AdminCredentials { get; set; }
/// The endpoint URL of the connected server, when available.
string? EndpointUrl { get; }
/// true when an active session exists.
bool IsConnected { get; }
/// The active session, when connected.
ISession? Session { get; }
/// The endpoint to connect to. Write-once before connect.
ConfiguredEndpoint? Endpoint { get; set; }
/// Locales preferred by the client.
ArrayOf PreferredLocales { get; set; }
/// NodeId of the DefaultApplicationGroup.
NodeId DefaultApplicationGroup { get; }
/// NodeId of the DefaultHttpsGroup.
NodeId DefaultHttpsGroup { get; }
/// NodeId of the DefaultUserTokenGroup.
NodeId DefaultUserTokenGroup { get; }
/// NodeId of the application certificate type.
NodeId ApplicationCertificateType { get; }
/// Raised when administrator credentials are needed.
event EventHandler? AdminCredentialsRequired;
/// Raised when the connection status changes.
event EventHandler? ConnectionStatusChanged;
/// Raised on every keep-alive callback.
event KeepAliveEventHandler? KeepAlive;
/// Raised when monitored item notifications change server status.
event MonitoredItemNotificationEventHandler? ServerStatusChanged;
/// Clears the cached .
void ResetCredentials();
/// Connects using the previously assigned endpoint.
ValueTask ConnectAsync(CancellationToken ct = default);
/// Connects to the supplied endpoint URL.
ValueTask ConnectAsync(string endpointUrl, CancellationToken ct = default);
/// Connects to the supplied configured endpoint.
ValueTask ConnectAsync(ConfiguredEndpoint? endpoint, CancellationToken ct = default);
/// Disconnects the active session.
ValueTask DisconnectAsync(CancellationToken ct = default);
/// Returns the supported private-key formats.
/// Reads the SupportedPrivateKeyFormats property of ServerConfigurationType (OPC 10000-12 §7.10.2).
ValueTask> GetSupportedKeyFormatsAsync(CancellationToken ct = default);
/// Reads the trust list of the specified certificate group.
/// Reads the trust list via the file transfer methods of TrustListType (OPC 10000-12 §7.8).
ValueTask ReadTrustListAsync(
NodeId certificateGroupId,
TrustListMasks masks = TrustListMasks.All,
long maxTrustListSize = 0,
CancellationToken ct = default);
/// Reads the default-application-group trust list.
/// Reads the trust list via the file transfer methods of TrustListType (OPC 10000-12 §7.8).
ValueTask ReadTrustListAsync(
TrustListMasks masks = TrustListMasks.All,
long maxTrustListSize = 0,
CancellationToken ct = default);
/// Updates the default-application-group trust list.
/// Writes the trust list via the file transfer methods of TrustListType (OPC 10000-12 §7.8).
ValueTask UpdateTrustListAsync(
TrustListDataType trustList,
CancellationToken ct = default);
/// Updates the default-application-group trust list.
/// Writes the trust list via the file transfer methods of TrustListType (OPC 10000-12 §7.8).
ValueTask UpdateTrustListAsync(
TrustListDataType trustList,
long maxTrustListSize,
CancellationToken ct = default);
/// Updates the trust list of the specified certificate group.
/// Writes the trust list via the file transfer methods of TrustListType (OPC 10000-12 §7.8).
ValueTask UpdateTrustListAsync(
NodeId certificateGroupId,
TrustListDataType trustList,
long maxTrustListSize,
CancellationToken ct = default);
/// Adds a certificate to the trust list.
/// Calls the AddCertificate method on TrustListType (OPC 10000-12 §7.8.7).
ValueTask AddCertificateAsync(
Certificate certificate,
bool isTrustedCertificate,
CancellationToken ct = default);
/// Adds a certificate to the trust list.
/// Calls the AddCertificate method on TrustListType (OPC 10000-12 §7.8.7).
ValueTask AddCertificateAsync(
NodeId certificateGroupId,
Certificate certificate,
bool isTrustedCertificate,
CancellationToken ct = default);
/// Removes a certificate from the trust list.
/// Calls the RemoveCertificate method on TrustListType (OPC 10000-12 §7.8.8).
ValueTask RemoveCertificateAsync(
string thumbprint,
bool isTrustedCertificate,
CancellationToken ct = default);
/// Removes a certificate from the trust list.
/// Calls the RemoveCertificate method on TrustListType (OPC 10000-12 §7.8.8).
ValueTask RemoveCertificateAsync(
NodeId certificateGroupId,
string thumbprint,
bool isTrustedCertificate,
CancellationToken ct = default);
/// Lists the rejected certificates.
/// Calls the GetRejectedList method on ServerConfigurationType (OPC 10000-12 §7.10.6).
ValueTask GetRejectedListAsync(CancellationToken ct = default);
/// Creates a certificate signing request.
/// Calls the CreateSigningRequest method on ServerConfigurationType (OPC 10000-12 §7.10.4).
ValueTask CreateSigningRequestAsync(
NodeId certificateGroupId,
NodeId certificateTypeId,
string subjectName,
bool regeneratePrivateKey,
ByteString nonce,
CancellationToken ct = default);
/// Updates the application certificate.
/// Calls the UpdateCertificate method on ServerConfigurationType (OPC 10000-12 §7.10.3).
ValueTask UpdateCertificateAsync(
NodeId certificateGroupId,
NodeId certificateTypeId,
ByteString certificate,
string privateKeyFormat,
ByteString privateKey,
ArrayOf issuerCertificates,
CancellationToken ct = default);
/// Applies the configuration changes on the server.
/// Calls the ApplyChanges method on ServerConfigurationType (OPC 10000-12 §7.10.5).
ValueTask ApplyChangesAsync(CancellationToken ct = default);
/// Lists the certificates configured on the server.
/// Calls the GetCertificates method on ServerConfigurationType (OPC 10000-12 §7.10.7).
ValueTask<(ArrayOf certificateTypeIds, ArrayOf certificates)> GetCertificatesAsync(
NodeId certificateGroupId,
CancellationToken ct = default);
/// Creates a self-signed certificate on the server.
/// Calls the CreateSelfSignedCertificate method on
/// ServerConfigurationType (OPC 10000-12 §7.10.6). The method
/// is optional; servers that do not support it return
/// Bad_NotSupported.
ValueTask CreateSelfSignedCertificateAsync(
NodeId certificateGroupId,
NodeId certificateTypeId,
string subjectName,
ArrayOf dnsNames,
ArrayOf ipAddresses,
ushort lifetimeInDays,
ushort keySizeInBits,
CancellationToken ct = default);
}
}