Beispiel #1
0
		/// <summary>
		/// Returns the basic action type for a <see cref="Workshare.PolicyContent.Action"/>.ActionType.
		/// </summary>
		/// <param name="action"></param>
		/// <returns></returns>
		public static string MapActionToActionType(UIAction action)
		{
			string type = null;
			if (action == null || action.Action == null || string.IsNullOrEmpty(type = action.Action.Type))
			{
				return string.Empty;
			}
			return MapActionToActionType(type.ToLowerInvariant());
		}
Beispiel #2
0
		public static void MapActionToTitleDescIcon(UIAction action, string type, out string tabPageName, out string title, out string description)
		{
			if (string.IsNullOrEmpty(type))
			{
				type = Dialogs.Utilities.MapActionToActionType(action);
			}
			switch (type)
			{
			case "BLOCK":
				title = "Block Options";
				tabPageName = string.Empty;
				description = string.Empty;
				return;
			case "ALERT":
				title = "Alert Options";
				tabPageName = string.Empty;
				description = string.Empty;
				return;
			case "CLEAN":
				title = Properties.Resources.HIDDEN_DATA_OPTIONS_TITLE;
				tabPageName = type;
				description = Properties.Resources.HIDDEN_DATA_OPTIONS_TEXT;
				return;
			case "PDFCLEAN":
				title = Properties.Resources.HIDDEN_PDFDATA_OPTIONS_TITLE;
				tabPageName = type;
				description = Properties.Resources.HIDDEN_PDFDATA_OPTIONS_TEXT;
				return;
			case "PDF":
				title = Properties.Resources.PDF_OPTIONS_TITLE;
				tabPageName = type;
				description = Properties.Resources.PDF_OPTIONS_TEXT;
				return;
			case "ZIP":
				title = Properties.Resources.ZIP_OPTIONS_TITLE;
				tabPageName = type;
				description = Properties.Resources.ZIP_OPTIONS_TEXT;
				return;
			case "RMS":
				title = "RMS Options";
				tabPageName = type;
				description = action.Description;
				return;
			case "PGP":
				title = "PGP Options";
				tabPageName = type;
				description = action.Description;
				return;
			case "RPOST":
				title = "RPost Options";
				tabPageName = type;
				description = action.Description;
				return;
			case "UTIMACO":
				title = "Utimaco Options";
				tabPageName = type;
				description = action.Description;
				return;
			case "CRYPTZONE":
				title = "Secure Email Options";
				tabPageName = type;
				description = action.Description;
				return;
			case "SENDLINK":
			case "SKYDOXSENDLINK":
				title = "Secure File Transfer (SFT)";
				tabPageName = type;
				description = action.Description;
				return;
			default:
				title = action.Action.Name;
				tabPageName = type;
				description = action.Description;
				return;
			}
		}
        /// <summary>
		/// For each of the given UIContentItem and its children, adds a SummaryContentControl row
		/// to the list, or updates the row to Completed state if it's already there
        /// </summary>
        /// <param name="action"></param>
        /// <param name="parent"></param>
		private void IterateContentItems(UIAction action, UIContentItem item)
        {
			if (item.ContainsPolicyViolation())
			{
				SummaryContentControl control = m_summaryContentControlList.Find(c => c.ContentId == item.Id);
				if (control == null && item.ContentType == ContentTypeEnum.Email.ToString())
				{
					// This could be the item for the email subject/body itself (not an attachment).
					// Look for a placeholder item added earlier (when we didn't have the Id available).
					control = m_summaryContentControlList.Find(c => c.TitleText == item.Name);
				}
				if (control == null)
				{
					// The control wasn't created before scanning: add it now
					control = AddNewContentControl(item.Id, item.DisplayName, item.ContentType, true);
				}

				// Either the control was just created, or it was a placeholder
				// created during dynamic-discovery scanning.
				// Make sure it has the outcome of the scan for each action type
				string actionType = Dialogs.Utilities.MapActionToActionType(action);
				if (!control.ContentItems.ContainsKey(actionType))
				{
					control.ContentItems.Add(actionType, item);
				}

				string parentActionType = Dialogs.Utilities.MapActionToActionType(item.Action);
				if (!control.ContentItems.ContainsKey(parentActionType))
				{
					control.ContentItems.Add(parentActionType, item);
				}

				bool execute = true;
				{
					IActionProperty actionProperty;
					item.ActionPropertySet.TryGetValue(PropertyNames.Execute, out actionProperty);
					ActionPropertyFacade executeProperty = actionProperty as ActionPropertyFacade;
					if (executeProperty != null)
					{
						execute = Convert.ToBoolean(executeProperty.Value, CultureInfo.InvariantCulture);
					}
				}

				foreach (UIPolicy policy in item.Policies.Values)
				{
					if (!policy.Triggered)
					{
						continue;
					}
					control.AddPolicy(policy.Name);
					control.AddRisk(policy.HighestRating);
					control.AddAction(actionType, execute);

					if (!control.SelectionContexts.ContainsKey(actionType))
					{
						control.SelectionContexts.Add(actionType, true);
					}
					control.ScanCompleted = true;
				}
			}

			foreach (UIContentItem child in item.ChildContentItems.Values)
            {
				IterateContentItems(action, child);
            }
        }
		private void IterateContentItems(UIAction action, UIContentItem parent)
		{

			switch (Dialogs.Utilities.MapActionToActionType(action))
			{
			case "CLEAN":
				RemoveCommentsEnabled = true;
				RemoveTrackChangesEnabled = true;
				SkipOfficeCleaningEnabled = true;
				break;
			case "PDFCLEAN":
				SkipPdfCleaningEnabled = true;
				break;
			case "PDF":
				PDFOptionsEnabled = true;
				break;
			}

			foreach (UIPolicy policy in parent.Policies.Values)
			{
				if (!policy.Triggered)
				{
					continue;
				}
				if (!policy.Actions.Exists(item => item.Name == action.Name))
				{
					continue;
				}
				SortedList<string, List<UICondition>> conditions;
				m_triggeredPolicies.TryGetValue(parent.Id, out conditions);
				if (conditions == null)
				{
					conditions = new SortedList<string, List<UICondition>>();
					m_triggeredPolicies[parent.Id] = conditions;
				}
				if (conditions.ContainsKey(policy.Name))
				{
					continue;
				}

				List<UICondition> expressions = new List<UICondition>();
				foreach (UICondition condition in policy.Conditions.Values)
				{
					UIExpression expression = condition as UIExpression;
					if (expression != null)
					{
						expressions.Add(expression);
					}
				}
				conditions[policy.Name] = expressions;

				if (m_totalRiskRating < policy.HighestRating)
				{
					m_totalRiskRating = policy.HighestRating;
				}
			}

			foreach (UIContentItem contentItem in parent.ChildContentItems.Values)
			{
				IterateContentItems(action, contentItem);
			}
		}
