public void TestGetDigest()
        {
            Request request = new Request();
            
            List<CustomProperty> props = new List<CustomProperty>();

            props.Add(new CustomProperty("Subject", "This is a subject"));
            
            RoutingEntity sourceRouting = new RoutingEntity();

            RoutingItem item = new RoutingItem();
            item.Content = "*****@*****.**";
            
            sourceRouting.Items = new RoutingItem[] {item};
            request.Source = sourceRouting;
            request.Properties = props.ToArray();

            string digest1 = new RequestDigestProvider().GetDigest(request);
            //change the request, get a different digest value.

            request.Source.Items[0].Content = "*****@*****.**";
            string digest2 = new RequestDigestProvider().GetDigest(request);
            Assert.AreNotEqual(digest1,digest2);

            request.Properties[0].Value = "Change the subject";
            string digest3 = new RequestDigestProvider().GetDigest(request);
            Assert.AreNotEqual(digest1,digest2);
            Assert.AreNotEqual(digest2, digest3);

            //Empty subject is OK
            request.Properties[0].Value = string.Empty;

            string digest4 = new RequestDigestProvider().GetDigest(request);
            Assert.AreNotEqual(digest1,digest4);
        }
		/// <summary>
		/// Compare a request with a test XML file, checks the following
		/// a) Number of attachments
		/// b) encryption status of attachments
		/// c) Structure of attachments(.zip/.msg)
		/// </summary>
		/// <param name="testXMLFile"></param>
		/// <param name="request"></param>
		/// <returns></returns>
		public bool CheckAttachments(string testXMLFile, Request request)
		{
			List<string> scriptAttachments = GetAttachmentList(testXMLFile);
			if (scriptAttachments.Count != request.Attachments.Length)
			{
				throw new Exception("CheckAttachments: Count does not match");
			}

			// TODO Ensure they exist on the disk
			
			// Check zip contents & structure
			foreach (Attachment attach in request.Attachments)
			{
				CheckAttachmentFiles(attach.File);

				if (attach.File.FileType == FileType.ZIP)
				{
					// Compare processed file with original test file
					if (!CheckZipsMatch(attach.File.FileName, Path.Combine(TestFileDirectory, Path.GetFileName(attach.FileName))))
					{
						return false;
					}
				}
				else if (attach.File.FileType == FileType.Email)
				{
					// TODO
				}

				// Check encryption status
			}

			return true;
		}
		internal void SaveRequest(Request request, string filepath)
		{
			using (FileStream fs = new FileStream(filepath, FileMode.Create, FileAccess.Write))
			{
				m_RequestSerializer.WriteObject(fs, request);
			}
		}
		public void VerifyAttachmentAreReadFromDisk()
		{
			//setup
			string someRandomFile = Path.GetTempFileName();
			try {

				File.WriteAllText(someRandomFile, "Hello world to you too");
			Request request = new Request();

			request.PolicyType = PolicyType.ClientEmail.ToString();
			request.Destination = new RoutingEntity();
			request.Source = new RoutingEntity();

			request.Source.Properties = new CustomProperty[] { new CustomProperty(SMTPRoutingPropertyTags.RequestChannel, "Outlook"), };
			request.Source.RoutingType = Workshare.PolicyContent.RoutingTypes.Source;

			request.Destination.Properties = new CustomProperty[] { new CustomProperty(SMTPRoutingPropertyTags.RequestChannel, "Outlook"), };
			request.Destination.RoutingType = Workshare.PolicyContent.RoutingTypes.Destination;

			request.Destination.Items = new Workshare.PolicyContent.RoutingItem[0];

			request.Source.PolicyType = request.Destination.PolicyType = request.PolicyType;

			request.DateTime = DateTime.Now;

			request.Properties = new CustomProperty[] { new CustomProperty(RequestAdaptor.PassContentAsFileProperty, string.Empty) };

			
		 
			string contentype = "text/plain";
			string id = Guid.NewGuid().ToString();
			string index = "1";


			Attachment attachment = new Attachment(someRandomFile, contentype, id, index, false);
			attachment.Content = null;

			attachment.Properties = new CustomProperty[] { new CustomProperty(ContentItemAdaptor.ContentDataSourceKey, someRandomFile) };

			request.Attachments = new Attachment[] { attachment };

			//execute
			IUniversalRequestObject uro = RequestAdaptor.GetURO(request);

			Assert.AreEqual(1, uro.Attachments.Count, "Incorrect number of attachments");
			foreach (RequestAttachment attach in uro.Attachments)
			{
				Assert.IsTrue(attach.Data == null, "Expected null data. Use file instead.");
				Assert.IsTrue(File.Exists(attach.FileName), "Should reference a valid file");
			}

			Assert.IsTrue(uro.Properties.ContainsKey(RequestAdaptor.PassContentAsFileProperty), "ContentAsFiles key missing");

			} finally{
				File.Delete(someRandomFile);
			}
		}
Exemple #5
0
		public Request Convert(RequestChannel requestChannel, bool ignoreRecipients)
		{
			Request request = new Request();

			Convert(requestChannel, request, ignoreRecipients);

			return request;

		}
Exemple #6
0
        public static Request GetRequest(IUniversalRequestObject uroIn)
        {
            if (null == uroIn)
                throw new ArgumentNullException("uroIn");

            Request requestOut = new Request();

            requestOut.DateTime = uroIn.DataTimeStamp;
            requestOut.Source = RoutingEntityAdaptor.GetRoutingEntity(uroIn.Source);
            requestOut.Destination = RoutingEntityAdaptor.GetRoutingEntity(uroIn.Destination);
            requestOut.PolicyType = uroIn.PolicyType.ToString();

            requestOut.Properties = new CustomProperty[0];
            if ( uroIn.Properties != null && uroIn.Properties.Count > 0)
            {
                List<CustomProperty> props = new List<CustomProperty>();
                foreach (KeyValuePair<string, string> pair in uroIn.Properties)
                {
                    props.Add(new CustomProperty(pair.Key, pair.Value));
                }
                requestOut.Properties = props.ToArray();
            }

            requestOut.Attachments = new Attachment[0];
            if ( uroIn.Attachments != null && uroIn.Attachments.Count > 0)
            {
                bool returnFile = uroIn.Properties.ContainsKey(RequestAdaptor.PassContentAsFileProperty);
                
                List<Attachment> attachments = new List<Attachment>();
                foreach (RequestAttachment attachment in uroIn.Attachments)
                {
                    attachments.Add(  returnFile ? AttachmentAdaptor.GetAttachmentAsFile(attachment) : AttachmentAdaptor.GetAttachment(attachment));
                }
                requestOut.Attachments = attachments.ToArray();
            }

            RequestAttachment mimeAttachment = uroIn.OriginalContentBytes;
            if ( mimeAttachment != null)
            {
                CustomProperty mimeProperty = new CustomProperty(SMTPPropertyTags.OriginalMimeContent,
                    mimeAttachment.Data.AsString(mimeAttachment.Data.Length, Encoding.Unicode));

                CustomProperty[] oldProps = requestOut.Properties;
                List<CustomProperty> newProps = new List<CustomProperty>(oldProps);
                newProps.Add(mimeProperty);
                requestOut.Properties = newProps.ToArray();
            }

            return requestOut;
        }
Exemple #7
0
        public static IUniversalRequestObject GetURO(Request request)
        {
            if (null == request)
                throw new ArgumentNullException("request");

            UniversalRequestObject uro = new UniversalRequestObject();

            uro.DataTimeStamp = request.DateTime;
            uro.PolicyType = (PolicyType)Enum.Parse(typeof(PolicyType), request.PolicyType);
            uro.Source = RoutingEntityAdaptor.GetUniversalRoutingEntity(request.Source);
            uro.Destination = RoutingEntityAdaptor.GetUniversalRoutingEntity(request.Destination);

            uro.Attachments = new RequestAttachmentCollection();
            if (request.Attachments != null)
            {
                foreach (Attachment attachment in request.Attachments)
                {
					if (!attachment.IgnoreForWorkshareActions) //yyz THIS MEANS .MP4 MISSED BY SENDLINK
                    {
						uro.Attachments.Add(AttachmentAdaptor.GetRequestAttachment(attachment));
					}
                }
            }

            uro.Properties = new Dictionary<string, string>();
            if (request.Properties != null)
            {
                foreach (CustomProperty property in request.Properties)
                {
                    //Original MIME content should be sent in via a named CustomProperty.
                    if (0 == string.Compare(SMTPPropertyTags.OriginalMimeContent, property.Name, StringComparison.InvariantCulture))
                    {
                        HandleOrigContentBytes(property.Value, uro);
                        continue;
                    }

                    uro.Properties[property.Name] = property.Value;
                }
            }

            if (PolicyType.ClientEmail.ToString() == request.PolicyType)
            {
                uro.Properties["_ROOTCONTENTID"] = Guid.NewGuid().ToString();
            }

            return uro;
        }
		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 string GetDigest(Request request)
		{
			if ( request  == null )
                throw new ArgumentNullException("request");
            
            if (request.Source == null)
                throw new ArgumentNullException("request.source");

            if (request.Source.Items == null)
                throw new ArgumentNullException("request.Source.Items");

            if (request.Properties == null)
                throw new ArgumentNullException("request.Properties");

			CustomProperty subjectProperty = Array.Find(request.Properties,
				cp => string.Equals(cp.Name, "Subject", StringComparison.OrdinalIgnoreCase));

			if (subjectProperty == null)
				throw new ArgumentException("request.Properties");
	
			if (request.Source.Items.Length != 1)
				throw new ArgumentException("request.Source.Items");

			string sourceRoutingAddress = request.Source.Items[0].Content;
			if (string.IsNullOrEmpty(sourceRoutingAddress))
				throw new ArgumentNullException("request");

			//Email clients may capitalize smtp addresses depending on what is entered in an address book.  
			sourceRoutingAddress = sourceRoutingAddress.ToLowerInvariant();

			StringBuilder sb = new StringBuilder();
			sb.Append(subjectProperty.Value);
			sb.Append(sourceRoutingAddress);

			byte[] buf = Encoding.Unicode.GetBytes(sb.ToString());

			using (HashAlgorithm ha = MD5.Create())
			{
				ha.TransformBlock(buf, 0, buf.Length, buf, 0);
				ha.TransformFinalBlock(m_salt, 0, m_salt.Length);

				return FormatHash(ha.Hash);
			}
		}
		/// <summary>
		/// Create a basic ClientMail request.
		/// </summary>
		/// <remarks>
		/// Sets up the destination and source routing etc
		/// </remarks>
		/// <returns></returns>
		public static Request CreateRequest(CustomProperty[] properties)
		{
			Request request = new Request();

			request.PolicyType = PolicyType.ClientEmail.ToString();
			request.DateTime = DateTime.Now;

			request.Properties = properties;

			RoutingEntity source = new RoutingEntity();
			request.Source = source;

			source.PolicyType = request.PolicyType;
			source.RoutingType = Workshare.PolicyContent.RoutingTypes.Source;
			source.Properties = new CustomProperty[] { new CustomProperty(SMTPPropertyKeys.RequestChannel, RequestChannel.Outlook) };

			PolicyContent.RoutingItem item = new PolicyContent.RoutingItem();
			item.Content = "*****@*****.**";

			item.Properties = new CustomProperty[] { new CustomProperty(SMTPItemPropertyKeys.DisplayName, "lnpair"), 
				new CustomProperty(SMTPItemPropertyKeys.AddressType, AddressType.From) };

			source.Items = new PolicyContent.RoutingItem[] { item };

			// Populate the destination routing entity
			RoutingEntity dest = new RoutingEntity();
			request.Destination = source;

			dest.PolicyType = request.PolicyType;
			dest.RoutingType = Workshare.PolicyContent.RoutingTypes.Destination;
			dest.Properties = new CustomProperty[] { new CustomProperty(SMTPPropertyKeys.RequestChannel, RequestChannel.Outlook) };

			item = new PolicyContent.RoutingItem();
			item.Content = "*****@*****.**";

			item.Properties = new CustomProperty[] { new CustomProperty(SMTPItemPropertyKeys.DisplayName, "lnpair"), 
				new CustomProperty(SMTPItemPropertyKeys.AddressType, AddressType.From) ,
				new CustomProperty(SMTPItemPropertyKeys.Internal, bool.FalseString)};


			dest.Items = new PolicyContent.RoutingItem[] { item };

			return request;
		}
		public void DisplayProgressOption()
		{
			OutlookHookWorker ohw = new OutlookHookWorker();
			Request request = new Request();
			
			bool bOriginalDisplayProgressOption = GetDisplayProgressOnMailSend();

			// if Professional isn't installed then the ConfigMgr calls will fail.
			if (SetDisplayProgressOnMailSend(false))
			{
				Assert.IsFalse(ohw.DisplayProgressOnMailSend(request), "Expected Progress display to be turned off.");

				SetDisplayProgressOnMailSend(bOriginalDisplayProgressOption);
			}
			else
			{
				Assert.IsTrue(ohw.DisplayProgressOnMailSend(request), "Expected Progress display to be turned on.");
			}
		}
Exemple #12
0
		public void Convert(RequestChannel requestChannel, Request request, bool ignoreRecipients)
		{
			request.PolicyType = PolicyType.ClientEmail.ToString();
			request.DateTime = DateTime.Now;

			List<CustomProperty> props = new List<CustomProperty>();
			props.Add(new CustomProperty(MailMessagePropertyKeys.FileHeader, string.Empty));
			props.Add(new CustomProperty(MailMessagePropertyKeys.Body, m_emailProxy.BodyText));
			props.Add(new CustomProperty(MailMessagePropertyKeys.FormattedBody, m_emailProxy.FormattedBodyText));
			props.Add(new CustomProperty(MailMessagePropertyKeys.Subject, m_emailProxy.Subject));
			props.Add(new CustomProperty(SMTPPropertyKeys.RequestChannel, requestChannel.ToString()));

			request.Properties = props.ToArray();

			if (null == request.Source)
				request.Source = new RoutingEntity();

			if (null == request.Destination)
				request.Destination = new RoutingEntity();

			request.Source.RoutingType = RoutingTypes.Source;
			request.Source.Properties = new CustomProperty[] { new CustomProperty(SMTPPropertyKeys.RequestChannel, requestChannel.ToString()) };
			request.Destination.RoutingType = RoutingTypes.Destination;
			request.Destination.Properties = new CustomProperty[] { new CustomProperty(SMTPPropertyKeys.RequestChannel, requestChannel.ToString()) };

			request.Source.Items = new Workshare.PolicyContent.RoutingItem[0];

			if (null == request.Destination.Items)
				request.Destination.Items = new Workshare.PolicyContent.RoutingItem[0];

			request.Source.PolicyType = request.Destination.PolicyType = request.PolicyType;

			ProcessSender(request);
			if (!ignoreRecipients)
			{
				ProcessToRecipients(request);
				ProcessCcRecipients(request);
				ProcessBccRecipients(request);
			}
			ProcessAttachments(request);
			ProcessHeaders(request);
			ProcessMimeContentProperty(request);
		}
		/// <summary>
		/// Helper method. Handles a request, creating encryption objects for each encrypted attachment, and decrypting them
		/// </summary>
		/// <returns>
		/// Returns true if passwords were successfully entered and applied to all encrypted attachments.
		/// Returns false if the user cancelled, or any decryption failed.
		/// </returns>
		public bool DecryptRequestAttachments(Request request, IContentEncryptionUi ui)
		{
			if (request == null || request.Attachments == null)
			{
				return true;
			}

			for (int i = 0; i < request.Attachments.Length; i++)// So we can recreate FCS files on fly
			{
				Attachment attachment = request.Attachments[i];

                if (attachment.File is Workshare.FCS.Lite.Interface.File)
                    AddReadProtectedProperty(ref attachment, ((Workshare.FCS.Lite.Interface.File)(attachment.File)).ReadPasswordProtected);

				if (attachment.IgnoreForWorkshareActions)
				{
					continue;
				}

				DecryptResult decryptResult = DecryptAttachment(ref attachment, ui);
				if (decryptResult == DecryptResult.Cancel)
				{
					return false;	// cancel decrypting of attachments
				}

				if (decryptResult == DecryptResult.Skip)
				{
					AddSkipScanningProperty(ref attachment, true);
					_skippedFiles.Add(GetEncryptionMapUniqueID(attachment));
				}
				else if (IsZipFile(attachment))// Decrypt any items inside the (now itself decrypted) attachment
				{
					// The dummy variable is for the out parramater CancelSend. 
					// CancelSend is ignored here. It's used by ReencryptResponseAttachments.
					bool dummy;
					if (!ProcessContainerContents(attachment, ui, true, out dummy))
					{
						return false;
					}
				}
			}
			return true;	// all attachments decrypted or skipped
		}
Exemple #14
0
		private void ProcessAttachments(Request request)
		{
			DiscardOldAttachments(request);

			StringBuilder attachmentsPropString = new StringBuilder();

			foreach (IEmailAttachment attachment in m_emailProxy.Attachments)
			{
                // 13850 - CR:  00183826 - Quinn Emanuel Urquhart & Sullivan - Professional 7.00 FP3 - "Access to the Path ...... is denied" ...
                // When the document is opened from the inspector window, Word opens it as Read-Only, after closing Word 
                // trying to send the mail with the same attachment you just opened it is saved in Read-Only and subsequently we are unable to 
                // process the document.
                System.IO.File.SetAttributes(attachment.FileName, FileAttributes.Normal);
				attachmentsPropString.AppendFormat("{0} ", AddAttachment(request, attachment));
			}

			List<CustomProperty> props = new List<CustomProperty>(request.Properties);
			props.Add(new CustomProperty(MailMessagePropertyKeys.Attachments, attachmentsPropString.ToString()));
			request.Properties = props.ToArray();
		}
        public void GetDigestMissingSource()
        {
            Request request = new Request();

            List<CustomProperty> props = new List<CustomProperty>();

            props.Add(new CustomProperty("Subject", "This is a subject"));
            request.Properties = props.ToArray();

            request.Source = null; //Invalid, this should cause the throw

            try
            {
                string digest = new RequestDigestProvider().GetDigest(request);
            }
            catch (ArgumentException)
            {
                Assert.IsTrue(true, "Expecting method to throw this ArgumentException");
                return;
            }

            Assert.Fail("Should have thrown the ArgumentException");
        }
		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.");
		}
Exemple #17
0
		public Response Scan(Request request, string user, ProcessLevel level, RunAt runat)
		{
			Logger.LogDebug(Properties.Resources.LOG_SCAN_BEGIN);

			if (PolicyCache.Instance().IsCacheEmpty)
			{
				Logger.LogInfo(Properties.Resources.LOG_CATEGORY_NO_MATCHES);
				return null;
			}
						
			try
			{
				return HandleContentScanning(request, user, level, runat, SkipDiscovery, TotalAttachmentSize);
			}
			catch (Exception ex)
			{
				Logger.LogError(ex);
                return ErrorResponse(ex);
			}
			finally
			{
				Logger.LogDebug(Properties.Resources.LOG_SCAN_END);
			}
		}
        public void GetDigestRoutingItemIsCaseInsensitive()
        {
            Request request = new Request();

            List<CustomProperty> props = new List<CustomProperty>();

            props.Add(new CustomProperty("Subject", "This is a subject"));

            RoutingEntity sourceRouting = new RoutingEntity();

            RoutingItem item = new RoutingItem();
            item.Content = "*****@*****.**";
            sourceRouting.Items = new RoutingItem[] { item };
            request.Source = sourceRouting;
            request.Properties = props.ToArray();

            string digest1 = new RequestDigestProvider().GetDigest(request);

            request.Source.Items[0].Content = request.Source.Items[0].Content.ToUpperInvariant();

            string digest2 = new RequestDigestProvider().GetDigest(request);

            Assert.AreEqual(digest1,digest2);
        }
Exemple #19
0
		protected virtual EnforceResponse CallEnforcerForPreview(IProgressCallback callback, Request request, Response response)
		{
			return m_factory.CreateContentEnforcer(callback).Enforce(request, response);
		}
Exemple #20
0
		private void ProcessMimeContentProperty(Request request)
		{
			CustomProperty mimeProperty = new CustomProperty(MailMessagePropertyKeys.MimeContent, m_emailProxy.MimeContent);

			List<CustomProperty> props = new List<CustomProperty>(request.Properties);
			props.Add(mimeProperty);
			request.Properties = props.ToArray();
		}
Exemple #21
0
		private void ProcessHeaders(Request request)
		{
			CustomProperty priority = new CustomProperty(MailMessagePropertyKeys.xPriority, string.Empty);

			switch (m_emailProxy.Priority)
			{
			case Priority.High:
				priority.Value = "1";
				break;
			case Priority.Normal:
				priority.Value = "3";
				break;
			case Priority.Low:
				priority.Value = "5";
				break;
			default:
				break;
			}

			List<CustomProperty> props = new List<CustomProperty>(request.Properties);

			props.Add(priority);

			request.Properties = props.ToArray();
		}
Exemple #22
0
		private Workshare.PolicyContent.RoutingItem FindDestinationRoutingItem(Request request, Workshare.PolicyContent.RoutingItem routingItem)
		{
			foreach (Workshare.PolicyContent.RoutingItem destinationRoutingItem in request.Destination.Items)
			{
				if ((GetPropertyValue(SMTPItemPropertyKeys.DisplayName, destinationRoutingItem.Properties) == GetPropertyValue(SMTPItemPropertyKeys.DisplayName, routingItem.Properties)) &&
					(GetPropertyValue(SMTPItemPropertyKeys.AddressType, destinationRoutingItem.Properties) == GetPropertyValue(SMTPItemPropertyKeys.AddressType, routingItem.Properties)))
				{
					return destinationRoutingItem;
				}
			}

			return null;
		}
Exemple #23
0
		private void AddOrReplaceDestinationRoutingItem(Request request, Workshare.PolicyContent.RoutingItem routingItem)
		{
			Workshare.PolicyContent.RoutingItem destinationRoutingItem = FindDestinationRoutingItem(request, routingItem);

			if (null == destinationRoutingItem)
			{
				List<Workshare.PolicyContent.RoutingItem> existingItems = new List<Workshare.PolicyContent.RoutingItem>(request.Destination.Items);
				existingItems.Add(routingItem);
				request.Destination.Items = existingItems.ToArray();
			}
			else
			{
				string readOnlyValue = GetPropertyValue(EmailProperties.ReadOnlyKey, destinationRoutingItem.Properties);
				if (!string.IsNullOrEmpty(readOnlyValue))
				{
					if (System.Convert.ToBoolean(readOnlyValue, System.Globalization.CultureInfo.InvariantCulture))
						return;
				}

				if (!IsSmtpAddress(routingItem.Content))
					return;

				if (destinationRoutingItem.Content != routingItem.Content)
				{
					List<CustomProperty> props = new List<CustomProperty>(destinationRoutingItem.Properties);

					bool needToAddModified = true;
					foreach (CustomProperty prop in props)
					{
						if (0 == string.Compare(prop.Name, EmailProperties.ModifiedKey, StringComparison.InvariantCultureIgnoreCase))
						{
							needToAddModified = false;
							prop.Value = bool.TrueString;
						}
					}

					if (needToAddModified)
					{
						props.Add(new CustomProperty(EmailProperties.ModifiedKey, bool.TrueString));
					}

					routingItem.Properties = props.ToArray();

					List<Workshare.PolicyContent.RoutingItem> routingItems = new List<Workshare.PolicyContent.RoutingItem>(request.Destination.Items);

					routingItems.Remove(destinationRoutingItem);
					routingItems.Add(routingItem);

					request.Destination.Items = routingItems.ToArray();
				}
			}
		}
