private static void processPolicyResponse(PolicyResponse policyResponse)
        {
            List<IExpressionResponse> expressionResponses = getRiskElements(policyResponse);

            _riskElements.OnPolicyBegin(policyResponse.Name);

			try
			{
				foreach (IExpressionResponse expresionResponse in expressionResponses)
				{
					string responseRisk = expresionResponse.Rating;
					string responseName = expresionResponse.Name;

					Dictionary<string, List<string>> expressionDetails =
						groupExpressionDetails(expresionResponse.ExpressionDetailCollection);

					if (expressionDetails.Count > 0)
					{
						foreach (string key in expressionDetails.Keys)
						{
							_riskElements.CheckRatingElement(responseRisk, key);

							List<string> details = expressionDetails[key];

                            if (details!= null && "ConditionSummary" == details.FirstOrDefault() && (responseName == "Cleans Microsoft Office documents of hidden data."))// || responseName == "Converts Microsoft Office document to PDF."))
						        continue;

							if (!_riskElements.SerializeDetails(key, details))
							{
								_riskElements.SerializeDISRule(
									responseName,
									responseRisk,
									key,
									details
									);
							}
						}
					}
				}

				_riskElements.OnPolicyEnd();
			}
			catch (System.Xml.XmlException ex)
			{
				/*
				 * This try/catch is used to catch the exception thrown from function: OnSerializeDISRulesContent(string obj).
				 * We store the Policy Name so that we can show it in the message box in:
				 * File: ProtectDialog.cs, Function: riskReportButton_Click(object sender, EventArgs e). 
				 */
				ex.Data["PolicyName"] = policyResponse.Name;
				throw ex;
			}
        }
		public void TestSkipVerified_GetPolicy()
		{
			PolicyResponse pr = new PolicyResponse();

			pr.SkipVerifiedMessages = true;

			Workshare.PolicyContent.Policy p = PolicyAdaptor.GetPolicy(pr);

			Assert.IsTrue(Array.Exists<CustomProperty>(p.Properties, delegate(CustomProperty cp)
			{
				return (PolicyConstants.SkipVerifiedMessages == cp.Name && bool.TrueString == cp.Value);
			}), "Expect to find a property with the specified name and value when SkipVerifiedMessages = true");
		}
 public void ReadXml(XmlReader reader)
 {
     if (reader.NodeType != XmlNodeType.Element)
         return;
     int iExpectedPolicyCount = Int32.Parse(reader.GetAttribute("NumPolicies"), CultureInfo.InvariantCulture);
     bool bIsMT = reader.IsEmptyElement;
     reader.ReadStartElement("PolicySetResponse");
     if (m_Policies == null)
         m_Policies = new Collection<IPolicyResponse>();
     else
         iExpectedPolicyCount += m_Policies.Count;
     while (reader.IsStartElement("PolicyResponse"))
     {
         PolicyResponse aPolicy = new PolicyResponse();
         aPolicy.ReadXml(reader);
         m_Policies.Add(aPolicy);
     }
     if (!bIsMT)
         reader.ReadEndElement();
     if (m_Policies.Count != iExpectedPolicyCount)
         throw new PolicyEngineException("Inconsistent XML");
 }
