Last active
November 4, 2016 14:34
-
-
Save emrekgn/9448b60edc3dc8e0c6b27f747f45b32a to your computer and use it in GitHub Desktop.
Sample Implementation for Ahenk pGina Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.ServiceProcess; | |
using System.Text; | |
using pGina.Shared.Types; | |
using log4net; | |
/* | |
* See https://github.com/pgina/pgina/wiki/Plugin-Tutorial | |
* for more info! | |
*/ | |
namespace AhenkPlugin | |
{ | |
public class PluginImpl : pGina.Shared.Interfaces.IPluginAuthenticationGateway, pGina.Shared.Interfaces.IPluginEventNotifications | |
{ | |
private ILog m_logger; | |
public PluginImpl() | |
{ | |
m_logger = LogManager.GetLogger("pGina.Plugin.AhenkPlugin"); | |
} | |
public string Description | |
{ | |
get | |
{ | |
return "Ahenk pGina Plugin for policy processing & logging"; | |
} | |
} | |
public string Name | |
{ | |
get | |
{ | |
return "Ahenk pGina Plugin"; | |
} | |
} | |
private static readonly Guid m_uuid = new Guid("D5C4D580-B3B2-4B0F-9244-1FF4B7F797E0"); | |
public Guid Uuid | |
{ | |
get | |
{ | |
return m_uuid; | |
} | |
} | |
public string Version | |
{ | |
get | |
{ | |
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); | |
} | |
} | |
public BooleanResult AuthenticatedUserGateway(SessionProperties properties) | |
{ | |
UserInformation userInfo = properties.GetTrackedSingle<UserInformation>(); | |
m_logger.InfoFormat("User successfully authenticated {0}", userInfo.Username); | |
return new BooleanResult() { Success = true }; | |
} | |
public void SessionChange(SessionChangeDescription changeDescription, SessionProperties properties) | |
{ | |
m_logger.InfoFormat("Session change. reaseon: {0}, id:{1}", changeDescription.Reason, changeDescription.SessionId); | |
UserInformation userInfo = properties.GetTrackedSingle<UserInformation>(); | |
/* | |
* See https://msdn.microsoft.com/en-us/library/system.serviceprocess.sessionchangedescription.aspx | |
* for session change description | |
*/ | |
switch (changeDescription.Reason) | |
{ | |
case SessionChangeReason.SessionLogon: | |
case SessionChangeReason.SessionUnlock: | |
m_logger.InfoFormat("User logged on {0}", userInfo.Username); | |
break; | |
case SessionChangeReason.SessionLogoff: | |
case SessionChangeReason.SessionLock: | |
m_logger.InfoFormat("User logged off {0}", userInfo.Username); | |
break; | |
default: | |
break; | |
} | |
throw new NotImplementedException(); | |
} | |
public void Starting() | |
{ | |
} | |
public void Stopping() | |
{ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment