internal void SaveResponse(Response response, string filepath)
		{
			using (FileStream fs = new FileStream(filepath, FileMode.Create, FileAccess.Write))
			{
				m_ResponseSerializer.WriteObject(fs, response);
			}
		}
Example #2
0
		protected static IStorageLinks GetStorageLinks(Response response, Action sendLinkAction)
		{
			Interop.Logging.Logger.LogInfo("GetStorageLinks");
			if (sendLinkAction == null)
			{
				throw new NullReferenceException("Failed to get the SendLink action");
			}

			string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar;
			path += sendLinkAction.Assembly;
			Assembly sendLinkAssembly = Assembly.LoadFrom(path);
			Type[] types = sendLinkAssembly.GetExportedTypes();

			IStorageLinks storagelinks = null;
			foreach (Type type in types)
			{
				if (typeof (IStorageLinks).IsAssignableFrom(type))
				{
					storagelinks = (IStorageLinks) sendLinkAssembly.CreateInstance(type.FullName);
					Interop.Logging.Logger.LogInfo(string.Format("Cloud Storage assembly type is {0}", type.FullName));
					break;
				}
			}

			if (storagelinks == null)
			{
				throw new NullReferenceException("Failed to find or create a valid storagelinks object");
			}
			return storagelinks;
		}
Example #3
0
		public void DoActionsTestHelper(Response response, PreviewResponseActionArgs e)
		{
			ResolvedAction pdfAction = null;
			ResolvedAction cleanAction = null;
			foreach (ResolvedAction action in response.ResolvedActions)
			{
				if (action.Action.ClassName == "Workshare.Policy.Actions.CleanUserAction")
					cleanAction = action;
				else if (action.Action.ClassName == "Workshare.Policy.Actions.PDFUserAction")
					pdfAction = action;
			}
			DoActions(pdfAction, cleanAction, e);            
		}
		public void RunAtGetsPropagatedToPRO()
		{
			Workshare.Policy.IContainer cont = null;
			Response response = new Response();
			Request request = new Request();
			request.PolicyType = PolicyType.ClientEmail.ToString();
			response.Contents = new Workshare.PolicyContent.ContentItem[0];

			IPolicyResponseObject pro = ResponseAdaptor.GetPRO(response, request, out cont);

			Assert.AreEqual(Workshare.Policy.RunAt.Client, pro.RunAt);

			response.Properties = new CustomProperty[] { new CustomProperty(ResponseAdaptor.RunAtKey, "Server") };

			pro = ResponseAdaptor.GetPRO(response, request, out cont);

			Assert.AreEqual(Workshare.Policy.RunAt.Server, pro.RunAt);
		}
		public void TestClientVerified_GetPro()
		{
			Response response = new Response();
			response.Contents = new Workshare.PolicyContent.ContentItem[0];

			Request request = new Request();
			request.PolicyType = PolicyType.Mta.ToString();

			Workshare.Policy.IContainer container;

			IPolicyResponseObject pro = ResponseAdaptor.GetPRO(response, request, out container);

			Assert.IsFalse(pro.VerifiedOnClient, "Expect this to be false - the input reponse did not have the CustomProperty that governs this flag.");

			CustomProperty verifiedOnClient = new CustomProperty(PolicyConstants.ClientVerified, bool.FalseString);
			response.Properties = new CustomProperty[] { verifiedOnClient };

			pro = ResponseAdaptor.GetPRO(response, request, out container);
			Assert.IsFalse(pro.VerifiedOnClient, "Expect this to be false - the input response CustomProperty has a value of false.");

			response.Properties[0].Value = bool.TrueString;
			pro = ResponseAdaptor.GetPRO(response, request, out container);
			Assert.IsTrue(pro.VerifiedOnClient, "Expect this to be true - the input response CustomProperty has a value of true.");
		}
Example #6
0
		private static Response ErrorResponse(Exception ex)
		{
			Response errorResponse = new Response();

            // if SupressUnsupportedOfficeError option is enabled and the error is caused by unsupported 
            // office 6/95 document we'll just skip this error and proceed sending the email
            var hr = Marshal.GetHRForException(ex);

            if (hr == UNSUPPORTED_OFFICE_EXCEPTION && Interop.Options.OptionApi.GetBool("SupressUnsupportedOfficeError"))
                return errorResponse;
            
            int count = 0;
			List<CustomProperty> props = new List<CustomProperty>();
			// pull out inner exceptions so we have the whole lot of info available to look at
			while (ex != null)
			{

				string suffix = "." + count.ToString(CultureInfo.InvariantCulture);

				props.Add(new CustomProperty(ContentEnforcer.ErrorMessageKey + suffix, ex.Message));
				props.Add(new CustomProperty(ContentEnforcer.ErrorStackKey   + suffix, ex.StackTrace));
				props.Add(new CustomProperty(ContentEnforcer.ErrorStringKey  + suffix, ex.ToString()));

				count++;
				ex = ex.InnerException;
			}

			errorResponse.Properties = props.ToArray();

			foreach (var prop in props)
			{
				Logger.LogInfo(prop.Name + " :: " + prop.Value);
			}

			return errorResponse;
		}
Example #7
0
		/// <summary>
		/// Remove irrelevant properties, if request is flagged as such
		/// </summary>
		/// <param name="result"></param>
		private static void RemoveExpressionDetail(Response result)
		{
			if (result != null && result.Properties != null)
			{
				if (!Array.Exists(result.Properties, prop =>
					string.Equals(prop.Name, RemovableDeviceRequestPropertyKeys.IgnoreExpressionDetail, StringComparison.OrdinalIgnoreCase)
					&& string.Equals(prop.Value, bool.TrueString, StringComparison.OrdinalIgnoreCase)))
				{
					return;
				}

				if (result.Contents != null)
				{
					RemoveExpressionDetail(result.Contents);
				}

				if (result.ResolvedActions != null)
				{
					foreach (ResolvedAction ra in result.ResolvedActions)
					{
						if (ra.Contents == null)
							continue;
						RemoveExpressionDetail(ra.Contents);
					}
				}
			}
		}
Example #8
0
        static  PolicySetEvent[] GetPolicySetEvents(Response response)
        {
            var policySets = new List<PolicySetEvent>();

			try
			{
                foreach (var contentItem in response.Contents)
                {   
                    foreach (var policySet in contentItem.PolicySets)
                    {
                        var policySetEvent = new PolicySetEvent() 
                            {
                                PolicySetName = policySet.Name 
                            };

                        foreach (var policy in policySet.Policies)
                        {   
                            foreach (var expression in policy.Expressions)
                            {
                                if (!String.IsNullOrEmpty(expression.Rating))
                                {
                                    policySetEvent.Risk = expression.Rating;
                                }
                            }
                        }

                        policySets.Add(policySetEvent);
                    }                
                }
            }
            catch(Exception ex)
            {
                Logger.LogError(ex);
            }

            return policySets.ToArray();
        }
Example #9
0
		/// <summary>
		/// Creates an engine PolicyResponseObject
		/// </summary>
		/// <param name="responseIn"></param>
		/// <param name="request"></param>
		/// <param name="container">container object built rooted at a virtual node</param>
		/// <returns>IPolicyResponseObject with URO inside the implementation.</returns>
		public static IPolicyResponseObject GetPRO(Response responseIn, Request request, out IContainer container)
		{
			if (null == responseIn)
				throw new ArgumentException("responseIn");

			PolicyResponseObject proOut = new PolicyResponseObject();

			proOut.UniversalRequestObject = RequestAdaptor.GetURO(request);
			proOut.PolicyType = proOut.UniversalRequestObject.PolicyType;

			proOut.RunAt = Workshare.Policy.RunAt.Client;
			
			if ( responseIn.Properties != null)
			{
				foreach (CustomProperty property in responseIn.Properties)
				{
					if (property.Name == RunAtKey && (Workshare.Policy.RunAt.Server.ToString() == property.Value))
					{
						proOut.RunAt = Workshare.Policy.RunAt.Server;
					}

					if (property.Name == PolicyConstants.ClientVerified &&
						property.Value == bool.TrueString)
					{
						proOut.VerifiedOnClient = true;
					}
					else
					{
						proOut.Properties[property.Name] = property.Value;
					}
				}
			}

			proOut.RoutingInformation = new Collection<IUniversalRoutingEntity>();
			if ( responseIn.Routing != null)
			{
				foreach (RoutingEntity routingEntity in responseIn.Routing)
				{
					proOut.RoutingInformation.Add( RoutingEntityAdaptor.GetUniversalRoutingEntity(routingEntity));
				}
			}

			container = HandleContent(proOut, responseIn);

			proOut.ResolvedActionCollection = new Collection<IResolvedAction>();
			if ( responseIn.ResolvedActions != null)
			{
				foreach (Workshare.PolicyContent.ResolvedAction action in responseIn.ResolvedActions)
				{
					proOut.ResolvedActionCollection.Add(ResolvedActionAdaptor.GetIResolvedAction(proOut, action));
				}
			}

			
			return proOut;
		}
Example #10
0
		private bool ProcessPrematureResponse()
		{
			// Means scanning has not completed yet, and the user has pressed Send
			// We gonna scrap discovery stuff, and apply pre-set actions
			m_threadKiller.Abort();
			m_skipDiscovery = true;

            InitializeEngine();

			if (m_encryptionManager == null)
			{
				m_encryptionManager = new ContentEncryptionManager(_msgExpander, _msgPacker);
			}
			if (!m_encryptionManager.DecryptRequestAttachments(m_request, m_encryptionUi))
			{
				m_processResult = ProcessResult.CANCELLED;
				return false;
			}
			m_response = CallContentScanner();
			m_uiResponse = ResponseAdapter.UIResponseFromResponse(m_request, m_response);

			m_policyClientDialog.SetResponse(m_uiResponse);

			// Check for violations
			if (m_uiResponse != null && !m_uiResponse.ContainsViolations())
			{
				m_processResult = ProcessResult.NO_VIOLATIONS;
				return false;
			}

			// Check for Actions in uiResponse
			if (m_uiResponse != null && m_uiResponse.Actions.Count <= 0)
			{
				m_processResult = ProcessResult.NO_ACTIONS;
				return false;
			}

			m_processResult = ProcessResult.UNDEFINED;



			CreateOfficeApplicationsUsingUroAttachments();

			return true;
		}
Example #11
0
		internal static bool ShouldExecuteSendLinkAction(Response response)
		{
			try
			{
				if (GetSendLinkAction(response) == null)
				{
					return false;
				}
				return true;
			}
			catch (Exception ex)
			{
				Interop.Logging.Logger.LogError(ex);
				throw;
			}

		}
Example #12
0
		private static bool ResponseContainsOfficeAction(Response response)
		{
			if (response == null)
			{
				return false;
			}
			ResolvedAction[] actions = response.ResolvedActions;
			if (actions == null)
			{
				return false;
			}
			foreach (ResolvedAction action in actions)
			{
				if (action.Action == null)
				{
					continue;
				}
				ActionProperty[] properties = action.Action.ActionProperties;
				if (properties == null)
				{
					continue;
				}
				if (Array.Exists(properties, prop =>
					prop.Name.Equals(PropertyNames.REQUIRES_APPCONTROLLER, StringComparison.InvariantCultureIgnoreCase)
					&& prop.Value.Equals(bool.TrueString, StringComparison.InvariantCultureIgnoreCase)))
				{
					return true;
				}
			}
			return false;
		}
Example #13
0
		protected virtual EnforceResponse CallEnforcerForPreview(IProgressCallback callback, Request request, Response response)
		{
			return m_factory.CreateContentEnforcer(callback).Enforce(request, response);
		}
