Skip to content

Commit

Permalink
Added optional portable/admin configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
aalbng committed Dec 22, 2016
1 parent 8a787ff commit f9bb47c
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 15 deletions.
30 changes: 20 additions & 10 deletions AdvancedConnectPlugin/AdvancedConnectExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ with the License. You may obtain a copy of the License at
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
*/
using AdvancedConnectPlugin.Tools;
using KeePass.Plugins;
using System;
using System.Drawing;
using System.IO;


using System.Reflection;

namespace AdvancedConnectPlugin
{
Expand Down Expand Up @@ -61,18 +61,28 @@ public override void Terminate()
this.toolsMenuExtension.removeToolsMenuExtensions();
}

//Build configuration folder structure
//Build configuration
public void buildConfigPath()
{
//Set and create directory
String configDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "KeePass/");
System.IO.Directory.CreateDirectory(configDirectory);

//Set configuration file path
//Set configuration file name
String configFileName = "AdvancedConnect.xml";
this.pathToPluginConfigFile = Path.Combine(configDirectory, configFileName);
}
String configDirectory = String.Empty;

//Check if portable / admin configuration is available
if (File.Exists(Path.Combine(ExecutableDirectory.GetExecutableDirectory(), configFileName)))
{
//Set directory in installation path (portable configuration)
configDirectory = ExecutableDirectory.GetExecutableDirectory();
this.pathToPluginConfigFile = Path.Combine(configDirectory, configFileName);
}
else
{
//Set and create directory within appdata roaming (user configuration)
configDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "KeePass/");
System.IO.Directory.CreateDirectory(configDirectory);
this.pathToPluginConfigFile = Path.Combine(configDirectory, configFileName);
}
}

}
}
1 change: 1 addition & 0 deletions AdvancedConnectPlugin/AdvancedConnectPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="GUI\ToolsMenuExtension.cs" />
<Compile Include="Data\Settings.cs" />
<Compile Include="Tools\ExecutableDirectory.cs" />
<Compile Include="Tools\SortableBindingList.cs" />
<Compile Include="Tools\StartProcess.cs" />
<Compile Include="Tools\StringCustom.cs" />
Expand Down
3 changes: 3 additions & 0 deletions AdvancedConnectPlugin/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.0.4
Added optional portable/admin configuration

1.0.3
Added Unix/Linux compatibility

Expand Down
23 changes: 18 additions & 5 deletions AdvancedConnectPlugin/Data/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,29 @@ public Settings load()
{
XmlSerializer serializerObj = new XmlSerializer(typeof(Settings));
FileStream readFileStream = new FileStream(this.plugin.pathToPluginConfigFile, FileMode.Open, FileAccess.Read, FileShare.Read);
loadedSettings = (Settings)serializerObj.Deserialize(readFileStream);
readFileStream.Close();

//Try to parse settings from configuration file. Create new configuration on parsing error
try
{
//Load configuration
loadedSettings = (Settings)serializerObj.Deserialize(readFileStream);
}
catch (InvalidOperationException)
{
//Create new configuration on error
loadedSettings = new Settings();
}
finally
{
readFileStream.Close();
}
}
else
{
//Create new configuration file if there is no configuration file present
loadedSettings = new Settings();
}




loadedSettings.plugin = this.plugin;
return loadedSettings;
}
Expand Down
32 changes: 32 additions & 0 deletions AdvancedConnectPlugin/Tools/ExecutableDirectory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright 2016 TGW Software Services GmbH
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;