Beispiel #5
0
		/// <summary>
		/// Prepares a <see cref="Workshare.Policy.ClientManager.ObjectModel.UIResponse"/> object based on the supplied <see cref="Response"/>
		/// </summary>
		/// <param name="request">A <see cref="Workshare.PolicyContent.Request"/> the request that the content scanner recieved when it generate the response</param>
		/// <param name="response">A <see cref="Workshare.PolicyContent.Response"/> object to parse</param>
		/// <returns>A fully populated <see cref="Workshare.Policy.ClientManager.ObjectModel.UIResponse"/> object</returns>
		public static UIResponse UIResponseFromResponse(Request request, Response response)
		{
			if (response == null)
			{
				throw new ArgumentNullException("response");
			}

			UIResponse uiResponse = new UIResponse(request, response);
			uiResponse.Initialize();

			ResolvedAction[] resolvedActions = response.ResolvedActions ?? new ResolvedAction[0];

			#region The loops
			foreach (ResolvedAction resolvedAction in resolvedActions)
			{
				foreach (ContentItem contentItem in resolvedAction.Contents)
				{
					foreach (PolicySet policySet in contentItem.PolicySets)
					{
						foreach (Workshare.PolicyContent.Policy policy in policySet.Policies)
						{
							if (!policy.Triggered)
								continue;
							foreach (Workshare.PolicyContent.Action action in policy.Actions)
							{
								#region Is Action valid
								if (action.Type != resolvedAction.Action.Type)
								{
									continue;
								}
								if (!Array.Exists(action.Properties, c => c.Name == "ExceptionAction"))
								{
									continue;
								}
								#endregion

								#region Create UIAction
								UIAction uiAction;
								uiResponse.Actions.TryGetValue(action.Type, out uiAction);
								if (uiAction == null)
								{
									uiAction = new UIAction(resolvedAction);
									uiResponse.Actions[action.Type] = uiAction;
								}
								#endregion

								#region Create UIContent & add to UIAction
								// First try and find the parent.
								UIContentItem uiParentContentItem = HandleParentContentItems(response, uiAction, action, contentItem);
								UIContentItem uiContentItem = null;
								if (uiParentContentItem == null)
								{
									uiContentItem = uiAction.GetContentItemById(contentItem.Id);
									if (uiContentItem == null)
									{
										uiContentItem = new UIContentItem(contentItem, action);
									}
									uiAction.ContentItems[uiContentItem.Name] = uiContentItem;
								}
								else
								{
									uiContentItem = UIContentItem.GetContentItemById(uiParentContentItem, contentItem.Id);
									if (uiContentItem == null)
									{
										uiContentItem = new UIContentItem(contentItem, action);
									}
									uiParentContentItem.ChildContentItems[uiContentItem.Id] = uiContentItem;
								}
								uiContentItem.Container = false;
								
								#endregion

								#region Create UIPolicy & add to UIContentItem
								UIPolicy uiPolicy;
								uiContentItem.Policies.TryGetValue(policy.Name, out uiPolicy);
								if (uiPolicy == null)
								{
									uiPolicy = new UIPolicy(policySet, policy);
									uiContentItem.Policies[policy.Name] = uiPolicy;
								}

								uiPolicy.Actions.Add(uiAction);
								#endregion

								#region Is this UIAction a blocking action?
								if (uiAction.IsBlockingAction() && !uiResponse.BlockingActions.Contains(uiAction))
								{
									uiResponse.BlockingActions.Add(uiAction);
								}
								#endregion
							}
						
						}
					}
				}
			}
			#endregion

			try
			{
				// The initialization will call Initialize on all contained objects.
				uiResponse.Initialize();
			}
			catch 
			{
				uiResponse = null;
			}

			return uiResponse;
		}
