Skip to content

Commit 24aa932

Browse files
committed
Resolving Conflict
2 parents 182af00 + dc6e77d commit 24aa932

17 files changed

Lines changed: 1290 additions & 242 deletions

src/AasxOpcUa2Client/AasOpcUaClient2.cs

Lines changed: 102 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This source code may use other Open Source software components (see LICENSE.txt)
1919
using System.Threading.Tasks;
2020
using AasxIntegrationBase;
2121
using AdminShellNS;
22+
using AnyUi;
2223

2324
using Workstation.ServiceModel.Ua;
2425
using Workstation.ServiceModel.Ua.Channels;
@@ -58,19 +59,32 @@ public class AasOpcUaClient2
5859
protected string _password;
5960
protected uint _timeOutMs = 2000;
6061

62+
//Optional parameters for secured OPC UA interface in AID
63+
protected MessageSecurityMode _securityMode;
64+
protected string _securityPolicy;
65+
protected static bool _autoConnect = false;
66+
6167
protected ClientSessionChannel _channel = null;
6268

63-
public AasOpcUaClient2(string endpointURL, bool autoAccept,
69+
public AasOpcUaClient2(
70+
string endpointURL,
71+
bool autoAccept,
6472
string userName, string password,
6573
uint timeOutMs = 2000,
66-
LogInstance log = null)
74+
LogInstance log = null,
75+
MessageSecurityMode? securityMode = MessageSecurityMode.None,
76+
string? securityPolicy = SecurityPolicyUris.None,
77+
bool? autoConnect = false)
6778
{
6879
_endpointURL = endpointURL;
6980
_autoAccept = autoAccept;
7081
_userName = userName;
7182
_password = password;
7283
_timeOutMs = timeOutMs;
7384
_log = log;
85+
_securityMode = (MessageSecurityMode)securityMode;
86+
_securityPolicy = securityPolicy;
87+
_autoConnect = (bool)autoConnect;
7488
}
7589

7690
public async Task DirectConnect()
@@ -98,19 +112,97 @@ public async Task StartClientAsync()
98112
ApplicationType = ApplicationType.Client
99113
};
100114

