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> <ItemGroup>
<AndroidResource Include="Resources\layout\Toolbar.xml" /> <AndroidResource Include="Resources\layout\Toolbar.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\xml\network_security_config.xml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<ProjectExtensions> <ProjectExtensions>
<VisualStudio> <VisualStudio>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?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"> <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" /> <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.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
</manifest> </manifest>

View File

@ -24432,22 +24432,25 @@ namespace Borepin.Droid
public const int image_share_filepaths = 2131820544; public const int image_share_filepaths = 2131820544;
// aapt resource value: 0x7F110001 // aapt resource value: 0x7F110001
public const int standalone_badge = 2131820545; public const int network_security_config = 2131820545;
// aapt resource value: 0x7F110002 // aapt resource value: 0x7F110002
public const int standalone_badge_gravity_bottom_end = 2131820546; public const int standalone_badge = 2131820546;
// aapt resource value: 0x7F110003 // 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 // 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 // aapt resource value: 0x7F110005
public const int standalone_badge_offset = 2131820549; public const int standalone_badge_gravity_top_start = 2131820549;
// aapt resource value: 0x7F110006 // 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() 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 #region Data
public override async Task LoadData() public override async Task LoadData()
{ {
IsBusy = true;
IMachineSystem machineSystem = await _BFFHService.GetMachineSystemInterface(); IMachineSystem machineSystem = await _BFFHService.GetMachineSystemInterface();
IInfoInterface info = await machineSystem.Info(); IInfoInterface info = await machineSystem.Info();
@ -66,6 +68,7 @@ namespace Borepin.PageModel
Machine.IUseInterface useInterface = _Machine.Use; Machine.IUseInterface useInterface = _Machine.Use;
await useInterface.Use(); await useInterface.Use();
await LoadData();
} }
private ICommand _GiveBackMachineCommand; private ICommand _GiveBackMachineCommand;
@ -80,6 +83,7 @@ namespace Borepin.PageModel
Machine.IInUseInterface inUseInterface = _Machine.Inuse; Machine.IInUseInterface inUseInterface = _Machine.Inuse;
await inUseInterface.GiveBack(); await inUseInterface.GiveBack();
await LoadData();
} }
#endregion #endregion

View File

@ -4,6 +4,7 @@ using System.Threading.Tasks;
using Capnp.Rpc; using Capnp.Rpc;
using System.Collections.Generic; using System.Collections.Generic;
using FabAccessAPI.Schema; using FabAccessAPI.Schema;
using System.Net.Http;
namespace Borepin.Service.BFFH namespace Borepin.Service.BFFH
{ {
@ -18,11 +19,11 @@ namespace Borepin.Service.BFFH
_CredentialService = credentialService; _CredentialService = credentialService;
} }
public Model.Connection ActiveConnection { get; private set; } public Connection ActiveConnection { get; private set; }
public bool IsAuthenticated { 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) if (_Connection != null || ActiveConnection != null)
{ {
@ -63,7 +64,7 @@ namespace Borepin.Service.BFFH
return await Task.FromResult(true); 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 } }); 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; public TcpRpcClient? RpcClient => _rpcClient;
#region Log #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 #endregion
/// <summary> /// <summary>
@ -30,7 +30,7 @@ namespace FabAccessAPI
{ {
_rpcClient = rpcClient; _rpcClient = rpcClient;
_bootstrapCap = _rpcClient.GetMain<IBootstrap>(); _bootstrapCap = _rpcClient.GetMain<IBootstrap>();
_Log.Debug($"Done bootstraping API connection."); //_Log.Debug($"Done bootstraping API connection.");
} }
/// <summary> /// <summary>
@ -46,7 +46,7 @@ namespace FabAccessAPI
var authCap = await _bootstrapCap.AuthenticationSystem(cancellationToken_); var authCap = await _bootstrapCap.AuthenticationSystem(cancellationToken_);
_auth = new Auth(authCap); _auth = new Auth(authCap);
var mechs = await _auth.GetMechanisms(); 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)) if (!mechs.Contains(mech))
{ {