mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-11-22 09:12:17 -05:00
minor changes
This commit is contained in:
parent
9f8f00bb26
commit
c882981a29
2
.gitignore
vendored
2
.gitignore
vendored
@ -258,3 +258,5 @@ Thumbs.db
|
|||||||
/src/java/PluginInputStick/bin
|
/src/java/PluginInputStick/bin
|
||||||
|
|
||||||
/src/java/PluginInputStick/icons
|
/src/java/PluginInputStick/icons
|
||||||
|
|
||||||
|
/src/PluginSdkBinding/bin/Release
|
||||||
|
@ -1,17 +1,27 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Android.App;
|
using Android.App;
|
||||||
using Android.Content;
|
using Android.Content;
|
||||||
|
using Android.Content.PM;
|
||||||
using Android.Runtime;
|
using Android.Runtime;
|
||||||
using Android.Views;
|
using Android.Views;
|
||||||
using Android.Widget;
|
using Android.Widget;
|
||||||
using Android.OS;
|
using Android.OS;
|
||||||
|
using KeeChallenge;
|
||||||
|
using KeePassLib.Serialization;
|
||||||
|
using keepass2android;
|
||||||
|
using keepass2android.Io;
|
||||||
|
|
||||||
namespace ArtTestApp
|
namespace ArtTestApp
|
||||||
{
|
{
|
||||||
[Activity(Label = "ArtTestApp", MainLauncher = true, Icon = "@drawable/icon")]
|
[Activity(Label = "ArtTestApp", MainLauncher = true, Icon = "@drawable/icon")]
|
||||||
public class Activity1 : Activity
|
public class Activity1 : Activity
|
||||||
{
|
{
|
||||||
|
private ChallengeInfo _chalInfo;
|
||||||
|
private byte[] _challengeSecret;
|
||||||
|
private IOConnectionInfo _ioConnectionInfo;
|
||||||
|
private IOConnectionInfo _ioConnectionInfoOut;
|
||||||
|
private const int RequestCodeChallengeYubikey = 98;
|
||||||
|
|
||||||
protected override void OnCreate(Bundle bundle)
|
protected override void OnCreate(Bundle bundle)
|
||||||
{
|
{
|
||||||
@ -20,30 +30,87 @@ namespace ArtTestApp
|
|||||||
// Set our view from the "main" layout resource
|
// Set our view from the "main" layout resource
|
||||||
SetContentView(Resource.Layout.Main);
|
SetContentView(Resource.Layout.Main);
|
||||||
|
|
||||||
|
_ioConnectionInfo = new IOConnectionInfo() { Path = "/mnt/sdcard/keepass/keechallenge.xml" };
|
||||||
|
_ioConnectionInfoOut = new IOConnectionInfo() { Path = "/mnt/sdcard/keepass/keechallengeOut.xml" };
|
||||||
|
|
||||||
|
|
||||||
// Get our button from the layout resource,
|
// Get our button from the layout resource,
|
||||||
// and attach an event to it
|
// and attach an event to it
|
||||||
FindViewById<Button>(Resource.Id.MyButton1).Click += (sender, args) =>
|
FindViewById<Button>(Resource.Id.MyButton1).Click += (sender, args) =>
|
||||||
{
|
{
|
||||||
try
|
Decrypt(_ioConnectionInfo);
|
||||||
{
|
|
||||||
StartActivity(typeof (Activity2));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
FindViewById<Button>(Resource.Id.MyButton2).Click += (sender, args) =>
|
FindViewById<Button>(Resource.Id.MyButton2).Click += (sender, args) =>
|
||||||
{
|
{
|
||||||
Intent i = new Intent("blabla");
|
Decrypt(_ioConnectionInfoOut);
|
||||||
StartActivityForResult(i, 1);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
FindViewById<Button>(Resource.Id.MyButton3).Click += (sender, args) => StartActivityForResult(typeof(PrefActivity), 1);
|
FindViewById<Button>(Resource.Id.MyButton3).Click += (sender, args) => StartActivityForResult(typeof(PrefActivity), 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Decrypt(IOConnectionInfo ioConnectionInfo)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//StartActivity(typeof (Activity2));
|
||||||
|
_chalInfo = ChallengeInfo.Load(ioConnectionInfo);
|
||||||
|
Intent chalIntent = new Intent("com.yubichallenge.NFCActivity.CHALLENGE");
|
||||||
|
chalIntent.PutExtra("challenge", _chalInfo.Challenge);
|
||||||
|
chalIntent.PutExtra("slot", 2);
|
||||||
|
chalIntent.AddFlags(ActivityFlags.SingleTop);
|
||||||
|
IList<ResolveInfo> activities = PackageManager.QueryIntentActivities(chalIntent, 0);
|
||||||
|
bool isIntentSafe = activities.Count > 0;
|
||||||
|
if (isIntentSafe)
|
||||||
|
{
|
||||||
|
StartActivityForResult(chalIntent, RequestCodeChallengeYubikey);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
|
||||||
|
{
|
||||||
|
base.OnActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
|
if (requestCode == RequestCodeChallengeYubikey && resultCode == Result.Ok)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte[] challengeResponse = data.GetByteArrayExtra("response");
|
||||||
|
_challengeSecret = KeeChallengeProv.GetSecret(_chalInfo, challengeResponse);
|
||||||
|
Array.Clear(challengeResponse, 0, challengeResponse.Length);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Kp2aLog.Log(e.ToString());
|
||||||
|
Toast.MakeText(this, "Error: " + e.Message, ToastLength.Long).Show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_challengeSecret != null)
|
||||||
|
{
|
||||||
|
Toast.MakeText(this, "OK!", ToastLength.Long).Show();
|
||||||
|
ChallengeInfo temp = KeeChallengeProv.Encrypt(_challengeSecret, _chalInfo.IV);
|
||||||
|
if (!temp.Save(_ioConnectionInfoOut))
|
||||||
|
{
|
||||||
|
Toast.MakeText(this, "error writing file", ToastLength.Long).Show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Toast.MakeText(this, "Not good :-(", ToastLength.Long).Show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Activity1.cs" />
|
<Compile Include="Activity1.cs" />
|
||||||
<Compile Include="Activity2.cs" />
|
<Compile Include="Activity2.cs" />
|
||||||
|
<Compile Include="App.cs" />
|
||||||
|
<Compile Include="ChallengeInfo.cs" />
|
||||||
|
<Compile Include="KeeChallenge.cs" />
|
||||||
<Compile Include="PrefActivity.cs" />
|
<Compile Include="PrefActivity.cs" />
|
||||||
<Compile Include="Resources\Resource.Designer.cs" />
|
<Compile Include="Resources\Resource.Designer.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
@ -73,6 +76,16 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AndroidResource Include="Resources\Xml\pref.xml" />
|
<AndroidResource Include="Resources\Xml\pref.xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\KeePassLib2Android\KeePassLib2Android.csproj">
|
||||||
|
<Project>{545b4a6b-8bba-4fbe-92fc-4ac060122a54}</Project>
|
||||||
|
<Name>KeePassLib2Android</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Kp2aBusinessLogic\Kp2aBusinessLogic.csproj">
|
||||||
|
<Project>{53a9cb7f-6553-4bc0-b56b-9410bb2e59aa}</Project>
|
||||||
|
<Name>Kp2aBusinessLogic</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
Loading…
Reference in New Issue
Block a user