// Overrides the IWMSEventNotificationPlugin.OnEvent method. This // implementation displays a message box when a client either // connects or disconnects. public void OnEvent( ref WMS_EVENT Event, IWMSContext UserCtx, IWMSContext PresentationCtx, IWMSCommandContext CommandCtx) { try { switch (Event.Type) { case WMS_EVENT_TYPE.WMS_EVENT_CONNECT: MessageBox.Show("Client connected", "Event Plug-in", MessageBoxButtons.OK); break; case WMS_EVENT_TYPE.WMS_EVENT_DISCONNECT: MessageBox.Show("Client disconnected", "Event Plug-in", MessageBoxButtons.OK); break; } } catch (Exception e) { MessageBox.Show(e.Message, "Event Plug-in Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void AuthorizeEvent(ref WMS_EVENT pEvent, IWMSContext pUserCtx, IWMSContext pPresentationCtx, IWMSCommandContext pCommandCtx, IWMSEventAuthorizationCallback pCallback, object Context) { int hr = 0; // By deafault access is granted to user const int ACCESS_DENIED = unchecked ((int)0x80070005); string initial_request = null; string user_ip_address = null; string user_agent = null; pPresentationCtx.GetStringValue(WMSDefines.WMS_PRESENT_REQUEST_NAME, WMSDefines.WMS_PRESENT_REQUEST_NAME_ID, out initial_request, 0); pUserCtx.GetStringValue(WMSDefines.WMS_USER_IP_ADDRESS_STRING, WMSDefines.WMS_USER_IP_ADDRESS_STRING_ID, out user_ip_address, 0); if (log.IsInfoEnabled) { pUserCtx.GetStringValue(WMSDefines.WMS_USER_AGENT, WMSDefines.WMS_USER_AGENT_ID, out user_agent, 0); } URLValidationExceptionTyte errortype = url_procesor.CheckURLValidity(initial_request, user_ip_address); if (URLValidationExceptionTyte.SUCCESS != errortype) { hr = ACCESS_DENIED; } if (log.IsInfoEnabled) { StringBuilder msg = new StringBuilder(); if (user_agent != null) { msg.Append("User-Agent=" + user_agent); } msg.Append(" User-Ip-Address=" + user_ip_address); msg.Append(" Request=" + initial_request); msg.Append(" Autorization-Result=" + errortype.ToString()); log.Info(msg.ToString()); } pCallback.OnAuthorizeEvent(hr, Context); }
public void AuthorizeEvent(ref WMS_EVENT pEvent, IWMSContext pUserCtx, IWMSContext pPresentationCtx, IWMSCommandContext pCommandCtx, IWMSEventAuthorizationCallback pCallback, object Context) { int hr = 0; // By deafault access is granted to user const int ACCESS_DENIED = unchecked((int)0x80070005); string initial_request = null; string user_ip_address = null; string user_agent = null; pPresentationCtx.GetStringValue(WMSDefines.WMS_PRESENT_REQUEST_NAME, WMSDefines.WMS_PRESENT_REQUEST_NAME_ID, out initial_request, 0); pUserCtx.GetStringValue(WMSDefines.WMS_USER_IP_ADDRESS_STRING, WMSDefines.WMS_USER_IP_ADDRESS_STRING_ID, out user_ip_address, 0); if (log.IsInfoEnabled) { pUserCtx.GetStringValue(WMSDefines.WMS_USER_AGENT, WMSDefines.WMS_USER_AGENT_ID, out user_agent, 0); } URLValidationExceptionTyte errortype = url_procesor.CheckURLValidity(initial_request, user_ip_address); if (URLValidationExceptionTyte.SUCCESS != errortype) { hr = ACCESS_DENIED; } if (log.IsInfoEnabled) { StringBuilder msg = new StringBuilder(); if(user_agent != null)msg.Append("User-Agent="+ user_agent); msg.Append(" User-Ip-Address="+user_ip_address); msg.Append(" Request="+initial_request); msg.Append(" Autorization-Result=" + errortype.ToString()); log.Info(msg.ToString()); } pCallback.OnAuthorizeEvent(hr, Context); }
public void AuthorizeEvent(ref WMS_EVENT pEvent, IWMSContext pUserCtx, IWMSContext pPresentationCtx, IWMSCommandContext pCommandCtx, IWMSEventAuthorizationCallback pCallback, object Context) { int hr = 0; // By deafault access is granted to user const int ACCESS_DENIED = unchecked((int)0x80070005); string user_ip_address = null; pUserCtx.GetStringValue(WMSDefines.WMS_USER_IP_ADDRESS_STRING, WMSDefines.WMS_USER_IP_ADDRESS_STRING_ID, out user_ip_address, 0); try { DateTime lastWrite = System.IO.File.GetLastWriteTime(denylistname); if (denyList == null) { denyList = IPListLoader.loadIpList(denylistname); lastWriteTime = lastWrite; } else if (lastWriteTime.Ticks != lastWrite.Ticks) { denyList = IPListLoader.loadIpList(denylistname); lastWriteTime = lastWrite; } if (denyList.CheckNumber(user_ip_address)) { hr = ACCESS_DENIED; } } catch (Exception e) { } pCallback.OnAuthorizeEvent(hr, Context); }