Beispiel #6
0
		/// <summary>|
		/// We need this to handle the recursive parenting.
		/// </summary>
		/// <param name="response">The <see cref="Workshare.PolicyContent.Response"/></param>
		/// <param name="uiAction">The <see cref="UIAction"/> object for the content item</param>
		/// <param name="action">The <see cref="Workshare.PolicyContent.Action"/> object for the content item</param>
		/// <param name="contentItem"></param>
		/// <returns></returns>
		private static UIContentItem HandleParentContentItems(Response response, UIAction uiAction, PolicyContent.Action action, ContentItem contentItem)
		{
			UIContentItem parent = uiAction.GetContentItemById(contentItem.ParentId);
			if (parent == null)
			{
				CustomProperty parentIndex = Array.Find(contentItem.Properties, p => p.Name == "ParentIndex");
				int index = (parentIndex == null ? -1 : Int32.Parse(parentIndex.Value));
				if (index > -1)
				{
					parent = new UIContentItem(response.Contents[index], action, true);
				}
				if (parent != null)
				{
					if (parent.ParentId == null)
					{
						uiAction.ContentItems[parent.Id] = parent;
					}
					else
					{
						UIContentItem grandparent = HandleParentContentItems(response, uiAction, action, parent.ContentItem);
						grandparent.ChildContentItems[parent.Id] = parent;
					}
				}
			}
			return parent;
		}
		protected void HandleContentItems(UIAction action, UIContentItem parent)
		{
			bool allowExecuteOverride = parent.AllowOverride(PropertyNames.Execute);
			
			bool isContainerContentItem = parent.IsContainerContentItem();

			MockContenItemControl ctrl = m_transparent ? new MockTransparentContentItemControl(parent) : 
				new MockContenItemControl(parent);
			ctrl.ApplyToAll += new ApplyToAllDelegate(action.HandleApplyToAll);
			m_controls.Add(ctrl);
		   
			foreach (UIContentItem child in parent.ChildContentItems.Values)
			{
				HandleContentItems(action, child);
			}
		}