From 6fc28d2dc43411a31d09e598a58277d350d06467 Mon Sep 17 00:00:00 2001 From: MutonUfoAI Date: Mon, 12 Dec 2016 11:25:14 +0100 Subject: [PATCH] init SSHAuth plugin --- Plugins/SSHAuth/SSHAuth.sln | 20 ++++ .../SSHAuth/SSHAuth/Configuration.Designer.cs | 38 +++++++ Plugins/SSHAuth/SSHAuth/Configuration.cs | 19 ++++ Plugins/SSHAuth/SSHAuth/PluginImpl.cs | 102 ++++++++++++++++++ .../SSHAuth/Properties/AssemblyInfo.cs | 36 +++++++ Plugins/SSHAuth/SSHAuth/SSHAuth.csproj | 75 +++++++++++++ Plugins/SSHAuth/SSHAuth/Settings.cs | 27 +++++ 7 files changed, 317 insertions(+) create mode 100644 Plugins/SSHAuth/SSHAuth.sln create mode 100644 Plugins/SSHAuth/SSHAuth/Configuration.Designer.cs create mode 100644 Plugins/SSHAuth/SSHAuth/Configuration.cs create mode 100644 Plugins/SSHAuth/SSHAuth/PluginImpl.cs create mode 100644 Plugins/SSHAuth/SSHAuth/Properties/AssemblyInfo.cs create mode 100644 Plugins/SSHAuth/SSHAuth/SSHAuth.csproj create mode 100644 Plugins/SSHAuth/SSHAuth/Settings.cs diff --git a/Plugins/SSHAuth/SSHAuth.sln b/Plugins/SSHAuth/SSHAuth.sln new file mode 100644 index 00000000..9fe625d0 --- /dev/null +++ b/Plugins/SSHAuth/SSHAuth.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SSHAuth", "SSHAuth\SSHAuth.csproj", "{467F6B77-E4FE-47AB-BA14-4520C82EE3EF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {467F6B77-E4FE-47AB-BA14-4520C82EE3EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {467F6B77-E4FE-47AB-BA14-4520C82EE3EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {467F6B77-E4FE-47AB-BA14-4520C82EE3EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {467F6B77-E4FE-47AB-BA14-4520C82EE3EF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Plugins/SSHAuth/SSHAuth/Configuration.Designer.cs b/Plugins/SSHAuth/SSHAuth/Configuration.Designer.cs new file mode 100644 index 00000000..d9067ae6 --- /dev/null +++ b/Plugins/SSHAuth/SSHAuth/Configuration.Designer.cs @@ -0,0 +1,38 @@ +namespace pGina.Plugin.SSHAuth +{ + partial class Configuration + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Text = "Configuration"; + } + + #endregion + } +} \ No newline at end of file diff --git a/Plugins/SSHAuth/SSHAuth/Configuration.cs b/Plugins/SSHAuth/SSHAuth/Configuration.cs new file mode 100644 index 00000000..49028199 --- /dev/null +++ b/Plugins/SSHAuth/SSHAuth/Configuration.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace pGina.Plugin.SSHAuth +{ + public partial class Configuration : Form + { + public Configuration() + { + InitializeComponent(); + } + } +} diff --git a/Plugins/SSHAuth/SSHAuth/PluginImpl.cs b/Plugins/SSHAuth/SSHAuth/PluginImpl.cs new file mode 100644 index 00000000..25a49ccc --- /dev/null +++ b/Plugins/SSHAuth/SSHAuth/PluginImpl.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Diagnostics; + +using log4net; +using pGina.Shared.Interfaces; +using pGina.Shared.Types; + +namespace pGina.Plugin.SSHAuth +{ + public class PluginImpl : IPluginAuthentication, IPluginAuthorization, IPluginAuthenticationGateway ,IPluginChangePassword, IPluginConfiguration + { + private ILog m_logger = LogManager.GetLogger("SSHAuth"); + + #region Init-plugin + public static Guid PluginUuid + { + get { return new Guid("{CC35057C-ACA8-499C-B127-AE4CF978F238}"); } + } + + public PluginImpl() + { + using (Process me = Process.GetCurrentProcess()) + { + m_logger.DebugFormat("Plugin initialized on {0} in PID: {1} Session: {2}", Environment.MachineName, me.Id, me.SessionId); + } + } + + public string Name + { + get { return "SSHAuth"; } + } + + public string Description + { + get { return "SSHAuth plugin"; } + } + + public Guid Uuid + { + get { return PluginUuid; } + } + + public string Version + { + get + { + return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + } + } + #endregion + + public void Starting() { } + public void Stopping() { } + + public void Configure() + { + Configuration myDialog = new Configuration(); + myDialog.ShowDialog(); + } + + public BooleanResult AuthenticateUser(SessionProperties properties) + { + UserInformation userInfo = properties.GetTrackedSingle(); + + if (userInfo.Username.Contains("hello") && userInfo.Password.Contains("pGina")) + { + // Successful authentication + return new BooleanResult() { Success = true }; + } + // Authentication failure + return new BooleanResult() { Success = false, Message = "Incorrect username or password." }; + } + + public BooleanResult AuthorizeUser(SessionProperties properties) + { + return new BooleanResult() { Success = false, Message = "AuthorizeUser test fail" }; + } + + public BooleanResult AuthenticatedUserGateway(SessionProperties properties) + { + return new BooleanResult() { Success = false, Message = "AuthenticatedUserGateway test fail" }; + } + + public BooleanResult ChangePassword(SessionProperties properties, ChangePasswordPluginActivityInfo pluginInfo) + { + UserInformation userInfo = properties.GetTrackedSingle(); + if (userInfo.HasSID) + { + return new BooleanResult() + { + Success = false, + Message = String.Format("This is an error message") + }; + } + + return new BooleanResult() { Success = true }; + } + } +} diff --git a/Plugins/SSHAuth/SSHAuth/Properties/AssemblyInfo.cs b/Plugins/SSHAuth/SSHAuth/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..19ea5175 --- /dev/null +++ b/Plugins/SSHAuth/SSHAuth/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die mit einer Assembly verknüpft sind. +[assembly: AssemblyTitle("SSHAuth")] +[assembly: AssemblyDescription("ssh authentication")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("University of Illinois at Chicago")] +[assembly: AssemblyProduct("SSHAuth")] +[assembly: AssemblyCopyright("Copyright © University of Illinois at Chicago 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar +// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von +// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("dada0db3-2d35-4c73-b8eb-db290e6c895e")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("3.9.9.4")] +[assembly: AssemblyFileVersion("3.9.9.4")] diff --git a/Plugins/SSHAuth/SSHAuth/SSHAuth.csproj b/Plugins/SSHAuth/SSHAuth/SSHAuth.csproj new file mode 100644 index 00000000..809dcea0 --- /dev/null +++ b/Plugins/SSHAuth/SSHAuth/SSHAuth.csproj @@ -0,0 +1,75 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {467F6B77-E4FE-47AB-BA14-4520C82EE3EF} + Library + Properties + pGina.Plugin.SSHAuth + pGina.Plugin.SSHAuth + v4.0 + 512 + + + true + full + false + ..\..\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\bin\ + TRACE + prompt + 4 + + + + False + ..\..\..\pGina\src\bin\Abstractions.dll + + + False + ..\..\..\pGina\src\bin\log4net.dll + + + False + ..\..\..\pGina\src\bin\pGina.Shared.dll + + + + + + + + + + + + + + Form + + + Configuration.cs + + + + + + + + \ No newline at end of file diff --git a/Plugins/SSHAuth/SSHAuth/Settings.cs b/Plugins/SSHAuth/SSHAuth/Settings.cs new file mode 100644 index 00000000..2db2f550 --- /dev/null +++ b/Plugins/SSHAuth/SSHAuth/Settings.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using pGina.Shared.Settings; + +namespace pGina.Plugin.SSHAuth +{ + public class Settings + { + private static dynamic m_settings = new pGinaDynamicSettings(PluginImpl.PluginUuid); + + static Settings() + { + m_settings.SetDefault("Foo", "Bar"); + m_settings.SetDefault("DoSomething", true); + m_settings.SetDefault("ListOfStuff", new string[] { "a", "b", "c" }); + m_settings.SetDefault("Size", 1); + } + + public static dynamic Store + { + get { return m_settings; } + } + } +}