Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
499 changes: 442 additions & 57 deletions .editorconfig

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Microsoft.Extensions.Logging;
using Opc.Ua;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ private void SessionManager_ImpersonateUser(ISession session, ImpersonateEventAr
VerifyX509IdentityToken(x509Token);
// set AuthenticatedUser role for accepted certificate authentication
args.Identity = new RoleBasedIdentity(
new UserIdentity(x509Token, MessageContext.Telemetry),
new UserIdentity(x509Token),
[Role.AuthenticatedUser]);
m_logger.LogInformation(
Utils.TraceMasks.Security,
Expand Down Expand Up @@ -368,7 +368,7 @@ private IUserIdentity VerifyPassword(UserNameIdentityToken userNameToken)
if (userName == "sysadmin" && Utils.IsEqual(password, "demo"u8))
{
return new SystemConfigurationIdentity(
new UserIdentity(userNameToken, MessageContext.Telemetry));
new UserIdentity(userNameToken));
}

// standard users for CTT verification
Expand All @@ -391,7 +391,7 @@ private IUserIdentity VerifyPassword(UserNameIdentityToken userNameToken)
new LocalizedText(info)));
}
return new RoleBasedIdentity(
new UserIdentity(userNameToken, MessageContext.Telemetry),
new UserIdentity(userNameToken),
[Role.AuthenticatedUser]);
}

Expand Down
18 changes: 9 additions & 9 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<PackageVersion Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="2.3.0" />
<PackageVersion Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets" Version="2.3.0" />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.9" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
Expand All @@ -31,22 +31,22 @@
<PackageVersion Include="NUnit.Console" Version="3.20.1" />
<PackageVersion Include="NUnit3TestAdapter" Version="5.2.0" />
<PackageVersion Include="PolySharp" Version="1.15.0" />
<PackageVersion Include="Roslynator.Analyzers" Version="4.14.0" />
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.14.0" />
<PackageVersion Include="Roslynator.Analyzers" Version="4.14.1" />
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.14.1" />
<PackageVersion Include="SharpFuzz" Version="2.2.0" />
<PackageVersion Include="Serilog" Version="4.3.0" />
<PackageVersion Include="Serilog.Expressions" Version="5.0.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.2" />
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageVersion Include="Serilog.Sinks.Debug" Version="3.0.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="7.0.0" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="9.0.9" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="9.0.10" />
<PackageVersion Include="System.Memory" Version="4.6.3" />
<PackageVersion Include="System.Formats.Asn1" Version="9.0.9" />
<PackageVersion Include="System.Formats.Asn1" Version="9.0.10" />
<PackageVersion Include="System.IO.Compression" Version="4.3.0" />
<PackageVersion Include="System.Net.NetworkInformation" Version="4.3.0" />
<PackageVersion Include="System.Collections.Immutable" Version="9.0.9" />
<PackageVersion Include="System.Text.Json" Version="9.0.5" />
<PackageVersion Include="System.Collections.Immutable" Version="9.0.10" />
<PackageVersion Include="System.Text.Json" Version="9.0.10" />
<PackageVersion Include="System.Private.Uri" Version="4.3.2" />
<PackageVersion Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.Cng" Version="5.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,17 @@ public Task<INode> FindAsync(ExpandedNodeId nodeId, CancellationToken ct = defau
/// <summary>
/// Helper to load a DataDictionary by its NodeId.
/// </summary>
internal async Task<DataDictionary> LoadDictionaryAsync(NodeId dictionaryId, string name)
internal async Task<DataDictionary> LoadDictionaryAsync(
NodeId dictionaryId,
string name,
CancellationToken ct = default)
{
var dictionaryToLoad = new DataDictionary();
await LoadDictionaryAsync(dictionaryToLoad, dictionaryId, name).ConfigureAwait(false);
await LoadDictionaryAsync(
dictionaryToLoad,
dictionaryId,
name,
ct: ct).ConfigureAwait(false);
return dictionaryToLoad;
}

Expand Down Expand Up @@ -642,9 +649,7 @@ private async Task LoadDictionaryAsync(

if (schema == null || schema.Length == 0)
{
throw ServiceResultException.Create(
StatusCodes.BadUnexpectedError,
"Cannot parse empty data dictionary.");
throw ServiceResultException.Unexpected("Cannot parse empty data dictionary.");
}

// Interoperability: some server may return a null terminated dictionary string
Expand Down
38 changes: 26 additions & 12 deletions Libraries/Opc.Ua.Client/Session/Factory/DefaultSessionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class DefaultSessionFactory : ISessionFactory, ISessionInstantiator
/// <inheritdoc/>
public ITelemetryContext Telemetry { get; init; }

/// <inheritdoc/>
public DiagnosticsMasks ReturnDiagnostics { get; set; }

/// <summary>
/// Obsolete default constructor
/// </summary>
Expand Down Expand Up @@ -113,6 +116,7 @@ public virtual async Task<ISession> CreateAsync(
sessionTimeout,
identity,
preferredLocales,
ReturnDiagnostics,
ct)
.ConfigureAwait(false);
}
Expand Down Expand Up @@ -142,6 +146,7 @@ public virtual async Task<ISession> CreateAsync(
sessionTimeout,
identity,
preferredLocales,
ReturnDiagnostics,
ct)
.ConfigureAwait(false);
}
Expand All @@ -162,16 +167,16 @@ public virtual async Task<ISession> CreateAsync(
if (reverseConnectManager == null)
{
return await CreateAsync(
configuration,
endpoint,
updateBeforeConnect,
checkDomain,
sessionName,
sessionTimeout,
userIdentity,
preferredLocales,
ct)
.ConfigureAwait(false);
configuration,
endpoint,
updateBeforeConnect,
checkDomain,
sessionName,
sessionTimeout,
userIdentity,
preferredLocales,
ct)
.ConfigureAwait(false);
}

