Esempio n. 1
0
        /// <summary>
        /// </summary>
        public PolicyEngine()
        {
            m_GeneralPolicyProcessor = new GeneralPolicyProcessor();

            m_GeneralPolicyProcessor.ExceptionHandler += new ExceptionEventHandler(OnException);
            m_GeneralPolicyProcessor.PolicyProgressEvent += new PolicyProgressEventHandler(OnPolicyProgress);
        }
Esempio n. 2
0
        private GeneralPolicyProcessor InitialiseGPP(ICompiledPolicySetCache compiledPolicy)
        {
            if (compiledPolicy == null)
                return null;

            string lang = GetCurrentCulturesLanguageFile(compiledPolicy);
            string content = compiledPolicy.Content;

            PolicySetLanguageMerger pslm = new PolicySetLanguageMerger();
            content = pslm.Merge(content, lang);

            GeneralPolicyProcessor gpp = new GeneralPolicyProcessor();
			gpp.ExceptionHandler += new ExceptionEventHandler(OnException);

            gpp.Initialise(m_runAt, content, compiledPolicy.ObjectReferences);

            return gpp;
        }
Esempio n. 3
0
		public BaseContentScanner(string name, IPolicySetVersionCache cache, PolicyType policyType, string runAt)
		{
			SkipDiscovery = false;
			m_policySetName = name;
			m_cache = cache; //keep it for cloning.

			m_runAt = (RunAt) Enum.Parse(typeof(RunAt), runAt);
			m_policyType = policyType;

			string channel = GetChannelForPolicyType(policyType);

			//Get the primary compiled cache
			ICompiledPolicySetCache icpsc = cache.GetCompiledPolicySet(channel, runAt);
			m_gpp = InitialiseGPP(icpsc);

			//For performance, a separate cache is available for messages with 0 attachments - this will be passed to a 
			//separate policy processor.  
			if (PolicyType.ClientEmail == policyType ||
				PolicyType.Mta == policyType)
			{
				foreach (ICompiledPolicySetCache compiled in cache.CompiledPolicySets)
				{
					//Ignore any other channels that we come across.
					if (channel != compiled.Channel)
						continue;

					//Perfect matches on 'target' should be discarded - we already found the primary cache in the call to GetCompiledPolicySet.
					if (0 == string.Compare(runAt, compiled.Target, StringComparison.InvariantCultureIgnoreCase))
						continue;

					if (compiled.Target.Contains(runAt))
					{
						m_zeroAttachmentGpp = InitialiseGPP(compiled);
						break;
						//Assumes that (for example) the 'Client - reduced policy set' compiled cache will always contain the word 'Client'
					}
				}
			}
		}
Esempio n. 4
0
        private static void ProcessActions(GeneralPolicyProcessor gpp, PolicyResponseObject pro, bool skipDiscovery)
        {
            Logger.LogTrace("ContentScanner: ProcessActions ENTER");
            foreach( IContentItem contentItem in pro.ContentCollection)
			{
				Debug.Assert(1 == contentItem.PolicySetCollection.Count,
							 "This collection should only contain one policy set - we only passed one in (see constructor)");

				double size = contentItem.Size;
				PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.ContentScanActionsSize);
				PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.ContentScanActions);
				gpp.SkipDiscovery = skipDiscovery;
				gpp.ProcessAction(contentItem, contentItem.PolicySetCollection[0]);

				List<IPolicyResponseAction> actions = ActionUtils.AssociateFilesWithActions(contentItem);

				gpp.ProcessExceptionAction(contentItem, contentItem.PolicySetCollection[0]);
				PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.ContentScanActions, 0);
				PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.ContentScanActionsSize, size);
			}
            Logger.LogTrace("ContentScanner: ProcessActions EXIT");
        }
Esempio n. 5
0
        private static void ProcessRouting(GeneralPolicyProcessor gpp, PolicyResponseObject pro)
        {
            Logger.LogTrace("ContentScanner: ProcessRouting ENTER");
            foreach (IContentItem contentItem in pro.ContentCollection)
            {
                Debug.Assert(1 == contentItem.PolicySetCollection.Count,
                             "This collection should only contain one policy set - we only passed one in (see constructor)");

                double size = contentItem.Size;
                PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.ContentScanRoutingSize);
                PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.ContentScanRouting);
                gpp.ProcessRouting(contentItem, contentItem.PolicySetCollection[0]);
                PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.ContentScanRouting, 0);
                PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.ContentScanRoutingSize, size);
            }
            Logger.LogTrace("ContentScanner: ProcessRouting EXIT");
        }