Example #14
0
		/// <summary>
		/// TEMPORARY method to ensure the host process caches office applications.
		/// Soon this will be optimized to avoid startup/shutdown of apps for every call to Enforce().
		/// </summary>
		/// <param name="response"></param>
		private static void CacheOfficeApps(Response response)
		{
			Logger.LogDebug("CONTENT ENFORCER: Caching MS Office apps");

			Dictionary <FileType, bool> fileTypeSet = new Dictionary<FileType, bool>();
			foreach (ContentItem item in response.Contents)
			{
				FileType ft = (FileType) Enum.Parse(typeof (FileType), item.ContentType);

				switch( ft )
				{
					case FileType.WordDocument:
					case FileType.ExcelSheet:
					case FileType.PowerPoint:
						
						if (!fileTypeSet.ContainsKey(ft))
						{
							OfficeApplicationCache.Instance.Create(ft);
							fileTypeSet[ft] = true;
						}
						break;
						
					default:
						break;
				}
			}
		}
Example #15
0
		private static bool ResponseNeedsApplicationCache(Response response)
		{
			foreach (CustomProperty property in response.Properties)
			{
				if ( 0 == string.Compare("RunAt", property.Name, StringComparison.InvariantCultureIgnoreCase))
				{
					RunAt runAt = (RunAt) Enum.Parse(typeof (RunAt), property.Value);

					return (RunAt.Client == runAt && ResponseContainsOfficeAction(response));
				}
			}
			return false;
		}
Example #16
0
 public UIResponse(Request request, Response response)
 {
     m_actions = new Dictionary<string, UIAction>();
     m_blockingActions = new List<UIAction>();
     m_request = request;
     m_response = response;
 }
Example #17
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;
		}
Example #18
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;
		}
Example #19
0
		private static IContainer HandleContent(PolicyResponseObject proOut, Response responseIn)
		{
			ContainerBuilder containerBuilder = new ContainerBuilder(proOut);
			IContainer retVal = containerBuilder.CreateContainerFromUro();
			

			AssignContentIds(responseIn, proOut.ContentCollection);
			
			//We now have a populated content collection, with the correct container structure.
			//Next, associate policy with the new content collection.

			Dictionary<string, Workshare.PolicyContent.ContentItem> contentItemLookup = new Dictionary<string, Workshare.PolicyContent.ContentItem>();
			foreach (Workshare.PolicyContent.ContentItem item in responseIn.Contents)
			{
				contentItemLookup[item.Id] = item;

				//This just gives us an indexer into the Response content items.  
			}

			foreach (IContentItem item in proOut.ContentCollection)
			{
				Workshare.Policy.Engine.ContentItem contentItem =
					item as Workshare.Policy.Engine.ContentItem;

				Debug.Assert(contentItemLookup.ContainsKey(contentItem.File.ContentId));

				PolicySet[] policySets = contentItemLookup[contentItem.File.ContentId].PolicySets;

				foreach (PolicySet set in policySets)
				{
					item.PolicySetCollection.Add( PolicySetAdaptor.GetIPolicySetResponse(set) );
				}
			}

			return retVal;
		}
Example #20
0
		public EnforceResponse Enforce(Request request, Response response)
		{
			Logger.LogDebug("CONTENT ENFORCER: Enforce()");
			if (null == request)
				throw new System.ArgumentNullException("request");
			if (null == response)
				throw new System.ArgumentNullException("response");

			bool isAppCacheNeeded = ResponseNeedsApplicationCache(response);

			List<IDisposable> disposeList = new List<IDisposable>();
			try
			{
				IContainer virtualRoot;
				IPolicyResponseObject pro = ResponseAdaptor.GetPRO(response, request, out virtualRoot);
				disposeList.Add(pro as IDisposable);
				disposeList.Add(virtualRoot);

				ActionExecuter executer = new ActionExecuter(m_operationCallback);

				if (isAppCacheNeeded)
				{
					CacheOfficeApps(response);
				}

				IUniversalRequestObject uro = executer.ExecuteActions(pro, ref virtualRoot);
				disposeList.Add(uro as IDisposable);

				EnforceResponse enforcedResponse = new EnforceResponse();

				enforcedResponse.Properties = new CustomProperty[0];

				enforcedResponse.ModifiedRequest = RequestAdaptor.GetRequest(uro);

				return enforcedResponse;
			}
			///TODO: resolve the fault v error code debate later. essentially need a test system to simulate
			/// the different scenarios. Note that the exception handling is part of the service agreement
			/// as opposed to the general Exception catch case below.
			catch (PolicyActionException actionException)
			{
				return HandleException(actionException, request, actionException.ExceptionHandling);
			}
			catch (Exception ex)
			{
				Logger.LogError("Content Enforcer General Failure");
				Logger.LogError(ex);
				return HandleException(ex, request, ActionExceptionHandling.Prompt);
			}
			finally
			{
				//For now, just shut down cached applications at the end of a call.
				if (isAppCacheNeeded)
				{
					Logger.LogDebug("CONTENT ENFORCER: Closing MS Office Apps");
					OfficeApplicationCache.Instance.ShutDown();
				}

				Logger.LogDebug("CONTENT ENFORCER: Disposing URO's");
				foreach (IDisposable disp in disposeList)
				{
					if (disp != null)
					{
						disp.Dispose();
					}
				}
                disposeList.Clear();
			}
		}
