Async loading of Challenge file

This commit is contained in:
Philipp Crocoll 2014-04-04 05:16:32 +02:00
parent 8c15b38036
commit 147c0e19b6
5 changed files with 3424 additions and 3635 deletions

View File

@ -20,7 +20,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>False</Optimize> <Optimize>False</Optimize>
<OutputPath>bin\Debug</OutputPath> <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> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause> <ConsolePause>False</ConsolePause>

View File

@ -20,7 +20,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <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> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>

View File

@ -276,14 +276,8 @@ namespace keepass2android
{ {
if (_keyFileOrProvider == KeyProviderIdChallenge) if (_keyFileOrProvider == KeyProviderIdChallenge)
{ {
if (!LoadChalFile()) break; LoadChalFile();
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 { } else {
LoadOtpFile (); LoadOtpFile ();
} }
@ -330,31 +324,59 @@ namespace keepass2android
).Execute(); ).Execute();
} }
private bool LoadChalFile() private void LoadChalFile()
{ {
//TODO make async! new LoadingDialog<object, object, object>(this, true,
try //doInBackground
{ delegate
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;
}
if (_chalInfo == null) try
{ {
Toast.MakeText(this, IFileStorage fileStorage =
GetString(Resource.String.CouldntLoadChalAuxFile) + " " + GetString(Resource.String.CouldntLoadChalAuxFile_Hint) App.Kp2a.GetOtpAuxFileStorage(_ioConnection);
, ToastLength.Long).Show(); IOConnectionInfo iocAux =
return false; fileStorage.GetFilePath(
} fileStorage.GetParentPath(_ioConnection),
return true; 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) private void ShowOtpEntry(IList<string> prefilledOtps)

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath> <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> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause> <ConsolePause>False</ConsolePause>
@ -171,7 +171,6 @@
<Compile Include="app\AppTask.cs" /> <Compile Include="app\AppTask.cs" />
<Compile Include="views\TextWithHelp.cs" /> <Compile Include="views\TextWithHelp.cs" />
<Compile Include="addons\KeeChallenge\KeeChallenge.cs" /> <Compile Include="addons\KeeChallenge\KeeChallenge.cs" />
<Compile Include="NfcChalActivity.cs" />
<Compile Include="addons\KeeChallenge\ChallengeInfo.cs" /> <Compile Include="addons\KeeChallenge\ChallengeInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>