/* ========================================================================
* 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.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Opc.Ua.Security.Certificates;
namespace Opc.Ua.Configuration
{
///
/// A class that installs, configures and runs a UA application.
///
public interface IApplicationInstance : IAsyncDisposable
{
///
/// Gets the application configuration used when the Start() method was called.
///
/// The application configuration.
ApplicationConfiguration? ApplicationConfiguration { get; set; }
///
/// Gets or sets the name of the application.
///
/// The name of the application.
string? ApplicationName { get; set; }
///
/// Gets or sets the type of the application.
///
/// The type of the application.
ApplicationType ApplicationType { get; set; }
///
/// Get or set the certificate password provider.
///
ICertificatePasswordProvider? CertificatePasswordProvider { get; set; }
///
/// Gets or sets the name of the config section containing the path
/// to the application configuration file.
///
/// The name of the config section.
string? ConfigSectionName { get; set; }
///
/// Gets or sets the type of configuration file.
///
/// The type of configuration file.
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
Type? ConfigurationType { get; set; }
///
/// Get or set bool which indicates if the auto creation
/// of a new application certificate during startup is disabled.
/// Default is enabled./>
///
///
/// Prevents auto self signed cert creation in use cases
/// where an expired certificate should not be automatically
/// renewed or where it is required to only use certificates
/// provided by the user.
///
bool DisableCertificateAutoCreation { get; set; }
///
/// Gets the server.
///
/// The server.
IServerBase? Server { get; }
///
/// Adds a Certificate to the Trusted Store of the Application, needed e.g. for the GDS to trust it´s own CA
///
/// The certificate to add to the store
/// The cancellation token
Task AddOwnCertificateToTrustedStoreAsync(Certificate certificate, CancellationToken ct);
///
/// Create a builder for a UA application configuration.
///
IApplicationConfigurationBuilderTypes Build(string applicationUri, string productUri);
///
/// Checks for a valid application instance certificate.
///
/// if set to true no dialogs will be displayed.
/// The lifetime in months.
/// Cancellation token to cancel operation with
///
ValueTask CheckApplicationInstanceCertificatesAsync(bool silent, ushort? lifeTimeInMonths = null, CancellationToken ct = default);
///
/// Deletes all application certificates.
///
///
ValueTask DeleteApplicationInstanceCertificateAsync(string[]? profileIds = null, CancellationToken ct = default);
///
/// Loads the application configuration.
///
///
ValueTask LoadApplicationConfigurationAsync(bool silent, CancellationToken ct = default);
///
/// Loads the application configuration.
///
///
Task LoadApplicationConfigurationAsync(Stream stream, bool silent, CancellationToken ct = default);
///
/// Loads the application configuration.
///
ValueTask LoadApplicationConfigurationAsync(string filePath, bool silent, CancellationToken ct = default);
///
/// Starts the UA server.
///
/// The server.
/// Cancellation token to cancel the startup operation.
Task StartAsync(IServerBase server, CancellationToken ct = default);
///
/// Stops the UA server.
///
/// Cancellation token to cancel the stop operation.
ValueTask StopAsync(CancellationToken ct = default);
}
}