Exemple #24
0
		private void ProcessRecipient(Request request, IEmailRecipient recipient, string addressType)
		{
			Workshare.PolicyContent.RoutingItem routingItem = new Workshare.PolicyContent.RoutingItem();
			routingItem.Content = recipient.EmailAddress;

			CustomProperty displayName = new CustomProperty(SMTPItemPropertyKeys.DisplayName, recipient.Name.Trim());
			CustomProperty addressTypeProp = new CustomProperty(SMTPItemPropertyKeys.AddressType, addressType);
			CustomProperty internalFlag = new CustomProperty(SMTPItemPropertyKeys.Internal, recipient.Internal.ToString());
			CustomProperty modified = new CustomProperty(EmailProperties.ModifiedKey, bool.FalseString);

			routingItem.Properties = new CustomProperty[] { displayName, addressTypeProp, internalFlag, modified };

			AddReadOnlyAttribute(routingItem);

			AddOrReplaceDestinationRoutingItem(request, routingItem);
		}
Exemple #25
0
		private void ProcessBccRecipients(Request request)
		{
			foreach (IEmailRecipient recipient in m_emailProxy.BccRecipients)
			{
				ProcessRecipient(request, recipient, AddressType.BCC);
			}
		}
Exemple #26
0
		private void ProcessSender(Request request)
		{
			string senderAddress = m_emailProxy.Sender.EmailAddress;
			string senderName = m_emailProxy.Sender.Name;

			Workshare.PolicyContent.RoutingItem routingItem = new Workshare.PolicyContent.RoutingItem();
			routingItem.Content = senderAddress;

			CustomProperty displayName = new CustomProperty(SMTPItemPropertyKeys.DisplayName, senderName);
			CustomProperty addressType = new CustomProperty(SMTPItemPropertyKeys.AddressType, AddressType.From);
			CustomProperty internalFlag = new CustomProperty(SMTPItemPropertyKeys.Internal, m_emailProxy.Sender.Internal.ToString());

			routingItem.Properties = new CustomProperty[] { displayName, addressType, internalFlag };

			request.Source.Items = new Workshare.PolicyContent.RoutingItem[] { routingItem };
		}
Exemple #27
0
		private void DiscardOldAttachments(Request request)
		{
			request.Attachments = new Attachment[0];
		}