101-
// create a 'ClientSessionChannel', a client-side channel that opens a 'session' with the server.
102-
_channel = new ClientSessionChannel(
103-
clientDescription,
104-
null, // no x509 certificates
105-
new AnonymousIdentity(), // no user identity
106-
"" + _endpointURL,
107-
SecurityPolicyUris.None); // no encryption
115+
// Create Endpoint
116+
var Endpoint = new EndpointDescription
117+
{
118+
EndpointUrl = _endpointURL,
119+
SecurityPolicyUri = _securityPolicy,
120+
SecurityMode = _securityMode,
121+
};
122+
123+
///<summary>
124+
///Set up auto connection by getting all endpoints from server and using one of these endpoints
125+
///Used by AID Submodel
126+
///</summary>
127+
if (_autoConnect)
128+
{
129+
130+
var endpointRequest = new GetEndpointsRequest()
131+
{
132+
EndpointUrl = _endpointURL,
133+
};
134+
GetEndpointsResponse endpoints = await DiscoveryService.GetEndpointsAsync(endpointRequest);
135+
if (endpoints.Endpoints != null)
136+
{
137+
foreach (var endpoint in endpoints.Endpoints)
138+
{
139+
if (endpoint.SecurityMode.ToString().ToLower() == "none" &&
140+
endpoint.SecurityPolicyUri.Split("#").Last().ToLower() == "none")
141+
{
142+
_log?.Info("Using auto connect option...");
143+
_log?.Info($"Creating channel from one of {endpoints.Endpoints.Length} Endpoints");
144+
_log?.Info($"Using Endpoint : Security Mode = {endpoint.SecurityMode} and Security Policy: {endpoint.SecurityPolicyUri.Split("#").Last()}");
145+
Endpoint.EndpointUrl = endpoint.EndpointUrl;
146+
Endpoint.SecurityMode = endpoint.SecurityMode;
147+
Endpoint.SecurityPolicyUri = endpoint.SecurityPolicyUri;
148+
_channel = new ClientSessionChannel(
149+
clientDescription,
150+
null, // no x509 certificates
151+
new AnonymousIdentity(), // no user identity
152+
Endpoint);
153+
154+
}
155+
break;
156+
}
157+
}
158+
159+
}
160+
161+
///<summary>
162+
///Set up Secure Session. Used by AID Submodel
163+
///</summary>
164+
165+
else if (_securityMode != MessageSecurityMode.None && _securityPolicy != SecurityPolicyUris.None)
166+
{
167+
///<summary>
168+
///create directory for client certificate.
169+
///certificate will be created if none is existing.
170+
///If the server does not auto accept certificates, it is mandatory to copy this client's public key
171+
///in ./pki/own/certs folder and add it to the server's trusted folders
172+
///</summary>
173+
_log?.Info($"....Creating Secure channel with security mode: {_securityMode} and security policy: {_securityPolicy}");
174+
var certificatestore = new DirectoryStore("./pki");
175+
// create a 'ClientSessionChannel', a client-side channel that opens a 'session' with the server.
176+
_channel = new ClientSessionChannel(
177+
clientDescription,
178+
certificatestore,
179+
new AnonymousIdentity(), // no user identity
180+
Endpoint // endpoint built for opc ua security
181+
);
182+
183+
}
184+
///<summary>
185+
/// Set up Unsecure Session. Used by AID, MTP and UaClient plugins
186+
///</summary>
187+
188+
else if (_securityMode == MessageSecurityMode.None)
189+
{
190+
// create a 'ClientSessionChannel', a client-side channel that opens a 'session' with the server.
191+
_log?.Info($"....Creating Unsecure channel with security mode: {_securityMode} and security policy: {_securityPolicy}");
192+
_channel = new ClientSessionChannel(
193+
clientDescription,
194+
null, // no x509 certificates
195+
new AnonymousIdentity(), // no user identity
196+
197+
Endpoint);
198+
}
108199

109200
// try opening a session and reading a few nodes.
110201
try
111202
{
112203
await _channel.OpenAsync();
113-
} catch (Exception ex)
204+
}
205+
catch (Exception ex)
114206
{
115207
ClientStatus = AasOpcUaClientStatus.ErrorCreateSession;
116208
_log?.Error(ex, "open async");

src/AasxPackageExplorer.sln

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,35 @@ Global
251251
{EBAE658A-3ECE-4C98-89BC-F79809AB4A5E}.ReleaseWithoutCEF|x64.Build.0 = Release|Any CPU
252252
{EBAE658A-3ECE-4C98-89BC-F79809AB4A5E}.ReleaseWithoutCEF|x86.ActiveCfg = Release|Any CPU
253253
{EBAE658A-3ECE-4C98-89BC-F79809AB4A5E}.ReleaseWithoutCEF|x86.Build.0 = Release|Any CPU
254+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
255+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.Debug|x64.ActiveCfg = Debug|Any CPU
256+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.Debug|x64.Build.0 = Debug|Any CPU
257+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.Debug|x86.ActiveCfg = Debug|Any CPU
258+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.Debug|x86.Build.0 = Debug|Any CPU
259+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.DebugSlow|Any CPU.ActiveCfg = Debug|Any CPU
260+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.DebugSlow|Any CPU.Build.0 = Debug|Any CPU
261+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.DebugSlow|x64.ActiveCfg = Debug|Any CPU
262+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.DebugSlow|x64.Build.0 = Debug|Any CPU
263+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.DebugSlow|x86.ActiveCfg = Debug|Any CPU
264+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.DebugSlow|x86.Build.0 = Debug|Any CPU
265+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.DebugWithoutCEF|Any CPU.ActiveCfg = Debug|Any CPU
266+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.DebugWithoutCEF|Any CPU.Build.0 = Debug|Any CPU
267+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.DebugWithoutCEF|x64.ActiveCfg = Debug|Any CPU
268+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.DebugWithoutCEF|x64.Build.0 = Debug|Any CPU
269+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.DebugWithoutCEF|x86.ActiveCfg = Debug|Any CPU
270+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.DebugWithoutCEF|x86.Build.0 = Debug|Any CPU
271+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.Release|Any CPU.ActiveCfg = Release|Any CPU
272+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.Release|Any CPU.Build.0 = Release|Any CPU
273+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.Release|x64.ActiveCfg = Release|Any CPU
274+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.Release|x64.Build.0 = Release|Any CPU
275+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.Release|x86.ActiveCfg = Release|Any CPU
276+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.Release|x86.Build.0 = Release|Any CPU
277+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.ReleaseWithoutCEF|Any CPU.ActiveCfg = Release|Any CPU
278+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.ReleaseWithoutCEF|Any CPU.Build.0 = Release|Any CPU
279+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.ReleaseWithoutCEF|x64.ActiveCfg = Release|Any CPU
280+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.ReleaseWithoutCEF|x64.Build.0 = Release|Any CPU
281+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.ReleaseWithoutCEF|x86.ActiveCfg = Release|Any CPU
282+
{967E60E3-D668-42A3-AA0B-1A031C20D871}.ReleaseWithoutCEF|x86.Build.0 = Release|Any CPU
254283
{5A05DF78-216B-4A0B-9E30-7B2557C7E867}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
255284
{5A05DF78-216B-4A0B-9E30-7B2557C7E867}.Debug|Any CPU.Build.0 = Debug|Any CPU
256285
{5A05DF78-216B-4A0B-9E30-7B2557C7E867}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -759,6 +788,35 @@ Global
759788
{7788AC2B-7F97-4755-B343-C4196FA90198}.ReleaseWithoutCEF|x64.Build.0 = Release|Any CPU
760789
{7788AC2B-7F97-4755-B343-C4196FA90198}.ReleaseWithoutCEF|x86.ActiveCfg = Release|Any CPU
761790
{7788AC2B-7F97-4755-B343-C4196FA90198}.ReleaseWithoutCEF|x86.Build.0 = Release|Any CPU
791+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
792+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.Debug|x64.ActiveCfg = Debug|Any CPU
793+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.Debug|x64.Build.0 = Debug|Any CPU
794+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.Debug|x86.ActiveCfg = Debug|Any CPU
795+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.Debug|x86.Build.0 = Debug|Any CPU
796+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.DebugSlow|Any CPU.ActiveCfg = Debug|Any CPU
797+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.DebugSlow|Any CPU.Build.0 = Debug|Any CPU
798+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.DebugSlow|x64.ActiveCfg = Debug|Any CPU
799+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.DebugSlow|x64.Build.0 = Debug|Any CPU
800+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.DebugSlow|x86.ActiveCfg = Debug|Any CPU
801+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.DebugSlow|x86.Build.0 = Debug|Any CPU
802+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.DebugWithoutCEF|Any CPU.ActiveCfg = Debug|Any CPU
803+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.DebugWithoutCEF|Any CPU.Build.0 = Debug|Any CPU
804+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.DebugWithoutCEF|x64.ActiveCfg = Debug|Any CPU
805+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.DebugWithoutCEF|x64.Build.0 = Debug|Any CPU
806+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.DebugWithoutCEF|x86.ActiveCfg = Debug|Any CPU
807+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.DebugWithoutCEF|x86.Build.0 = Debug|Any CPU
808+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
809+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.Release|Any CPU.Build.0 = Release|Any CPU
810+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.Release|x64.ActiveCfg = Release|Any CPU
811+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.Release|x64.Build.0 = Release|Any CPU
812+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.Release|x86.ActiveCfg = Release|Any CPU
813+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.Release|x86.Build.0 = Release|Any CPU
814+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.ReleaseWithoutCEF|Any CPU.ActiveCfg = Release|Any CPU
815+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.ReleaseWithoutCEF|Any CPU.Build.0 = Release|Any CPU
816+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.ReleaseWithoutCEF|x64.ActiveCfg = Release|Any CPU
817+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.ReleaseWithoutCEF|x64.Build.0 = Release|Any CPU
818+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.ReleaseWithoutCEF|x86.ActiveCfg = Release|Any CPU
819+
{2F21FEFF-F0EF-40B5-BA05-09FC9F499AE9}.ReleaseWithoutCEF|x86.Build.0 = Release|Any CPU
762820
{B540EBF4-C026-45A4-9721-909AF0CC14C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
763821
{B540EBF4-C026-45A4-9721-909AF0CC14C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
764822
{B540EBF4-C026-45A4-9721-909AF0CC14C1}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -1389,6 +1447,35 @@ Global
13891447
{4EB64F40-1A01-46BB-BEED-D1A75313C7F8}.ReleaseWithoutCEF|x64.Build.0 = Release|Any CPU
13901448
{4EB64F40-1A01-46BB-BEED-D1A75313C7F8}.ReleaseWithoutCEF|x86.ActiveCfg = Release|Any CPU
13911449
{4EB64F40-1A01-46BB-BEED-D1A75313C7F8}.ReleaseWithoutCEF|x86.Build.0 = Release|Any CPU
1450+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1451+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.Debug|x64.ActiveCfg = Debug|Any CPU
1452+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.Debug|x64.Build.0 = Debug|Any CPU
1453+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.Debug|x86.ActiveCfg = Debug|Any CPU
1454+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.Debug|x86.Build.0 = Debug|Any CPU
1455+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.DebugSlow|Any CPU.ActiveCfg = Debug|Any CPU
1456+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.DebugSlow|Any CPU.Build.0 = Debug|Any CPU
1457+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.DebugSlow|x64.ActiveCfg = Debug|Any CPU
1458+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.DebugSlow|x64.Build.0 = Debug|Any CPU
1459+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.DebugSlow|x86.ActiveCfg = Debug|Any CPU
1460+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.DebugSlow|x86.Build.0 = Debug|Any CPU
1461+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.DebugWithoutCEF|Any CPU.ActiveCfg = Debug|Any CPU
1462+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.DebugWithoutCEF|Any CPU.Build.0 = Debug|Any CPU
1463+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.DebugWithoutCEF|x64.ActiveCfg = Debug|Any CPU
1464+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.DebugWithoutCEF|x64.Build.0 = Debug|Any CPU
1465+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.DebugWithoutCEF|x86.ActiveCfg = Debug|Any CPU
1466+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.DebugWithoutCEF|x86.Build.0 = Debug|Any CPU
1467+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
1468+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.Release|Any CPU.Build.0 = Release|Any CPU
1469+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.Release|x64.ActiveCfg = Release|Any CPU
1470+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.Release|x64.Build.0 = Release|Any CPU
1471+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.Release|x86.ActiveCfg = Release|Any CPU
1472+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.Release|x86.Build.0 = Release|Any CPU
1473+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.ReleaseWithoutCEF|Any CPU.ActiveCfg = Release|Any CPU
1474+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.ReleaseWithoutCEF|Any CPU.Build.0 = Release|Any CPU
1475+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.ReleaseWithoutCEF|x64.ActiveCfg = Release|Any CPU
1476+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.ReleaseWithoutCEF|x64.Build.0 = Release|Any CPU
1477+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.ReleaseWithoutCEF|x86.ActiveCfg = Release|Any CPU
1478+
{BE68E42C-28CB-4298-9F34-A18AF92FC4DE}.ReleaseWithoutCEF|x86.Build.0 = Release|Any CPU
13921479
{FF0DEFE4-84F7-4DC0-8C65-5ACE5153DD94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13931480
{FF0DEFE4-84F7-4DC0-8C65-5ACE5153DD94}.Debug|Any CPU.Build.0 = Debug|Any CPU
13941481
{FF0DEFE4-84F7-4DC0-8C65-5ACE5153DD94}.Debug|x64.ActiveCfg = Debug|Any CPU

src/AasxPackageExplorer/options-debug.MIHO.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
"AccessInfo": {
5454
"Method": "None" // None, Ask, Basic, CertificateStore, File, InteractiveEntry, Secret
5555
}
56+
},
57+
{
58+
"BaseAddress": "https://leo-discovery.admin-shell-io.com/api/v2/",
59+
"AccessInfo": {
60+
"Method": "None" // None, Ask, Basic, CertificateStore, File, InteractiveEntry, Secret
61+
}
5662
},
5763
{
5864
"BaseAddress": "https://aasx-server-pcf.dev.pxcio.net/",

src/AasxPackageLogic/DispEditHelperEntities.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,7 @@ public static async Task<bool> ExecuteUiForFetchOfElements(
15211521
"Error building location from fetch selection. Aborting.");
15221522
return false;
15231523
}
1524+
Options.Curr.AutoAuthenticateAsk = fetchContext.Record.AutoAuthenticate;
15241525

15251526
// more details into container options
15261527
var containerOptions = new PackageContainerHttpRepoSubset.

0 commit comments

Comments
 (0)