mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-12-23 07:28:48 -05:00
Async loading of Challenge file
This commit is contained in:
parent
8c15b38036
commit
147c0e19b6
@ -20,7 +20,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>False</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;EXCLUDE_TWOFISH;INCLUDE_KEYBOARD;INCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE;INCLUDE_KEYTRANSFORM</DefineConstants>
|
||||
<DefineConstants>DEBUG;EXCLUDE_TWOFISH;EXCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;EXCLUDE_JAVAFILESTORAGE;EXCLUDE_KEYTRANSFORM</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>False</ConsolePause>
|
||||
|
@ -20,7 +20,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;EXCLUDE_TWOFISH;INCLUDE_KEYBOARD;INCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE;INCLUDE_KEYTRANSFORM</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;EXCLUDE_TWOFISH;EXCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;EXCLUDE_JAVAFILESTORAGE;EXCLUDE_KEYTRANSFORM</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
|
@ -276,14 +276,8 @@ namespace keepass2android
|
||||
{
|
||||
if (_keyFileOrProvider == KeyProviderIdChallenge)
|
||||
{
|
||||
if (!LoadChalFile()) break;
|
||||
Intent chalIntent = new Intent("com.yubichallenge.NFCActivity.CHALLENGE");
|
||||
chalIntent.PutExtra("challenge", _chalInfo.Challenge);
|
||||
chalIntent.PutExtra("slot", 2);
|
||||
IList<ResolveInfo> activities = PackageManager.QueryIntentActivities(chalIntent, 0);
|
||||
bool isIntentSafe = activities.Count > 0;
|
||||
if (isIntentSafe)
|
||||
StartActivityForResult(chalIntent, RequestCodeChallengeYubikey);
|
||||
LoadChalFile();
|
||||
|
||||
} else {
|
||||
LoadOtpFile ();
|
||||
}
|
||||
@ -330,31 +324,59 @@ namespace keepass2android
|
||||
).Execute();
|
||||
}
|
||||
|
||||
private bool LoadChalFile()
|
||||
private void LoadChalFile()
|
||||
{
|
||||
//TODO make async!
|
||||
try
|
||||
{
|
||||
IFileStorage fileStorage = App.Kp2a.GetOtpAuxFileStorage(_ioConnection);
|
||||
IOConnectionInfo iocAux = fileStorage.GetFilePath(fileStorage.GetParentPath(_ioConnection),
|
||||
fileStorage.GetFilenameWithoutPathAndExt(_ioConnection) + ".xml");
|
||||
|
||||
_chalInfo = ChallengeInfo.Load(iocAux);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
return false;
|
||||
}
|
||||
new LoadingDialog<object, object, object>(this, true,
|
||||
//doInBackground
|
||||
delegate
|
||||
{
|
||||
|
||||
if (_chalInfo == null)
|
||||
{
|
||||
Toast.MakeText(this,
|
||||
GetString(Resource.String.CouldntLoadChalAuxFile) + " " + GetString(Resource.String.CouldntLoadChalAuxFile_Hint)
|
||||
, ToastLength.Long).Show();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
try
|
||||
{
|
||||
IFileStorage fileStorage =
|
||||
App.Kp2a.GetOtpAuxFileStorage(_ioConnection);
|
||||
IOConnectionInfo iocAux =
|
||||
fileStorage.GetFilePath(
|
||||
fileStorage.GetParentPath(_ioConnection),
|
||||
fileStorage.GetFilenameWithoutPathAndExt(_ioConnection) +
|
||||
".xml");
|
||||
|
||||
_chalInfo = ChallengeInfo.Load(iocAux);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
, delegate
|
||||
{
|
||||
if (_chalInfo == null)
|
||||
{
|
||||
Toast.MakeText(this,
|
||||
GetString(Resource.String.CouldntLoadChalAuxFile) +
|
||||
" " +
|
||||
GetString(
|
||||
Resource.String.CouldntLoadChalAuxFile_Hint)
|
||||
, ToastLength.Long).Show();
|
||||
return;
|
||||
|
||||
}
|
||||
Intent chalIntent = new Intent("com.yubichallenge.NFCActivity.CHALLENGE");
|
||||
chalIntent.PutExtra("challenge", _chalInfo.Challenge);
|
||||
chalIntent.PutExtra("slot", 2);
|
||||
IList<ResolveInfo> activities = PackageManager.QueryIntentActivities(chalIntent, 0);
|
||||
bool isIntentSafe = activities.Count > 0;
|
||||
if (isIntentSafe)
|
||||
{
|
||||
StartActivityForResult(chalIntent, RequestCodeChallengeYubikey);
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO message no plugin!
|
||||
}
|
||||
}).Execute();
|
||||
|
||||
}
|
||||
|
||||
private void ShowOtpEntry(IList<string> prefilledOtps)
|
||||
|
6968
src/keepass2android/Resources/Resource.designer.cs
generated
6968
src/keepass2android/Resources/Resource.designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -30,7 +30,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;EXCLUDE_TWOFISH;INCLUDE_KEYBOARD;INCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE;INCLUDE_KEYTRANSFORM</DefineConstants>
|
||||
<DefineConstants>DEBUG;EXCLUDE_TWOFISH;EXCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;EXCLUDE_JAVAFILESTORAGE;EXCLUDE_KEYTRANSFORM</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>False</ConsolePause>
|
||||
@ -171,7 +171,6 @@
|
||||
<Compile Include="app\AppTask.cs" />
|
||||
<Compile Include="views\TextWithHelp.cs" />
|
||||
<Compile Include="addons\KeeChallenge\KeeChallenge.cs" />
|
||||
<Compile Include="NfcChalActivity.cs" />
|
||||
<Compile Include="addons\KeeChallenge\ChallengeInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user