Skip to content

Commit c7306c4

Browse files
[+] Modelling: Connection check foreign interface and NA
1 parent 4107338 commit c7306c4

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

roles/lib/files/FWO.Services/ModellingConnectionHandler.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,29 @@ public void AddExtraConfig()
276276
AddExtraConfigMode = true;
277277
}
278278

279+
public bool InterfaceAllowedWithNetworkArea(ModellingConnection interf)
280+
{
281+
if (!ActConn.IsInterface && !ActConn.IsCommonService && interf.AppId != ActConn.AppId &&
282+
( ActConn.DestinationAreas.Count > 0 || DstAreasToAdd.Count > 0 ||
283+
ActConn.SourceAreas.Count > 0 || SrcAreasToAdd.Count > 0 ))
284+
{
285+
return false;
286+
}
287+
288+
return true;
289+
}
290+
291+
public bool InterfaceAllowedWithNetworkArea()
292+
{
293+
if (!ActConn.IsInterface && !ActConn.IsCommonService && ActConn.UsedInterfaceId != null &&
294+
ActConn.UsedInterfaceId > 0 && PreselectedInterfaces.FirstOrDefault(_ => _.Id == ActConn.UsedInterfaceId)?.AppId != ActConn.AppId)
295+
{
296+
return false;
297+
}
298+
299+
return true;
300+
}
301+
279302
/// <summary>
280303
/// Checks the opposite direction if it already contains a network area.
281304
/// </summary>

roles/ui/files/FWO.UI/Pages/NetworkModelling/EditConn.razor

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,13 @@
489489
{
490490
if(Container.ConnElement != null)
491491
{
492+
if (!ConnHandler.InterfaceAllowedWithNetworkArea(Container.ConnElement))
493+
{
494+
DisplayMessageInUi(default, userConfig.GetText("edit_connection"), "", true);
495+
Container.Clear();
496+
return;
497+
}
498+
492499
if(ConnHandler!.ActConn.IsInterface)
493500
{
494501
await ConnHandler!.RequestReplaceInterface(Container.ConnElement);
@@ -506,6 +513,13 @@
506513
}
507514
if(Container.AreaElements.Count > 0)
508515
{
516+
if (!ConnHandler.InterfaceAllowedWithNetworkArea())
517+
{
518+
DisplayMessageInUi(default, userConfig.GetText("edit_connection"), "", true);
519+
Container.Clear();
520+
return;
521+
}
522+
509523
if (ConnHandler is not null && !ConnHandler.NetworkAreaUseAllowed(Container.AreaElements, Direction.Source, out (string Title, string Text) reason))
510524
{
511525
DisplayMessageInUi(default, reason.Title, reason.Text, true);
@@ -531,6 +545,13 @@
531545
{
532546
if(Container.ConnElement != null)
533547
{
548+
if (!ConnHandler.InterfaceAllowedWithNetworkArea(Container.ConnElement))
549+
{
550+
DisplayMessageInUi(default, userConfig.GetText("edit_connection"), "", true);
551+
Container.Clear();
552+
return;
553+
}
554+
534555
if(ConnHandler!.ActConn.IsInterface)
535556
{
536557
await ConnHandler!.RequestReplaceInterface(Container.ConnElement);
@@ -547,7 +568,14 @@
547568
ConnHandler?.AppRolesToDestination(Container.AppRoleElements);
548569
}
549570
if(Container.AreaElements.Count > 0)
550-
{
571+
{
572+
if (!ConnHandler.InterfaceAllowedWithNetworkArea())
573+
{
574+
DisplayMessageInUi(default, userConfig.GetText("edit_connection"), "", true);
575+
Container.Clear();
576+
return;
577+
}
578+
551579
if (ConnHandler is not null && !ConnHandler.NetworkAreaUseAllowed(Container.AreaElements, Direction.Destination, out (string Title, string Text) reason))
552580
{
553581
DisplayMessageInUi(default, reason.Title, reason.Text, true);

0 commit comments

Comments
 (0)