Skip to content

Commit

Permalink
initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippC committed Nov 20, 2017
1 parent be4d05b commit fc8ffa7
Show file tree
Hide file tree
Showing 27 changed files with 926 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/AutoFillPlugin/.vs/AutoFillPlugin/v15/*.suo
/AutoFillPlugin/*.user
*.suo
/AutoFillPlugin/bin/Debug
/AutoFillPlugin/bin/Release
/AutoFillPlugin/obj/Debug
/AutoFillPlugin/obj/Release
/Kp2aAccServiceLibBindings/bin/Debug
/Kp2aAccServiceLibBindings/bin/Release
/Kp2aAccServiceLibBindings/obj/Debug
/Kp2aAccServiceLibBindings/obj/Release
38 changes: 38 additions & 0 deletions AutoFillPlugin/AccessReceiver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Keepass2android.Pluginsdk;

namespace keepass2android.AutoFillPlugin
{
[BroadcastReceiver(Exported = true)]
[IntentFilter(new[] { Strings.ActionRequestAccess, Strings.ActionTriggerRequestAccess, Strings.ActionReceiveAccess, Strings.ActionRevokeAccess })]
public class AccessReceiver : PluginAccessBroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
Android.Util.Log.Debug("KP2AAS", intent.Action);
base.OnReceive(context, intent);
}


public override IList<string> Scopes
{
get
{
return new List<string>
{
Strings.ScopeQueryCredentials
};
}
}
}
}
19 changes: 19 additions & 0 deletions AutoFillPlugin/Assets/AboutAssets.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Any raw assets you want to be deployed with your application can be placed in
this directory (and child directories) and given a Build Action of "AndroidAsset".

These files will be deployed with you package and will be accessible using Android's
AssetManager, like this:

public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

InputStream input = Assets.Open ("my_asset.txt");
}
}

Additionally, some Android functions will automatically load asset files:

Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
104 changes: 104 additions & 0 deletions AutoFillPlugin/AutoFillPlugin.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6FF440E6-E8FF-4E43-8221-9E3972F14812}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>keepass2android.AutoFillPlugin</RootNamespace>
<AssemblyName>AutoFillPlugin</AssemblyName>
<FileAlignment>512</FileAlignment>
<AndroidApplication>true</AndroidApplication>
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v7.1</TargetFrameworkVersion>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Json" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AccessReceiver.cs" />
<Compile Include="Credentials.cs" />
<Compile Include="LookupCredentialsActivity.cs" />
<Compile Include="MainActivity.cs" />
<Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="GettingStarted.Xamarin" />
<None Include="Resources\AboutResources.txt" />
<None Include="Assets\AboutAssets.txt" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\values\Strings.xml" />
<AndroidResource Include="Resources\drawable-xhdpi\Icon.png" />
<AndroidResource Include="Resources\drawable-xhdpi\ic_notify_autofill.png" />
</ItemGroup>
<ItemGroup>
<None Include="Properties\AndroidManifest.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\xml\accserviceconfig.xml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\drawable\" />
<Folder Include="Resources\layout\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\keepass2android\src\KeePassLib2Android\KeePassLib2Android.csproj">
<Project>{545b4a6b-8bba-4fbe-92fc-4ac060122a54}</Project>
<Name>KeePassLib2Android</Name>
</ProjectReference>
<ProjectReference Include="..\..\keepass2android\src\PluginSdkBinding\PluginSdkBinding.csproj">
<Project>{3da3911e-36de-465e-8f15-f1991b6437e5}</Project>
<Name>PluginSdkBinding</Name>
</ProjectReference>
<ProjectReference Include="..\Kp2aAccServiceLibBindings\Kp2aAccServiceLibBindings.csproj">
<Project>{303c49ee-bef3-4a1a-af35-b813812a7b5a}</Project>
<Name>Kp2aAccServiceLibBindings</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="PluginSdkBinding.csproj" />
</ItemGroup>
<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.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
52 changes: 52 additions & 0 deletions AutoFillPlugin/AutoFillPlugin.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoFillPlugin", "AutoFillPlugin.csproj", "{6FF440E6-E8FF-4E43-8221-9E3972F14812}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeePassLib2Android", "..\..\keepass2android\src\KeePassLib2Android\KeePassLib2Android.csproj", "{545B4A6B-8BBA-4FBE-92FC-4AC060122A54}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kp2aAccServiceLibBindings", "..\Kp2aAccServiceLibBindings\Kp2aAccServiceLibBindings.csproj", "{303C49EE-BEF3-4A1A-AF35-B813812A7B5A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginSdkBinding", "..\..\keepass2android\src\PluginSdkBinding\PluginSdkBinding.csproj", "{3DA3911E-36DE-465E-8F15-F1991B6437E5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
ReleaseNoNet|Any CPU = ReleaseNoNet|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6FF440E6-E8FF-4E43-8221-9E3972F14812}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6FF440E6-E8FF-4E43-8221-9E3972F14812}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6FF440E6-E8FF-4E43-8221-9E3972F14812}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{6FF440E6-E8FF-4E43-8221-9E3972F14812}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6FF440E6-E8FF-4E43-8221-9E3972F14812}.Release|Any CPU.Build.0 = Release|Any CPU
{6FF440E6-E8FF-4E43-8221-9E3972F14812}.Release|Any CPU.Deploy.0 = Release|Any CPU
{6FF440E6-E8FF-4E43-8221-9E3972F14812}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
{6FF440E6-E8FF-4E43-8221-9E3972F14812}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
{6FF440E6-E8FF-4E43-8221-9E3972F14812}.ReleaseNoNet|Any CPU.Deploy.0 = Release|Any CPU
{545B4A6B-8BBA-4FBE-92FC-4AC060122A54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{545B4A6B-8BBA-4FBE-92FC-4AC060122A54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{545B4A6B-8BBA-4FBE-92FC-4AC060122A54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{545B4A6B-8BBA-4FBE-92FC-4AC060122A54}.Release|Any CPU.Build.0 = Release|Any CPU
{545B4A6B-8BBA-4FBE-92FC-4AC060122A54}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
{545B4A6B-8BBA-4FBE-92FC-4AC060122A54}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
{303C49EE-BEF3-4A1A-AF35-B813812A7B5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{303C49EE-BEF3-4A1A-AF35-B813812A7B5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{303C49EE-BEF3-4A1A-AF35-B813812A7B5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{303C49EE-BEF3-4A1A-AF35-B813812A7B5A}.Release|Any CPU.Build.0 = Release|Any CPU
{303C49EE-BEF3-4A1A-AF35-B813812A7B5A}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
{303C49EE-BEF3-4A1A-AF35-B813812A7B5A}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.Release|Any CPU.Build.0 = Release|Any CPU
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
21 changes: 21 additions & 0 deletions AutoFillPlugin/Credentials.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace keepass2android.AutoFillPlugin
{
public class Credentials
{
public string User;
public string Password;
public string Url;
}
}
4 changes: 4 additions & 0 deletions AutoFillPlugin/GettingStarted.Xamarin
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<GettingStarted>
<LocalContent>GS\Android\CS\AndroidApp\GettingStarted.html</LocalContent>
<EmbeddedNavigation>false</EmbeddedNavigation>
</GettingStarted>
98 changes: 98 additions & 0 deletions AutoFillPlugin/LookupCredentialsActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

using Keepass2android.Pluginsdk;
using KeePassLib;

namespace keepass2android.AutoFillPlugin
{
[Activity(Label = "@string/LookupTitle", LaunchMode = Android.Content.PM.LaunchMode.SingleInstance, Theme="@style/android:Theme.Material.Light")]
public class LookupCredentialsActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);

var url = Intent.GetStringExtra("UrlToSearch");

StartActivityForResult(Kp2aControl.GetQueryEntryIntent(url), 123);
}

protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);

try
{

string lastQueriedUrl = data.GetStringExtra(Strings.ExtraQueryString);


string entryId = data.GetStringExtra(Strings.ExtraEntryId);
var jsonOutput = new Org.Json.JSONObject(data.GetStringExtra(Strings.ExtraEntryOutputData));
Dictionary<string, string> output = new Dictionary<string, string>();
for (var iter = jsonOutput.Keys(); iter.HasNext;)
{
string key = iter.Next().ToString();
string value = jsonOutput.Get(key).ToString();
output[key] = value;
}


string user = "", password = "";
output.TryGetValue(KeePassLib.PwDefs.UserNameField, out user);
output.TryGetValue(KeePassLib.PwDefs.PasswordField, out password);
Android.Util.Log.Debug ("KP2AAS", "Received credentials for " + lastQueriedUrl);
bool hasData = false;
Keepass2android.Kbbridge.KeyboardDataBuilder kbdataBuilder = new Keepass2android.Kbbridge.KeyboardDataBuilder();

String[] keys = {PwDefs.UserNameField,
PwDefs.PasswordField,

};

int i = 0;
foreach (string key in keys)
{
String value;

if (output.TryGetValue(key, out value) && (value.Length > 0))
{
kbdataBuilder.AddString(key, keys[i], value);
hasData = true;
}
i++;
}

kbdataBuilder.Commit();
string title;
output.TryGetValue(PwDefs.TitleField, out title);
if (string.IsNullOrEmpty(title))
title = "untitled";
Keepass2android.Kbbridge.KeyboardData.EntryName = title;
Keepass2android.Kbbridge.KeyboardData.EntryId = entryId;
if (hasData)
Keepass2android.Autofill.AutoFillService.NotifyNewData(lastQueriedUrl);

}
catch(Exception e) {
Android.Util.Log.Debug ("KP2AAS", "Exception while receiving credentials: " + e.ToString());
}
finally {

Finish ();
}
}


}
}
27 changes: 27 additions & 0 deletions AutoFillPlugin/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace keepass2android.AutoFillPlugin
{
#if DEBUG
[Activity(Label = "MainActivity", MainLauncher =true)]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);

// Create your application here
}
}
#endif
}
Loading

0 comments on commit fc8ffa7

Please sign in to comment.