Example #21
0
		private bool GetResponse()
		{
			object[] errors = null;
			try
			{
				m_response = CallContentScanner();
                ResponseAnalyser.CollectAndSendEvents(m_response, ResponseAnalyser.EventType.PolicySet);

				if (m_response == null)
				{
					Logger.LogError("RequestManager.GetResponse(): ContentScanner returned null");
					m_processResult = ProcessResult.ERROR_SCAN_FAILURE;// Indicate total scanning failure.
					return false;
				}

				m_uiResponse = ResponseAdapter.UIResponseFromResponse(m_request, m_response);

				errors = m_uiResponse.GetErrors();
				if (errors.Length == 0)
				{
					return true;
				}
			}
			catch (Exception ex)
			{
				Logger.LogError(ex);
			}

			RecordDiscoveryErrors(errors);
			return false;
		}
Example #22
0
		private List<SendLinkInfo> GetLinks(Response response, MailItem mailItem, IEnumerable<PolicyContent.Attachment> listAttachments, string id)
		{
		    try
		    {
                bool foundDistributionList = false;
                List<string> emailAddresses;
                using (IWSMail mail = Oif.CreateWSMail(mailItem))
                {
                    emailAddresses = new List<string>();
                    using (IWSRecipients recipients = mail.Recipients)
                    {
                        foreach (IWSRecipient recip in recipients)
                        {
                            // Only add recipients for SkyDox that are To and CC
                            if (recip.Type != (int)OlMailRecipientType.olBCC)
                            {
                                emailAddresses.Add(recip.AddressEntry.SMTPAddress);
                                foundDistributionList |= IsDistributionList(recip.AddressEntry);
                            }

                            recip.Dispose();
                        }
                    }
                }

                var sendlinkAction = GetSendLinkAction(response);
                var storageLinks = GetStorageLinks(response, sendlinkAction);
                var propertySet = GetActionProperties(sendlinkAction);

                if (foundDistributionList && storageLinks.RequireUsersToLogIn(propertySet))
                {
                    if(WsMessage.ShowMessage(IntPtr.Zero, Resources.SENDLINK_MSG_HAS_DIST_LIST, MessageButtons.WsYesNo,
                                                            MessageBranding.WsDefault,
                                                            MessageType.WsWarnIcon,
                                                            Resources.SENDLINK_MSG_HAS_DIST_LIST_HEADLINE,
                                                            -1) != MessageResult.WsResultYes)
					{
                        Logger.LogInfo("User cancelling due to distribution list");
                        throw new AbortSendLinkException("Cloud Storage Authentication Cancelled", false);
					}
                }

                string username = OptionApi.GetString("SendLinkCloudStorageLoginName");
                if(String.IsNullOrEmpty(username))
                {
                    username = GetDefaultSendEmailForCurrentProfile(mailItem); // if we have to use a "default" username, we should make the user log in
                	OptionApi.SetString("SendLinkCloudStorageLoginName", username);                    
                }

                List<SendLinkInfo> list = GetAttachments(listAttachments, id);

		    
                var prSearchBytes = mailItem.PropertyAccessor.GetProperty(MAPIStringDefines.PR_SEARCH_KEY);
		    
                string prSearchKey = Convert.ToBase64String(prSearchBytes);
                
                string subject = mailItem.Subject;
                if (string.IsNullOrEmpty(subject))
                    subject ="( " + DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss") + " )";

                return RetrieveLinks(username, storageLinks, sendlinkAction, response, list, emailAddresses, subject, id, prSearchKey);    
		    }
		    catch (StorageUnavailableException ex)
		    {
		        Logger.LogError(ex);
		        throw new AbortSendLinkException(Resources.PleaseCheckYourInternetConnection, ex, true);
		    }
		}
