// takes a uro and converts to InstantMessage Entity public static InstantMessageEntity ConvertToInstantMessageEntity(IPolicyResponseObject pro) { InstantMessageEntity instantMessageEntity = new InstantMessageEntity(); // TODO: m_InstantMessageEntity.ChannelType = Upi.UniversalRequestObject.ChannelType; //instantMessageEntity.ChannelType = pro.ChannelType.ToString(); // string RecipientIPAddress; if (pro.Properties.ContainsKey(IPPropertyKeys.DestinationIP)) instantMessageEntity.DestinationIP = pro.Properties[IPPropertyKeys.DestinationIP]; // string SenderIPAddress; if (pro.Properties.ContainsKey(IPPropertyKeys.OriginIP)) instantMessageEntity.OriginIP = pro.Properties[IPPropertyKeys.OriginIP]; List<DocumentEntity> documentEntities = new List<DocumentEntity>(); foreach (IContentItem fileInfo in pro.ContentCollection) { if (!ShouldAudit(fileInfo)) continue; DocumentEntity documentEntity = ConvertToDocumentEntity(fileInfo, pro); documentEntities.Add(documentEntity); } instantMessageEntity.Contents = documentEntities.ToArray(); return instantMessageEntity; }
public static void AddActionToContentCollection(IPolicyResponseObject pro, IAction3 action, bool skipRootContainer, bool triggeredPolicy) { ResolvedAction resAction = new ResolvedAction(); PolicyResponseAction pra = new PolicyResponseAction(); pra.Action = action; pra.InternalProperties = new MockActionPropertySet(); for (int index = 0; index < pro.ContentCollection.Count; ++index) { ContentItem contentItem = pro.ContentCollection[index] as ContentItem; if (null == contentItem) continue; if (skipRootContainer && (0 == index) && (contentItem.File.IsCollection)) continue; if (resAction.ContentCollection == null) resAction.ContentCollection = new Collection<IContentItem>(); resAction.ContentCollection.Add(contentItem); resAction.ResponseAction = pra; if (pro.ResolvedActionCollection == null) (pro as PolicyResponseObject).ResolvedActionCollection = new Collection<IResolvedAction>(); if(!pro.ResolvedActionCollection.Contains(resAction)) pro.ResolvedActionCollection.Add(resAction); AddActionToContentItem(contentItem, pra, triggeredPolicy); } }
/// <summary> /// This method sets the 'InternalContact' bool field to internal/external depending on email address domain name. /// </summary> /// <param name="iPro"></param> public static void SetMessageRouting(IPolicyResponseObject iPro) { PolicyResponseObject pro = iPro as PolicyResponseObject; // Should be one sender if (pro.UniversalRequestObject.Source.Items.Count == 0) { // What to do? Apart from not crashing? return; } pro.UniversalRequestObject.Source.Items[0].Properties[SMTPItemPropertyKeys.Internal] = bool.TrueString; string sender = pro.UniversalRequestObject.Source.Items[0].Content; foreach (IRoutingItem routingItem in pro.UniversalRequestObject.Destination.Items) { string recipient = routingItem.Content; if (GetInternal(sender, recipient)) { routingItem.Properties[SMTPItemPropertyKeys.Internal] = bool.TrueString; } else { routingItem.Properties[SMTPItemPropertyKeys.Internal] = bool.FalseString; } } }
public static HttpRequestEntity ConvertToHttpRequestEntity(IPolicyResponseObject pro) { HttpRequestEntity httpRequestEntity = new Workshare.BusinessObjects.Entities.HttpRequestEntity(); //httpRequestEntity.ChannelType = pro.ChannelType.ToString(); httpRequestEntity.SendDateTime = pro.ResponseDate; if (pro.Properties.ContainsKey(IPPropertyKeys.OriginPort)) httpRequestEntity.OriginPort = System.Convert.ToInt32(pro.Properties[IPPropertyKeys.OriginPort], CultureInfo.InvariantCulture); if (pro.Properties.ContainsKey(IPPropertyKeys.OriginIP)) httpRequestEntity.OriginIP = pro.Properties[IPPropertyKeys.OriginIP]; if (pro.Properties.ContainsKey(IPPropertyKeys.DestinationPort)) httpRequestEntity.DestinationPort = System.Convert.ToInt32(pro.Properties[IPPropertyKeys.DestinationPort], CultureInfo.InvariantCulture); if (pro.Properties.ContainsKey(IPPropertyKeys.DestinationIP)) httpRequestEntity.DestinationIP = pro.Properties[IPPropertyKeys.DestinationIP]; if (pro.Properties.ContainsKey(HttpRequestPropertyKeys.RequestURL)) { httpRequestEntity.RequestURL = pro.Properties[HttpRequestPropertyKeys.RequestURL]; httpRequestEntity.Description = pro.Properties[HttpRequestPropertyKeys.RequestURL]; // sic } if (pro.Properties.ContainsKey(HttpRequestPropertyKeys.RequestProtocol)) httpRequestEntity.RequestProtocol = pro.Properties[HttpRequestPropertyKeys.RequestProtocol]; if (pro.Properties.ContainsKey(HttpRequestPropertyKeys.RequestMethod)) httpRequestEntity.RequestMethod = pro.Properties[HttpRequestPropertyKeys.RequestMethod]; if (pro.Properties.ContainsKey(HttpRequestPropertyKeys.ReferrerURL)) httpRequestEntity.ReferrerURL = pro.Properties[HttpRequestPropertyKeys.ReferrerURL]; List<DocumentEntity> documentEntities = new List<DocumentEntity>(); if (pro.ContentCollection != null) { foreach (IContentItem fileInfo in pro.ContentCollection) { if (!ShouldAudit(fileInfo)) continue; DocumentEntity documentEntity = ConvertToDocumentEntity(fileInfo, pro); documentEntities.Add(documentEntity); } } httpRequestEntity.Contents = documentEntities.ToArray(); return httpRequestEntity; }
public static string ConvertToText(IPolicyResponseObject pro) { PolicyResponseObject Upi = pro as PolicyResponseObject; string sResult = ""; if (Upi.UniversalRequestObject.Properties.ContainsKey(MailMessagePropertyKeys.Subject)) sResult += "Subject = " + Upi.UniversalRequestObject.Properties[MailMessagePropertyKeys.Subject] + Environment.NewLine; sResult += "PolicyType = " + Upi.UniversalRequestObject.PolicyType + Environment.NewLine; foreach (IContentItem fileInfo in Upi.ContentCollection) { sResult += ConvertToText(fileInfo, Upi.UniversalRequestObject); sResult += "==============================================="; sResult += Environment.NewLine; } return sResult; }
public PolicyResponseObject ProcessActions(IPolicyResponseObject pro) { PolicyResponseObject upi = pro as PolicyResponseObject; if (upi == null) throw new PolicyEngineException("An invalid Policy Information Object was passed to the PolicyEngine."); ChannelType channel = PolicyTypeMappings.Lookup[upi.UniversalRequestObject.PolicyType]; m_policyEngineCache.SetPolicyEnginesCompiledPolicySetCache(upi, channel.ToString()); Dictionary<string, PolicyEngine> policyEngines = m_policyEngineCache.GetPolicyEnginesForChannel(channel.ToString()); if (policyEngines.Count == 0) return null; PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.Actions); ProcessActionInfosForContentCollection(upi, policyEngines); //ActionUtils.PopulateResolvedActionCollection(upi); PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.Actions, 0); return upi; }
public IPolicyResponseObject ProcessRoutings(IPolicyResponseObject pro) { if (!(pro is PolicyResponseObject)) throw new PolicyEngineException("An invalid Policy Information Object was passed to the PolicyEngine."); if (null == PolicyCache) throw new PolicyEngineException("The policy store has not been initialised."); RoutingProcessor routingProcessor = new RoutingProcessor(m_policyEngineCache); return routingProcessor.Process(pro as PolicyResponseObject); }
private static void RemoveActionsWithEmptyContentLists(IPolicyResponseObject pro) { //remove any resolved item if no more content items are in its list. List<IResolvedAction> actions = new List<IResolvedAction>(pro.ResolvedActionCollection); actions.RemoveAll(x => x.ContentCollection == null || x.ContentCollection.Count == 0); ((PolicyResponseObject)pro).ResolvedActionCollection = new Collection<IResolvedAction>(actions); }
/// <summary> /// This method does processing on the resolved action list in a pro. /// Actions in the resolved list are filtered out, if all policies where that action belongs /// had the property SkipVerifiedMessages = true. /// Also, the pro itself must be verified at the top level, or resolved actions should remain unaffected. /// </summary> /// <param name="pro"></param> /// <remarks> /// The purpose of this method is for policies that must 'skip messages that were already processed' by another Protect client. /// Currently the only example of this is preventing email messages sent from a machine with Protect client from being processed /// by a Protect Network mta. /// </remarks> public static void ResolveActionsForVerifiedResponses(IPolicyResponseObject pro) { if (pro == null || pro.ContentCollection == null || pro.ResolvedActionCollection == null || pro.ResolvedActionCollection.Count == 0) return; if (!pro.VerifiedOnClient) return; foreach (IContentItem ci in pro.ContentCollection) { if (ci.PolicySetCollection == null) continue; Dictionary<string, List<IPolicyResponse>> actionLookup = MapActionsToPolicies(ci); //Which actions still apply for this content item? //If an action no longer applies due to Skipverified, it doesnt survive for this content item. List<string> blacklist = new List<string>(); foreach (string type in actionLookup.Keys) { if (actionLookup[type].TrueForAll(delegate(IPolicyResponse pol) { return pol.SkipVerifiedMessages; })) { blacklist.Add(type); } } //for each resolved action, remove current content item from that list, if the resolved action is not in the survive list. foreach (IResolvedAction resolvedAction in pro.ResolvedActionCollection) { if (resolvedAction.ContentCollection == null) continue; if (blacklist.Exists(delegate(string x) { return x == resolvedAction.ResponseAction.Type; })) { RemoveContentItemFromResolvedAction(ci, resolvedAction); } } } RemoveActionsWithEmptyContentLists(pro); }
private List<_Document> getDocumentPolicies(IPolicyResponseObject upi) { foreach(Workshare.Policy.Engine.ContentItem content in upi.ContentCollection) { List<PolicyResponse> policyResponses = new List<PolicyResponse>(); foreach(PolicySetResponse set in content.PolicySetCollection) { foreach(PolicyResponse policyResponse in set.PolicyReportCollection) { // We check ActionCollection because Legacy policies all hace Active Content Channels // therefore policy will run through NXBRE and possibly be triggered. But only // legacy policies with Active Content channels that have Actions will have // policyResponse.ActionCollection.Count > 0 (JE 08.10.2010) if ((policyResponse.Triggered) && (policyResponse.ActionCollection.Count > 0 || shouldAllowPDFWithNoActions(upi, policyResponse))) { policyResponses.Add(policyResponse); } } } if(policyResponses.Count > 0) { _Document doc = new _Document(); doc.Name = content.DisplayName; doc.PolicyList = policyResponses; _DocumentList.Add(doc); } } return _DocumentList; }
private bool RemoveZipFilesInFolder(ActionData data, IPolicyResponseObject pro, bool bRemoved) { if (data.FileType == FileType.Folder) { int i = 0; while (i < data.Nested.Count) { if (!RemoveZipFilesInFolder(data.Nested[i] as ActionData, pro, bRemoved)) ++i; } } else if (data.FileType == FileType.ZIP) { foreach (ResolvedAction resAction in pro.ResolvedActionCollection) { foreach (ContentItem ci in resAction.ContentCollection) { if (ContainedinPRO(data.Properties["FileName"], ci.File as File)) { if (!bRemoved) return false; if (data.Parent.Nested.Count > 0) { data.Parent.Nested.Remove(data); return true; } } } } if (!bRemoved && data.Parent.Nested.Count > 0) { data.Parent.Nested.Remove(data); return true; } } return false; }
// takes a pro and converts to ActiveContentAlert Entity public static ActiveContentAlertEntity2 ConvertToActiveContentAlertEntity(IPolicyResponseObject pro) { ActiveContentAlertEntity2 activeContentAlertEntity = new ActiveContentAlertEntity2(); //activeContentAlertEntity.ChannelType = pro.ChannelType.ToString(); activeContentAlertEntity.SendDateTime = pro.ResponseDate; if (pro.Properties.ContainsKey(Workshare.Policy.Interfaces.ActiveContentPropertyKeys.UserName)) activeContentAlertEntity.UserName = pro.Properties[Workshare.Policy.Interfaces.ActiveContentPropertyKeys.UserName]; if (pro.Properties.ContainsKey(Workshare.Policy.Interfaces.ActiveContentPropertyKeys.MachineName)) activeContentAlertEntity.MachineLocator = pro.Properties[Workshare.Policy.Interfaces.ActiveContentPropertyKeys.MachineName]; if (pro.Properties.ContainsKey(Workshare.Policy.Interfaces.ActiveContentPropertyKeys.Application)) activeContentAlertEntity.Application = pro.Properties[Workshare.Policy.Interfaces.ActiveContentPropertyKeys.Application]; if (pro.ContentCollection != null) { if (pro.ContentCollection.Count > 0) activeContentAlertEntity.SourceFileName = pro.ContentCollection[0].Name; } List<DocumentEntity> documentEntities = new List<DocumentEntity>(); foreach (IContentItem fileInfo in pro.ContentCollection) { if (!ShouldAudit(fileInfo)) continue; DocumentEntity documentEntity = ConvertToDocumentEntity(fileInfo, pro); documentEntities.Add(documentEntity); } activeContentAlertEntity.Document = documentEntities[0]; return activeContentAlertEntity; }
public static MailMessageEntity ConvertToMailMessageEntity(IPolicyResponseObject pro) { MailMessageEntity m_MailMessageEntity = new MailMessageEntity(); if ((pro != null) && (pro.RoutingInformation != null)) { //m_MailMessageEntity.ChannelType = pro.ChannelType.ToString(); m_MailMessageEntity.ContentType = pro.ChannelDetail; List<ContactEntity> recipientsTo = new List<ContactEntity>(); List<ContactEntity> recipientsBCC = new List<ContactEntity>(); List<ContactEntity> recipientsCC = new List<ContactEntity>(); IUniversalRoutingEntity source = GetRoutingEntity(pro, RoutingTypes.Source.ToString()); if (source != null) { if (source.Items.Count == 1 && source.Items[0].Properties[SMTPItemPropertyKeys.AddressType] == AddressType.From) m_MailMessageEntity.SenderContact = ExtractContact(source.Items[0]); } IUniversalRoutingEntity destination = GetRoutingEntity(pro, RoutingTypes.Destination.ToString()); if (destination != null) { foreach (IRoutingItem item in destination.Items) { if (item.Properties[SMTPItemPropertyKeys.AddressType] == AddressType.To) recipientsTo.Add(ExtractContact(item)); if (item.Properties[SMTPItemPropertyKeys.AddressType] == AddressType.BCC) recipientsBCC.Add(ExtractContact(item)); if (item.Properties[SMTPItemPropertyKeys.AddressType] == AddressType.CC) recipientsCC.Add(ExtractContact(item)); } m_MailMessageEntity.RecipientsTo = recipientsTo.ToArray(); m_MailMessageEntity.RecipientsBCC = recipientsBCC.ToArray(); m_MailMessageEntity.RecipientsCC = recipientsCC.ToArray(); } m_MailMessageEntity.SendDateTime = pro.ResponseDate; } List<DocumentEntity> documentEntities = new List<DocumentEntity>(); if ((pro != null) && (pro.ContentCollection != null)) { foreach (IContentItem contentItem in pro.ContentCollection) { DocumentEntity documentEntity = ProEntityConverter.ConvertToDocumentEntity(contentItem, pro); documentEntities.Add(documentEntity); if (contentItem.Type == "Email") { if (contentItem.Properties.ContainsKey("Subject")) m_MailMessageEntity.Subject = contentItem.Properties["Subject"]; } } } m_MailMessageEntity.Attachments = documentEntities.ToArray(); return m_MailMessageEntity; }
private static IUniversalRoutingEntity GetRoutingEntity(IPolicyResponseObject pro, string type) { if (pro.RoutingInformation == null) return null; IUniversalRoutingEntity entity = pro.RoutingInformation[0]; if (entity.RoutingType == type) return entity; if (pro.RoutingInformation.Count == 2) { entity = pro.RoutingInformation[1]; if (entity.RoutingType == type) return entity; } return null; }
public static Response GetResponse( IPolicyResponseObject pro) { if (null == pro) throw new ArgumentNullException("pro"); Response response = new Response(); response.PolicyType = pro.PolicyType.ToString(); response.ResponseDate = pro.ResponseDate; int index = 0; if (pro.ContentCollection != null && pro.ContentCollection.Count > 0) { response.Contents = new Workshare.PolicyContent.ContentItem[pro.ContentCollection.Count]; bool useFiles = false; foreach (IContentItem ici in pro.ContentCollection) { if (ici.Properties.ContainsKey(ContentItemAdaptor.ContentDataSourceKey)) { useFiles = true; break; } } foreach (IContentItem proContentItem in pro.ContentCollection) { if (!proContentItem.Properties.ContainsKey(ContentItemAdaptor.ContentDataSourceKey) && useFiles) { proContentItem.Properties[ContentItemAdaptor.ContentDataSourceKey] = string.Empty; } Workshare.PolicyContent.ContentItem contentItem = ContentItemAdaptor.GetContentItem(proContentItem); response.Contents[index++] = contentItem; } } List<CustomProperty> properties = new List<CustomProperty>(); if (pro.Properties != null) { foreach (string key in pro.Properties.Keys) { properties.Add(new CustomProperty(key, pro.Properties[key])); } } properties.Add(new CustomProperty(PolicyConstants.ClientVerified, pro.VerifiedOnClient.ToString())); response.Properties = properties.ToArray(); if (pro.ResolvedActionCollection != null && pro.ResolvedActionCollection.Count > 0) { index = 0; response.ResolvedActions = new Workshare.PolicyContent.ResolvedAction[pro.ResolvedActionCollection.Count]; foreach (IResolvedAction ra in pro.ResolvedActionCollection) { response.ResolvedActions[index++] = ResolvedActionAdaptor.GetResolvedAction(ra); } } if (pro.RoutingInformation != null && pro.RoutingInformation.Count > 0) { index = 0; response.Routing = new RoutingEntity[pro.RoutingInformation.Count]; foreach(IUniversalRoutingEntity ure in pro.RoutingInformation) { response.Routing[index++] = RoutingEntityAdaptor.GetRoutingEntity(ure); } } return response; }
public IUniversalRequestObject ExecuteActions(IPolicyResponseObject upi) { ActionExecuter executer = new ActionExecuter(m_progressCallback); return executer.ExecuteActions(upi, ref m_container); }
internal static DocumentEntity ConvertToDocumentEntity(IContentItem fileInfo, IPolicyResponseObject uro) { if (fileInfo == null) return null; DocumentEntity documentEntity = new DocumentEntity(); List<PolicySetEventEntity> policyEvents = new List<PolicySetEventEntity>(); // Can't actually do much populating if this is null documentEntity.ContentType = fileInfo.Type; documentEntity.Name = fileInfo.Name; InitialiseFileEntityMetadata(documentEntity, fileInfo); if (fileInfo.PolicySetCollection != null) { foreach (IPolicySetResponse policySetInfo in fileInfo.PolicySetCollection) { PolicySetEventEntity PolicySet = new PolicySetEventEntity(); PolicySet.EventDate = policySetInfo.Date; PolicySet.PolicySetName = policySetInfo.Name; List<PolicyEntity> PolicyEntities = new List<PolicyEntity>(); if (policySetInfo.PolicyReportCollection != null) { foreach (IPolicyResponse policyInfo in policySetInfo.PolicyReportCollection) { if (!ProEntityConverter.ShouldAudit(policyInfo)) continue; PolicyEntity PolicyEntity = new PolicyEntity(); PolicyEntity.PolicyName = policyInfo.Name; PolicyEntity.Triggered = policyInfo.Triggered; List<ExpressionEntity> expressionList = new List<ExpressionEntity>(); if (policyInfo.ExpressionCollection != null) { foreach (IExpressionResponse expressionInfo in policyInfo.ExpressionCollection) { if (!expressionInfo.Triggered) continue; ExpressionEntity expression = new ExpressionEntity(); expression.ExpressionName = expressionInfo.Name; expression.ExpressionRating = expressionInfo.Rating; expression.ExpressionType = "CONDITION"; expression.ExpressionTriggered = expressionInfo.Triggered; // IMPORTANT!! these not put to the audit trail as is storing personal info. bad. List<ExpressionPropertyEntity> expressionProperty = new List<ExpressionPropertyEntity>(); expression.ExpressionProperties = expressionProperty.ToArray(); expressionList.Add(expression); } } if (policyInfo.Routing != null) { ExpressionEntity routing = new ExpressionEntity(); routing.ExpressionName = policyInfo.Routing.Name; routing.ExpressionRating = policyInfo.Routing.Rating; routing.ExpressionType = "ROUTING"; routing.ExpressionTriggered = true; // IMPORTANT!! these not put to the audit trail as is storing personal info. bad. List<ExpressionPropertyEntity> expressionProperty = new List<ExpressionPropertyEntity>(); routing.ExpressionProperties = expressionProperty.ToArray(); expressionList.Add(routing); } PolicyEntity.Expressions = expressionList.ToArray(); List<PolicyPropertyEntity> policyPropList = new List<PolicyPropertyEntity>(); if (policyInfo.Properties != null) { foreach (KeyValuePair<string, string> de in policyInfo.Properties) { PolicyPropertyEntity prop = new PolicyPropertyEntity(); prop.Name = de.Key; prop.PropertyValue = de.Value; policyPropList.Add(prop); } } PolicyEntity.PolicyProperties = policyPropList.ToArray(); List<ActionEntity> acList = new List<ActionEntity>(); if (policyInfo.ActionCollection != null) { foreach (IPolicyResponseAction actionInfo in policyInfo.ActionCollection) { ActionEntity ae = ConvertActionEntity(actionInfo); if (ae != null) acList.Add(ae); } } PolicyEntity.Actions = acList.ToArray(); PolicyEntities.Add(PolicyEntity); } } PolicySet.Policies = PolicyEntities.ToArray(); policyEvents.Add(PolicySet); } } documentEntity.DocumentEvents = policyEvents.ToArray(); return documentEntity; }
public IPolicyResponseObject ProcessActions(IPolicyResponseObject pro) { ActionProcessor processor = new ActionProcessor(m_PolicyCache, m_policyEngineCache); m_Pro = processor.ProcessActions(pro); if (m_Pro != null) ActionUtils.PopulateResolvedActionCollection(m_Pro); return m_Pro; }
public static bool ShouldAudit(IPolicyResponseObject pro) { foreach (IContentItem fileInfo in pro.ContentCollection) { if (ShouldAudit(fileInfo)) return true; } return false; }
/// <summary> /// Executes actions specified in the PolicyResponseObject. Supports both file and folder based /// actions. /// </summary> /// <param name="pro">PolicyResponseObject with ResolvedActions and ContentItems</param> /// <param name="container">ContentItems in a hierarchy structure</param> /// <returns></returns> public IUniversalRequestObject ExecuteActions(IPolicyResponseObject pro, ref IContainer container) { MimeEngine mimeEngine = new MimeEngine(); mimeEngine.ProgressCallback = _progressCallback; PolicyResponseObject realPro = pro as PolicyResponseObject; if (realPro == null) throw new PolicyEngineException("Invalid policy response object passed to the ActionExecuter"); // for now just do this fudge - cull this at earliest opportunity Laku 25/07/07 // the handling of the block and alert actions should be within the action processor if (ContainsBlockAction(realPro.ResolvedActionCollection)) { container.Files.Clear(); return CreateOutputUro(realPro, container); } #region process resolved actions // builds the master list of items into a hierarchy ActionData masterData = new ActionData(container, GetReadableContent); List<Guid> collections = new List<Guid>(); PolicyResponseAction pra = null; ActionData workingSet = null; try { foreach (ResolvedAction resAction in pro.ResolvedActionCollection) { if (resAction.ContentCollection.Count <= 0) continue; pra = resAction.ResponseAction as PolicyResponseAction; if (pra.IsExceptionAction) { mimeEngine.ExceptionAction = pra; continue; } if (pra.Action.Capabilities.SupportsMime && !mimeEngine.Actions.ContainsKey(resAction)) { mimeEngine.Actions[resAction] = GetActionOfTypeFromContentItem(realPro, resAction.ContentCollection[0], resAction.ResponseAction.Type).InternalProperties as ActionPropertySet; if (masterData.FileType == FileType.Email) continue; } collections.Clear(); ActionData.GetAllCollectionId(masterData, collections); workingSet = new ActionData(masterData, new Predicate<ActionData>(delegate(ActionData item) { string supportedFileType = FileTypeToSupportedFileTypeString(item.FileType); if (item.FileType == FileType.Folder || item.FileType == FileType.Selection) return true; if (!pra.Action.SupportedFileCollection.Supports(supportedFileType)) return false; if (item.Underworld != null && item.Underworld.Parent != null) { IFile parent = item.Underworld.Parent as IFile; if (parent != null && parent.FileType == FileType.ZIP)// && !pra.Action.SupportedFileCollection.Supports(".zip")) if (Array.IndexOf(pra.Action.SupportedFileCollection.UnsupportedFiles(), ".zip") >= 0) return false; } foreach (ContentItem ci in resAction.ContentCollection) { if (ci.File.UniqueIdentifier == item.Underworld.UniqueIdentifier && pra.Action.SupportedFileCollection.Supports(supportedFileType)) { return true; } } return false; }), GetReadableContent); if (ActionUtils.DoesActionSupportFolders((resAction.ResponseAction as PolicyResponseAction).Action)) { //magic IActionProperty prop = null; ActionData firstLevelData = workingSet.Nested[0] as ActionData; if (workingSet.Nested.Count > 0) pra = FindContentAction(realPro, firstLevelData, resAction, true); bool bZipAllFolder = false; if (pra.InternalProperties.SystemProperties.TryGetValue("FileType", out prop)) { if (workingSet.FileType == FileType.Email) prop.Value = ".email"; else { prop.Value = ".fld"; IActionProperty zipAttr = null; if (pra.InternalProperties.TryGetValue("ZIPAttachedFiles", out zipAttr) && (bool) zipAttr.Value) { bZipAllFolder = true; if (workingSet.Nested.Count > 0) RemoveZipFilesInFolder(workingSet.Nested[0] as ActionData, pro, false); } } } ExecuteAction(pra, workingSet); if (masterData.Nested.Count > 0 && bZipAllFolder) { RemoveZipFilesInFolder(masterData.Nested[0] as ActionData, pro, true); } } else { foreach (ActionData item in workingSet.GetAllLeafs()) { PolicyResponseAction actionToExecute = FindContentAction(realPro, item, resAction, false); ExecuteAction(actionToExecute, item); } } ActionData.Merge(masterData, workingSet, true); ActionData.PruneEmptyCollections(masterData, collections); pra.Executed = true; } } catch (AbortActionException abortThis) { // handle abort scenario PolicyActionException somethingWrong = new PolicyActionException(string.Format(CultureInfo.InvariantCulture, "Operation was aborted by action {0}", pra.Type), abortThis); somethingWrong.ExceptionHandling = ActionExceptionHandling.Abort; throw somethingWrong; } catch (Exception e) { throw CreateActionException(pra.Type, realPro, e, false); } #endregion if (masterData.Nested.Count != 0) container = ContentToPackedContainer(masterData); else container.Files.Clear(); // Synchronise the URO with the changes to the attachments IUniversalRequestObject outputUro = CreateOutputUro(realPro, container); try { // The MIME actions will modify the URO directly mimeEngine.ExecuteActions(outputUro); UniversalResponseObjectHelper.CopyProperties(outputUro, realPro.UniversalRequestObject); UniversalResponseObjectHelper.CopyRouting(outputUro, realPro.UniversalRequestObject); } catch (AbortActionException abortThis) { // handle abort scenario PolicyActionException somethingWrong = new PolicyActionException(string.Format(CultureInfo.InvariantCulture, "Operation was aborted by action {0}", pra.Type), abortThis); somethingWrong.ExceptionHandling = ActionExceptionHandling.Abort; throw somethingWrong; } catch (Exception e) { throw CreateActionException(pra.Type, realPro, e, true); } return outputUro; }
/// ----------------------------------------------------------------------------- /// private void internalInitialize(IPolicyResponseObject pro) { if(pro != null) { List<_Document> documentList = getDocumentPolicies(pro); processDocumentList(documentList); } }
private static bool UpdateIncidentProperties(IPolicyResponseObject response) { bool bIncidentRaised = false; if (response.ContentCollection == null) return false; foreach (IContentItem contentItem in response.ContentCollection) { foreach (IPolicySetResponse policySet in contentItem.PolicySetCollection) { foreach (IPolicyResponse policy in policySet.PolicyReportCollection) { if ((policy.Routing != null) && (policy.Routing.Properties != null)) { Dictionary<string, string> WorkflowProps = new Dictionary<string, string>(policy.Properties); Dictionary<string, string> NonWorkflowProps = new Dictionary<string, string>(policy.Properties); WorkflowProps[IncidentPropertyKeys.CloseIncident] = bool.TrueString; foreach (KeyValuePair<string, string> property in policy.Routing.Properties) { if (property.Key == "RaiseIncidentWorklist" && !string.IsNullOrEmpty(property.Value)) { bIncidentRaised = true; WorkflowProps[IncidentPropertyKeys.Incident] = bool.TrueString; WorkflowProps[IncidentPropertyKeys.Worklist] = property.Value; } else { if (property.Key == "CloseIncident" && !string.IsNullOrEmpty(property.Value)) WorkflowProps[IncidentPropertyKeys.CloseIncident] = property.Value; else NonWorkflowProps[property.Key] = property.Value; } } policy.Properties.Clear(); foreach (KeyValuePair<string, string> kvp in WorkflowProps) policy.Properties.Add(kvp.Key, kvp.Value); policy.Routing.Properties.Clear(); foreach (KeyValuePair<string, string> kvp in NonWorkflowProps) policy.Routing.Properties.Add(kvp.Key, kvp.Value); } } } } return bIncidentRaised; }
public static RemovableStorageEntity ConvertToRemovableTransferEntity(IPolicyResponseObject pro) { RemovableStorageEntity removableStorageEntity = new RemovableStorageEntity(); removableStorageEntity.InspectionDateTime = pro.ResponseDate; removableStorageEntity.MachineLocator = System.Environment.MachineName; if (pro.RoutingInformation.Count > 0) { IUniversalRoutingEntity sourceRouting = GetRoutingEntity(pro, RoutingTypes.Source); IUniversalRoutingEntity destinationRouting = GetRoutingEntity(pro, RoutingTypes.Destination); if (sourceRouting != null) { if (sourceRouting.Items.Count > 0) { if (sourceRouting.Items[0].Properties.ContainsKey(Workshare.Policy.Routing.SMTPItemPropertyKeys.DisplayName)) removableStorageEntity.UserName = sourceRouting.Items[0].Properties[Workshare.Policy.Routing.SMTPItemPropertyKeys.DisplayName]; else removableStorageEntity.UserName = sourceRouting.Items[0].Content; } } if (destinationRouting != null) { foreach (IRoutingItem routing in destinationRouting.Items) { if (routing.Properties.ContainsKey(RemovableDeviceItemPropertyKeys.ContentType)) { switch (routing.Properties[RemovableDeviceItemPropertyKeys.ContentType]) { case RemovableDeviceItemContentTypes.DeviceType: removableStorageEntity.DeviceType = routing.Content; break; case RemovableDeviceItemContentTypes.VolumeID: removableStorageEntity.DeviceID = routing.Content; break; case RemovableDeviceItemContentTypes.VolumeName: removableStorageEntity.DeviceName = routing.Content; break; } } } } } List<DocumentEntity> fileEntities = new List<DocumentEntity>(); foreach (IContentItem fileInfo in pro.ContentCollection) { if (!ShouldAudit(fileInfo)) continue; DocumentEntity fileEntity = ConvertToDocumentEntity(fileInfo, pro); fileEntities.Add(fileEntity); } removableStorageEntity.Files = fileEntities.ToArray(); return removableStorageEntity; }
private void EnforcePolicy() { m_policyResponseObject = null; if (m_engine == null || m_uroIn == null) throw new System.NullReferenceException("Give me something to work with!"); m_policyResponseObject = m_engine.ProcessPolicies(RunAt.Client, m_uroIn, ProcessLevel.Actions); }
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; }