namespace AdvancedConnectPlugin.Tools
{
public static class ExecutableDirectory
{
//Returns the assembly directory
public static string GetExecutableDirectory()
{
string codeBase = Assembly.GetEntryAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}
}
141 changes: 141 additions & 0 deletions Libs/KeePass.config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Meta>
<PreferUserConfiguration>false</PreferUserConfiguration>
<OmitItemsWithDefaultValues>true</OmitItemsWithDefaultValues>
</Meta>
<Application>
<LastUsedFile>
<Path />
<CredProtMode>Obf</CredProtMode>
<CredSaveMode>NoSave</CredSaveMode>
</LastUsedFile>
<MostRecentlyUsed>
<MaxItemCount>12</MaxItemCount>
<Items />
</MostRecentlyUsed>
<WorkingDirectories />
<Start>
<CheckForUpdate>false</CheckForUpdate>
<CheckForUpdateConfigured>true</CheckForUpdateConfigured>
</Start>
<FileOpening />
<FileClosing />
<TriggerSystem>
<Triggers />
</TriggerSystem>
</Application>
<Logging />
<MainWindow>
<X>625</X>
<Y>317</Y>
<Width>670</Width>
<Height>525</Height>
<SplitterHorizontalFrac>0.8313253</SplitterHorizontalFrac>
<SplitterVerticalFrac>0.250764519</SplitterVerticalFrac>
<Layout>Default</Layout>
<ToolBar />
<EntryView />
<TanView />
<EntryListColumnCollection>
<Column>
<Type>Title</Type>
<Width>90</Width>
</Column>
<Column>
<Type>UserName</Type>
<Width>90</Width>
</Column>
<Column>
<Type>Password</Type>
<Width>90</Width>
<HideWithAsterisks>true</HideWithAsterisks>
</Column>
<Column>
<Type>Url</Type>
<Width>90</Width>
</Column>
<Column>
<Type>Notes</Type>
<Width>90</Width>
</Column>
</EntryListColumnCollection>
<EntryListColumnDisplayOrder>0 1 2 3 4</EntryListColumnDisplayOrder>
<ListSorting>
<Order>Ascending</Order>
</ListSorting>
</MainWindow>
<UI>
<TrayIcon />
<Hiding />
<StandardFont>
<Family>Microsoft Sans Serif</Family>
<Size>8.25</Size>
<GraphicsUnit>Point</GraphicsUnit>
<Style>Regular</Style>
<OverrideUIDefault>false</OverrideUIDefault>
</StandardFont>
<PasswordFont>
<Family>Courier New</Family>
<Size>8.25</Size>
<GraphicsUnit>Point</GraphicsUnit>
<Style>Regular</Style>
<OverrideUIDefault>false</OverrideUIDefault>
</PasswordFont>
<BannerStyle>WinVistaBlack</BannerStyle>
<DataEditorFont>
<Family>Microsoft Sans Serif</Family>
<Size>8.25</Size>
<GraphicsUnit>Point</GraphicsUnit>
<Style>Regular</Style>
<OverrideUIDefault>false</OverrideUIDefault>
</DataEditorFont>
<UIFlags>0</UIFlags>
<KeyCreationFlags>0</KeyCreationFlags>
<KeyPromptFlags>0</KeyPromptFlags>
</UI>
<Security>
<WorkspaceLocking>
<LockAfterTime>0</LockAfterTime>
<LockAfterGlobalTime>0</LockAfterGlobalTime>
</WorkspaceLocking>
<Policy />
<MasterPassword>
<MinimumLength>0</MinimumLength>
<MinimumQuality>0</MinimumQuality>
</MasterPassword>
</Security>
<Native />
<PasswordGenerator>
<AutoGeneratedPasswordsProfile>
<GeneratorType>CharSet</GeneratorType>
<Length>20</Length>
<CharSetRanges>ULD_______</CharSetRanges>
</AutoGeneratedPasswordsProfile>
<LastUsedProfile>
<GeneratorType>CharSet</GeneratorType>
<Length>20</Length>
<CharSetRanges>ULD_______</CharSetRanges>
</LastUsedProfile>
<UserProfiles />
</PasswordGenerator>
<Defaults>
<OptionsTabIndex>0</OptionsTabIndex>
<SearchParameters>
<ComparisonMode>InvariantCultureIgnoreCase</ComparisonMode>
</SearchParameters>
<KeySources />
</Defaults>
<Integration>
<HotKeyGlobalAutoType>393281</HotKeyGlobalAutoType>
<HotKeySelectedAutoType>0</HotKeySelectedAutoType>
<HotKeyShowWindow>393291</HotKeyShowWindow>
<HotKeyEntryMenu>0</HotKeyEntryMenu>
<UrlSchemeOverrides>
<BuiltInOverridesEnabled>1</BuiltInOverridesEnabled>
<CustomOverrides />
</UrlSchemeOverrides>
<ProxyType>System</ProxyType>
</Integration>
<Custom />
</Configuration>
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ AdvancedConnect is a plugin for [KeePass](http://keepass.info) password manager
On windows operation system the native remote desktop client have no option to provide the username and password via command-line. The built-in rdp support is a little workaround wich provides this functionality. You have to configure the keepass connection field (containing ip or hostname), a connection method (e.g. rdp) and you can set additional parameters (e.g. /w:1440 /h:900).<br />
- Use the **Applications** tab in the **Options** dialog to configure your connection applications. <br />
The **Path** and **Commandline Options** column is also supporting keepass placeholders and OS environment variables.
- To use a **portable configuration** you have to create a emtpy file named **AdvancedConnect.xml** next to **KeePass.exe**. <br />
(If a portable\admin configuration file is available, the default configuration *%appdata%\Keepass\AdvancedConnect.xml* will be ignored)


## Example
Expand Down

0 comments on commit f9bb47c

Please sign in to comment.