Added: Network Security Config

https://devblogs.microsoft.com/xamarin/cleartext-http-android-network-security/
This commit is contained in:
TheJoKlLa 2021-09-19 19:40:00 +02:00
parent e340e1e6eb
commit bc54f708ca
7 changed files with 30 additions and 13 deletions

View File

@ -172,6 +172,11 @@
<ItemGroup>
<AndroidResource Include="Resources\layout\Toolbar.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\xml\network_security_config.xml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="org.fab_infra.fabaccess" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
<application android:theme="@style/MainTheme" android:label="FabAccess"></application>
<application android:theme="@style/MainTheme" android:label="FabAccess" android:networkSecurityConfig="@xml/network_security_config"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

View File

@ -24432,22 +24432,25 @@ namespace Borepin.Droid
public const int image_share_filepaths = 2131820544;
// aapt resource value: 0x7F110001
public const int standalone_badge = 2131820545;
public const int network_security_config = 2131820545;
// aapt resource value: 0x7F110002
public const int standalone_badge_gravity_bottom_end = 2131820546;
public const int standalone_badge = 2131820546;
// aapt resource value: 0x7F110003
public const int standalone_badge_gravity_bottom_start = 2131820547;
public const int standalone_badge_gravity_bottom_end = 2131820547;
// aapt resource value: 0x7F110004
public const int standalone_badge_gravity_top_start = 2131820548;
public const int standalone_badge_gravity_bottom_start = 2131820548;
// aapt resource value: 0x7F110005
public const int standalone_badge_offset = 2131820549;
public const int standalone_badge_gravity_top_start = 2131820549;
// aapt resource value: 0x7F110006
public const int xamarin_essentials_fileprovider_file_paths = 2131820550;
public const int standalone_badge_offset = 2131820550;
// aapt resource value: 0x7F110007
public const int xamarin_essentials_fileprovider_file_paths = 2131820551;
static Xml()
{

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>

View File

@ -31,6 +31,8 @@ namespace Borepin.PageModel
#region Data
public override async Task LoadData()
{
IsBusy = true;
IMachineSystem machineSystem = await _BFFHService.GetMachineSystemInterface();
IInfoInterface info = await machineSystem.Info();
@ -66,6 +68,7 @@ namespace Borepin.PageModel
Machine.IUseInterface useInterface = _Machine.Use;
await useInterface.Use();
await LoadData();
}
private ICommand _GiveBackMachineCommand;
@ -80,6 +83,7 @@ namespace Borepin.PageModel
Machine.IInUseInterface inUseInterface = _Machine.Inuse;
await inUseInterface.GiveBack();
await LoadData();
}
#endregion

View File

@ -4,6 +4,7 @@ using System.Threading.Tasks;
using Capnp.Rpc;
using System.Collections.Generic;
using FabAccessAPI.Schema;
using System.Net.Http;
namespace Borepin.Service.BFFH
{
@ -18,11 +19,11 @@ namespace Borepin.Service.BFFH
_CredentialService = credentialService;
}
public Model.Connection ActiveConnection { get; private set; }
public Connection ActiveConnection { get; private set; }
public bool IsAuthenticated { get; private set; }
public async Task Connect(Model.Connection connection)
public async Task Connect(Connection connection)
{
if (_Connection != null || ActiveConnection != null)
{
@ -63,7 +64,7 @@ namespace Borepin.Service.BFFH
return await Task.FromResult(true);
}
public async Task<bool> Authenticate(Model.Connection connection, string password)
public async Task<bool> Authenticate(Connection connection, string password)
{
await _Connection.Auth("PLAIN", new Dictionary<string, object> { { "Username", ActiveConnection.Username }, { "Password", password } });

View File

@ -19,7 +19,7 @@ namespace FabAccessAPI
public TcpRpcClient? RpcClient => _rpcClient;
#region Log
private static readonly log4net.ILog _Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
//private static readonly log4net.ILog _Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
/// <summary>
@ -30,7 +30,7 @@ namespace FabAccessAPI
{
_rpcClient = rpcClient;
_bootstrapCap = _rpcClient.GetMain<IBootstrap>();
_Log.Debug($"Done bootstraping API connection.");
//_Log.Debug($"Done bootstraping API connection.");
}
/// <summary>
@ -46,7 +46,7 @@ namespace FabAccessAPI
var authCap = await _bootstrapCap.AuthenticationSystem(cancellationToken_);
_auth = new Auth(authCap);
var mechs = await _auth.GetMechanisms();
_Log.Debug($"The Server supports the following auth mechs: {string.Join(", ", mechs)}");
//_Log.Debug($"The Server supports the following auth mechs: {string.Join(", ", mechs)}");
if (!mechs.Contains(mech))
{