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>
<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>

View File

@ -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>

View File

@ -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)

File diff suppressed because it is too large Load Diff

View File

@ -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>