Example #23
0
		protected Response CreateResponseForPreview(PreviewResponseActionArgs e, ResolvedAction[] actions)
		{
			Response response = new Response();
			response.Contents = new ContentItem[2] { new ContentItem(), new ContentItem() };
			bool foundItem0 = false, foundItem1 = false;
			foreach (ContentItem item in e.UIResponse.Response.Contents)
			{
				if (item.Name == m_emailContentName)
				{
					response.Contents[0] = item;
					foundItem0 = true;
				}
				else if (item.Id == e.DocID)
				{
					response.Contents[1] = item;
					foundItem1 = true;
				}
				if (foundItem0 && foundItem1)
				{
					break;
				}
			}
			response.PolicyType = e.UIResponse.Response.PolicyType;
			response.Properties = e.UIResponse.Response.Properties;
			response.ResolvedActions = actions;
			response.ResponseDate = e.UIResponse.Response.ResponseDate;
			response.Routing = e.UIResponse.Response.Routing;
			return response;
		}
Example #24
0
        static List<ActionEvent> GetActionEvents(Response response, bool preResolve = false)
        {
            var events = new List<ActionEvent>();

            foreach (var action in GetActions(response, preResolve))
            {
                string contentId = action.Item1;
                string actionType = action.Item2;
                string actionRisk = action.Item3;
                ActionProperty[] actionProperties = action.Item4;

                if (String.Compare(actionType, "Clean", true) == 0 ||
                    String.Compare(actionType, "Lightspeed Clean", true) == 0 ||
                    String.Compare(actionType, "PDFClean", true) == 0)
                {
                    events.AddRange(CreateEvents(actionType, contentId, actionProperties));
                    continue;
                }

                if (String.Compare(actionType, "Workshare SendLink", true) == 0)
                {
                    actionType = "Secure File Transfer";
                }
                events.Add(CreateEvent("ActionApplied", actionType, actionRisk, contentId));
            }

            return events;
        }
Example #25
0
		private void PrepareProtectSimpleResponse(string profileLocation)
		{
			InitializeEngine();

			AddProtectSimpleProfile(profileLocation);	// A profile is a policy, but we chose to call it a Profile :)

			if (m_encryptionManager == null)
			{
				m_encryptionManager = new ContentEncryptionManager(_msgExpander, _msgPacker);
			}

			if (m_encryptionUi != null)
			{
				m_encryptionUi.OnShowDialog += new ShowDialogEvent(m_encryptionUi_OnShowDialog);
			}

			if (!m_encryptionManager.DecryptRequestAttachments(m_request, m_encryptionUi))
			{
				if (!string.IsNullOrEmpty(m_encryptionManager.LastErrorText))
				{
					m_errors.Add(ErrorAsDialogTextKey + m_encryptionManager.LastErrorText);// prepend ErrorAsDialogTextKey constant so that we DO display the message to the user
					m_encryptionManager.LastErrorText = string.Empty;
					m_processResult = ProcessResult.ERRORS;
					m_bUpdateProcessResult = false;
				}
				else
				{
					m_processResult = ProcessResult.CANCELLED;
				}
				return;
			}

			m_response = CallContentScanner();
            
			ResponseAnalyser.CollectAndSendEvents(m_response, ResponseAnalyser.EventType.PolicySet);

			m_uiResponse = ResponseAdapter.UIResponseFromResponse(m_request, m_response);                      

			// hey, you know what - something might have gone wrong in that content scanning. Let's check
			object[] errors = m_uiResponse.GetErrors();
			if (errors.Length > 0)
			{
				// wow! something bad did happen. Better report it back to the user
				RecordDiscoveryErrors(errors);
				return;
			}

			string reason = string.Empty;
			if (!m_uiResponse.Synchronize(out reason))
			{
				Logger.LogError("Unable to synchronize responses. Reason = " + reason);
				m_processResult = ClientManager.ProcessResult.ERRORS;
				return;
			}

			// Check for violations
			if (m_uiResponse != null && !m_uiResponse.ContainsViolations())
			{
				m_processResult = ProcessResult.NO_VIOLATIONS;
				return;
			}

			// Check for Actions in uiResponse
			if (m_uiResponse != null && m_uiResponse.Actions.Count <= 0)
			{
				m_processResult = ProcessResult.NO_ACTIONS;
				return;
			}

			m_processResult = ProcessResult.UNDEFINED;

			CreateOfficeApplicationsUsingUroAttachments();

			return;
		}