Exemple #28
0
		private string AddAttachment(Request request, IEmailAttachment attachment)
		{
            string contentType = MimeAttachmentsProxy.GetContentType(attachment);
			string attachmentName = attachment.DisplayName;

            // 14781 - CR:  00180301 Professional 7.00 FP3 - Rodyk -  Illegal Characters in Path error sending MSG attachments
            var invalidFileNameCharacters = Path.GetInvalidFileNameChars();
		    if (attachmentName.IndexOfAny(invalidFileNameCharacters) == -1)
		    {
		        // Hack alert. TFS6626 - customer with 'Lawsoft' which creates dodgy .msg files that have the DisplayName field of the attachment set wrongly
		        // the DisplayName is missing the '.' separating the name and the extension. We work around this for now
		        if (string.IsNullOrEmpty(Path.GetExtension(attachmentName)) &&
		            !string.IsNullOrEmpty(Path.GetExtension(attachment.FileName)))
		        {
		            // do we have a display name with no extension and a file name with an extension
		            // there must be a '.' in the filename, since it has an extension.
		            // now test to see if we remove the '.' separating the extension, does the filename end with the attachment name
		            if (attachment.FileName.Remove(attachment.FileName.LastIndexOf('.'), 1).EndsWith(attachmentName))
		            {
		                // yep, so we have FileName = 'c:\blah\blah\test.docx' and display name = 'testdocx'
		                // which isn't good - as we check for profiles to display based on the extension (which would be blank)
		                // and we re-instate only the displayname of the attachment, not the file name
		                // so we will get the corrected display name from the filename
		                attachmentName = Path.GetFileName(attachment.FileName);
		            }
		        }
		    }
		    string contentId = attachment.ContentId;
			string index = attachment.ContentItemIndex.ToString(CultureInfo.InvariantCulture);

			if (string.IsNullOrEmpty(contentId))
				contentId = Guid.NewGuid().ToString();


			IFile file = new File(attachment.FileName, attachmentName);
			Attachment requestAttachment = new Attachment(file, contentType, contentId, index, false);
		    requestAttachment.IsSignature = attachment.IsSignature;

			if (attachment.IsSignature)
			{
				requestAttachment.IgnoreForWorkshareActions = true;
			}

			CustomProperty prop = new CustomProperty(PropertyNames.LocalFileName, attachment.FileName);

			if (attachment.RecordKey != null)
			{
				string recordkey =  attachment.RecordKey;
				CustomProperty prop2 = new CustomProperty(PropertyNames.RecordKey, recordkey);
				requestAttachment.Properties = new CustomProperty[] { prop, prop2 };
			}
			else
			{
				requestAttachment.Properties = new CustomProperty[] { prop };
			}

			List<Attachment> attachments = new List<Attachment>(request.Attachments);
			attachments.Add(requestAttachment);
			request.Attachments = attachments.ToArray();

			return attachmentName;
		}
Exemple #29
0
		/// <summary>
		/// Handles an exception thrown during enforcement. Creates a new EnforceResponse containing the exception details
		/// </summary>
		private EnforceResponse HandleException(Exception ex, Request request, string exceptionHandling)
		{
			Logger.LogError("Request manager detected exception in enforcement");
			Logger.LogError(ex);
			EnforceResponse original = new EnforceResponse();

			List<CustomProperty> properties = new List<CustomProperty>();

			properties.Add(new CustomProperty("Error.Message", ex.Message));
			properties.Add(new CustomProperty("Error.Stack", ex.StackTrace));
			properties.Add(new CustomProperty("Error.Result", exceptionHandling));

			if (exceptionHandling == "Abort")
			{
				properties.Add(new CustomProperty("ABORT", "true"));
			}

			original.Properties = properties.ToArray();
			original.ModifiedRequest = request;

			StringBuilder sb = new StringBuilder(Resources.CRITICAL_EXCEPTION);
			sb.Append(' ');
			sb.Append(Resources.CONTACT_SYSTEM_ADMIN);

			m_errors.Add(sb.ToString());
			m_exceptions.Add(ex);

			return original;
		}
Exemple #30
0
		protected Request CreateRequestForPreview(string ID)
		{
			Request request = new Request();
			foreach (Attachment a in m_request.Attachments)
			{
				if (a.Id == ID)
				{
					// make a temp copy via local file manager
					string filename = CreateATempFilename(Path.GetFileName(a.FileName));
					File.Copy(a.FileName, filename);
					request.Attachments = new Attachment[1] { new Attachment(new Engine.File(filename, a.Name), a.ContentType, a.Id, a.Index, false) };
					break;
				}
			}
			request.DateTime = m_request.DateTime;
			request.Destination = m_request.Destination;
			request.PolicyType = m_request.PolicyType;
			request.Properties = m_request.Properties;
			request.Source = m_request.Source;
			return request;
		}