Esempio n. 6
0
 private static void ProcessExpressions(GeneralPolicyProcessor gpp, PolicyResponseObject pro)
 {
     Logger.LogTrace("ContentScanner: ProcessExpressions ENTER");
     foreach (IContentItem contentItem in pro.ContentCollection)
     {
         double size = contentItem.Size;
         PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.ContentScanExpressionSize);
         PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.ContentScanExpression);
         gpp.ProcessFileInfo(contentItem);
         PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.ContentScanExpression, 0);
         PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.ContentScanExpressionSize, size);
     }
     Logger.LogTrace("ContentScanner: ProcessExpressions EXIT");
 }
Esempio n. 7
0
 private static void TearDownPolicyProcessor(GeneralPolicyProcessor gpp)
 {
     gpp.TearDown();
 }
Esempio n. 8
0
        private void SetupPolicyProcessor(GeneralPolicyProcessor gpp, IUniversalRequestObject uro)
        {
            Logger.LogTrace("ContentScanner: SetupPolicyProcessor ENTER");
            gpp.Source = uro.Source;
            gpp.Destination = uro.Destination;

            string[] addresses = AddressUtilities.GetRecipientAddressList(uro);
            gpp.RecipientList = addresses;

            gpp.CurrentRunAtMode = m_runAt;
            Logger.LogTrace("ContentScanner: SetupPolicyProcessor EXIT");
        }
Esempio n. 9
0
		private static void ProcessActions(GeneralPolicyProcessor gpp, PolicyResponseObject pro, bool skipDiscovery)
		{
			foreach (IContentItem contentItem in pro.ContentCollection)
			{
                if (contentItem.Properties.ContainsKey("SkipScanning")
                    && (string.Equals(contentItem.Type, "PDFDocument", StringComparison.InvariantCultureIgnoreCase)
                        || contentItem.Properties.ContainsKey("ReadProtected")
                       )
                   )
				{
					continue;
				}

				Debug.Assert(1 == contentItem.PolicySetCollection.Count,
							 "This collection should only contain one policy set - we only passed one in (see constructor)");

				double size = contentItem.Size;
				PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.ContentScanActionsSize);
				PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.ContentScanActions);
				gpp.SkipDiscovery = skipDiscovery;
				gpp.ProcessAction(contentItem, contentItem.PolicySetCollection[0]);

				List<IPolicyResponseAction> actions = ActionUtils.AssociateFilesWithActions(contentItem);

				gpp.ProcessExceptionAction(contentItem, contentItem.PolicySetCollection[0]);
				PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.ContentScanActions, 0);
				PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.ContentScanActionsSize, size);
			}
		}
Esempio n. 10
0
		private static void ProcessRouting(GeneralPolicyProcessor gpp, PolicyResponseObject pro)
		{
			foreach (IContentItem contentItem in pro.ContentCollection)
			{
                if (contentItem.Properties.ContainsKey("SkipScanning")
                    && (string.Equals(contentItem.Type, "PDFDocument", StringComparison.InvariantCultureIgnoreCase)
                        || contentItem.Properties.ContainsKey("ReadProtected")
                       )
                   )
				{
					continue;
				}
				
				Debug.Assert(1 == contentItem.PolicySetCollection.Count, "This collection should only contain one policy set - we only passed one in (see constructor)");

				double size = contentItem.Size;
				PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.ContentScanRoutingSize);
				PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.ContentScanRouting);
				gpp.ProcessRouting(contentItem, contentItem.PolicySetCollection[0]);
				PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.ContentScanRouting, 0);
				PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.ContentScanRoutingSize, size);
			}
		}
Esempio n. 11
0
		private static void ProcessExpressions(GeneralPolicyProcessor gpp, PolicyResponseObject pro)
		{
			foreach (IContentItem contentItem in pro.ContentCollection)
			{
                if (contentItem.Properties.ContainsKey("SkipScanning")
                    && (string.Equals(contentItem.Type, "PDFDocument", StringComparison.InvariantCultureIgnoreCase)
                        || contentItem.Properties.ContainsKey("ReadProtected")
                       )
                   )
				{
					continue;
				}
				
				double size = contentItem.Size;
				PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.ContentScanExpressionSize);
				PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.ContentScanExpression);
				gpp.ProcessFileInfo(contentItem);
				PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.ContentScanExpression, 0);
				PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.ContentScanExpressionSize, size);
			}
		}
Esempio n. 12
0
		private void SetupPolicyProcessor(GeneralPolicyProcessor gpp, IUniversalRequestObject uro)
		{
			gpp.Source = uro.Source;
			gpp.Destination = uro.Destination;

			string[] addresses = AddressUtilities.GetRecipientAddressList(uro);
			gpp.RecipientList = addresses;

			gpp.CurrentRunAtMode = m_runAt;
		}