ITransportWaitingConnection connection;
Expand Down Expand Up @@ -263,6 +268,7 @@ public virtual async Task<ISession> RecreateAsync(
"The ISession provided is not of a supported type.");
}

template.ReturnDiagnostics = ReturnDiagnostics;
return await Session.RecreateAsync(template, ct).ConfigureAwait(false);
}

Expand All @@ -279,6 +285,7 @@ public virtual async Task<ISession> RecreateAsync(
"The ISession provided is not of a supported type");
}

template.ReturnDiagnostics = ReturnDiagnostics;
return await Session.RecreateAsync(template, connection, ct).ConfigureAwait(false);
}

Expand All @@ -294,6 +301,7 @@ public virtual async Task<ISession> RecreateAsync(
nameof(sessionTemplate),
"The ISession provided is not of a supported type");
}
template.ReturnDiagnostics = ReturnDiagnostics;
return await Session.RecreateAsync(template, transportChannel, ct)
.ConfigureAwait(false);
}
Expand All @@ -304,7 +312,10 @@ public virtual Session Create(
ApplicationConfiguration configuration,
ConfiguredEndpoint endpoint)
{
return new Session(channel, configuration, endpoint);
return new Session(channel, configuration, endpoint)
{
ReturnDiagnostics = ReturnDiagnostics
};
}

/// <inheritdoc/>
Expand All @@ -322,7 +333,10 @@ public virtual Session Create(
endpoint,
clientCertificate,
availableEndpoints,
discoveryProfileUris);
discoveryProfileUris)
{
ReturnDiagnostics = ReturnDiagnostics
};
}
}
}
22 changes: 12 additions & 10 deletions Libraries/Opc.Ua.Client/Session/Factory/TraceableSessionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ public override async Task<ISession> CreateAsync(
{
using Activity activity = Telemetry.GetActivitySource().StartActivity();
ISession session = await base.CreateAsync(
configuration,
endpoint,
updateBeforeConnect,
false,
sessionName,
sessionTimeout,
identity,
preferredLocales,
ct)
.ConfigureAwait(false);
configuration,
endpoint,
updateBeforeConnect,
false,
sessionName,
sessionTimeout,
identity,
preferredLocales,
ct)
.ConfigureAwait(false);
return new TraceableSession(session, Telemetry);
}

Expand Down Expand Up @@ -119,6 +119,7 @@ public override async Task<ISession> CreateAsync(
sessionTimeout,
identity,
preferredLocales,
ReturnDiagnostics,
ct)
.ConfigureAwait(false);

Expand Down Expand Up @@ -151,6 +152,7 @@ public override async Task<ISession> CreateAsync(
sessionTimeout,
identity,
preferredLocales,
ReturnDiagnostics,
ct)
.ConfigureAwait(false);

Expand Down
5 changes: 5 additions & 0 deletions Libraries/Opc.Ua.Client/Session/ISessionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ namespace Opc.Ua.Client
/// </summary>
public interface ISessionFactory
{
/// <summary>
/// Set diagnostics for all sessions created by the factory
/// </summary>
DiagnosticsMasks ReturnDiagnostics { get; set; }

/// <summary>
/// Creates a new communication session with a server by invoking the CreateSession service
/// </summary>
Expand Down
Loading
Loading