Beispiel #4
0
		internal static IPolicyResponse GetIPolicyResponse(Workshare.PolicyContent.Policy policyIn)
		{
			if (null == policyIn)
				throw new ArgumentException("policy");
			

			PolicyResponse policyOut = new PolicyResponse();

			policyOut.Audit = policyIn.Audit;
			policyOut.Description = policyIn.Description;
			policyOut.Name = policyIn.Name;
			policyOut.Triggered = policyIn.Triggered;
			policyOut.RoutingId = null;  //TODO: Include RoutingId. How/Why!
			policyOut.Routing = RoutingAdaptor.GetIRoutingResponse(policyIn.Routing);
			
			if ( policyIn.Properties != null)
			{
				foreach (CustomProperty property in policyIn.Properties)
				{
					switch (property.Name)
					{
						case PolicyAdaptor.ExecuteBlockProp:
							policyOut.BlockOnException = bool.TrueString == property.Value;
							break;

						case PolicyConstants.SkipVerifiedMessages:
							policyOut.SkipVerifiedMessages = bool.TrueString == property.Value;
							break;

						default:
							policyOut.Properties[property.Name] = property.Value;
							break;
					}
				}
			}

			policyOut.ActionCollection = new Collection<IPolicyResponseAction>();
			if ( policyIn.Actions != null)
			{
				foreach (Workshare.PolicyContent.Action action in policyIn.Actions)
				{
					policyOut.ActionCollection.Add( ActionAdaptor.GetIPolicyResponseAction(action) );
				}
			}

			policyOut.ExpressionCollection = new Collection<IExpressionResponse>();
			if ( policyIn.Expressions != null)
			{
				foreach (Expression expression in policyIn.Expressions)
				{
					policyOut.ExpressionCollection.Add(ExpressionAdaptor.GetIExpressionResponse(expression));
				}
			}

			return policyOut;
		}
		private object BeforeRuleHandler(IBRERuleContext aBrc, Hashtable aMap, object aStep)
		{
			if (m_CurrentFileInfo.PolicySetCollection == null || m_CurrentFileInfo.PolicySetCollection.Count == 0)
				throw new PolicyEngineException("Unable to audit policy information as no policy information has been audited");

			PolicyResponse policy = new PolicyResponse();

			policy.Name = GetName(aMap);

			if (aMap.ContainsKey("AuditLevel"))
				policy.Audit = (aMap["AuditLevel"] as string) != "None";
			else
				policy.Audit = true;

			if (aMap.ContainsKey("blockOnException"))
				policy.BlockOnException = Convert.ToBoolean(aMap["blockOnException"], CultureInfo.InvariantCulture);
			else
				policy.BlockOnException = true;

			if (aMap.ContainsKey(PolicyConstants.SkipVerifiedMessages))
				policy.SkipVerifiedMessages = Convert.ToBoolean(aMap[PolicyConstants.SkipVerifiedMessages], CultureInfo.InvariantCulture);
			else
				policy.SkipVerifiedMessages = false;

			if (aMap.ContainsKey("Description"))
				policy.Description = aMap["Description"] as string;

			GetLatestPolicyInfoSet().Add(policy);

			return null;
		}
		public void ProcessRouting(IContentItem file, IPolicySetResponse policySet)
		{
			PolicySetResponse policySetInfo = policySet as PolicySetResponse;
			m_CurrentFileInfo = file as ContentItem;
			foreach (PolicyResponse policyResponse in policySetInfo.PolicyReportCollection)
			{
				m_CurrentPolicyInfo = policyResponse;
				m_NxBre.Process(policyResponse.RoutingId);
			}
		}
		private bool shouldAllowPDFWithNoActions(IPolicyResponseObject upi, PolicyResponse policyResponse)
		{
			bool decision = false;

			if (upi.ContentCollection.Count > 0 && upi.ContentCollection[0].Type	== "PDFDocument")
			{
				if (policyResponse.Description == "Clean Policy."
					&& policyResponse.Name == "Hidden PDF Data Policy")
				{
					for (int i = 0; i < policyResponse.ExpressionCollection.Count; i++)
					{
						// policyResponse.ExpressionCollection[0].Name == "Cleans PDF documents of hidden data."
						if (policyResponse.ExpressionCollection[i].ExpressionDetailCollection.Count > 0)
						{
							decision = true;
							break;
						}
					}
				}
			}
			return decision;
		}
Beispiel #8
0
        private List<IExpressionResponse> GetRiskElements(PolicyResponse policyResponse, string rating)
        {
            List<IExpressionResponse> expressionDetails = new List<IExpressionResponse>();

            Collection<IExpressionResponse> expressions = policyResponse.ExpressionCollection;
            foreach (IExpressionResponse expresionResponse in expressions)
            {
                if (string.Compare(expresionResponse.Rating, rating, true) == 0)
                {                    
                    expressionDetails.Add(expresionResponse);
                }
            }
            return expressionDetails;
        }
        private static List<IExpressionResponse> getRiskElements(PolicyResponse policyResponse)
        {
            List<IExpressionResponse> expressionDetails = new List<IExpressionResponse>();
            Collection<IExpressionResponse> expressions = policyResponse.ExpressionCollection;

            foreach(IExpressionResponse expresionResponse in expressions) {
///             if(string.Compare(expresionResponse.Rating, rating, true) == 0)
///             {
                expressionDetails.Add(expresionResponse);
///             }
            }

            return expressionDetails;
        }