Example #26
0
		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;
		}
Example #27
0
		protected static PolicyContent.Action GetSendLinkAction(Response response)
		{
			foreach (ContentItem item in response.Contents)
			{
				foreach (PolicySet policySet in item.PolicySets)
				{
					foreach (PolicyContent.Policy policy in policySet.Policies)
					{
						foreach (PolicyContent.Action action in policy.Actions)
						{
							if (action.ActionProperties.Any(prop => prop.Name == "CloudStorage"))
							{
								return action;
							}
						}
					}
				}
			}
			return null;
		}
Example #28
0
		private static void PopulateRunAt(Response response, RunAt runat)
		{
			List<CustomProperty> props = new List<CustomProperty>(response.Properties);
			
			props.Add( new CustomProperty("RunAt", runat.ToString()));

			response.Properties = props.ToArray();
		}
Example #29
0
		internal List<SendLinkInfo> RetrieveLinks(string defaultEmailAddress, IStorageLinks storageLinks, Action sendLinkAction, Response response, List<SendLinkInfo> files, List<string> emailAddresses, string subject, string id, string prSearchKey = "")
		{
			Interop.Logging.Logger.LogInfo("Retrieve Links");

			try
			{
                List<IActionProperty> actionProperties = GetActionProperties(sendLinkAction);

				int count = files.Count;
   			    string workingDirectory = GetWorkingDirectory(id);
                storageLinks.PrSearchKey = prSearchKey;
                storageLinks.GetLinks(defaultEmailAddress, files, emailAddresses, subject, actionProperties, workingDirectory, id);

				if (files.Count != count)
				{
					throw new ArgumentException("The number of items returned are invalid. The number of items retured should match the input number.");
				}

				if (!ContainsLinks(files))
				{
					throw new ArgumentException("Failed to retreive any links.");
				}

				return files;
			}
			catch (Exception ex)
			{
				Interop.Logging.Logger.LogError(ex);
				throw;
			}
			finally
			{
				Interop.Logging.Logger.LogInfo("Exit Retrieve Links");
			}
		}
Example #30
0
		private static void AssignContentIds(Response responseIn, Collection<IContentItem> collection)
		{
			if (responseIn.Contents.Length != collection.Count)
			{
				Debug.Assert(false);
				return;
			}

			for(int i = 0;i< collection.Count; i++)
			{
				bool nameMatch = 0 == string.Compare(collection[i].Name, responseIn.Contents[i].Name, StringComparison.InvariantCultureIgnoreCase);

				if (collection[i].Properties.ContainsKey(ContentItemAdaptor.ContentDataSourceKey))
				{
					nameMatch = nameMatch || (0 == string.Compare(collection[i].Properties[ContentItemAdaptor.ContentDataSourceKey], responseIn.Contents[i].Name, StringComparison.InvariantCultureIgnoreCase));
				}
				//Debug.Assert(nameMatch, "Content item names do not match");
				
				Workshare.Policy.Engine.ContentItem contentItem = collection[i] as Workshare.Policy.Engine.ContentItem;
				if ( contentItem != null)
				{
					contentItem.File.ContentId = responseIn.Contents[i].Id;
				}
			}
		}