Пример #1
0
        private void CompileNxBrePolicySet(IPolicySetVersionCache version, IPolicySet policySet, string target)
        {
            if ((null == version) || (null == policySet) || (string.IsNullOrEmpty(target)))
                return;

            NxPolicyStore nxBreStore = new NxPolicyStore();
            nxBreStore.ResourceManager = ResourcesCache.GetResources();
            policySet.Export(nxBreStore);

            CompiledPolicySetExtractor cpse = new CompiledPolicySetExtractor(nxBreStore.XMLRepresentation);
            List<string> channels = cpse.GetChannelNames();

            foreach (string channel in channels)
            {
                string objects = cpse.GetObjects(channel);
                string rules = cpse.GetRules(channel);

                ICompiledPolicySetCache cps = version.GetCompiledPolicySet(channel, target);
                if (cps == null)
                {
                    cps = version.NewCompiledPolicySet(channel, target, rules, objects);
                }
                else
                {
                    cps.Content = rules;
                    cps.ObjectReferences = objects;
                }
                    
                SaveLanguages(cpse.GetLanguages(), cps);
            }
        }
Пример #2
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'
					}
				}
			}
		}