private static void CopyMessageClassificationProperties(Item oldItem, Item newItem, UserContext userContext) { if (ReplyForwardUtilities.IsClassificationRetained(oldItem)) { string property = ItemUtility.GetProperty <string>(oldItem, ItemSchema.ClassificationGuid, string.Empty); if (!string.IsNullOrEmpty(property)) { Guid empty = Guid.Empty; if (GuidHelper.TryParseGuid(property, out empty) && userContext.ComplianceReader.MessageClassificationReader.LookupMessageClassification(empty, CultureInfo.CurrentUICulture) != null) { newItem[ItemSchema.ClassificationGuid] = property; bool property2 = ItemUtility.GetProperty <bool>(oldItem, ItemSchema.IsClassified, false); newItem[ItemSchema.IsClassified] = property2; newItem[ItemSchema.Classification] = ItemUtility.GetProperty <string>(oldItem, ItemSchema.Classification, string.Empty); newItem[ItemSchema.ClassificationDescription] = ItemUtility.GetProperty <string>(oldItem, ItemSchema.ClassificationDescription, string.Empty); newItem[ItemSchema.ClassificationKeep] = ItemUtility.GetProperty <bool>(oldItem, ItemSchema.ClassificationKeep, false); } } } }
public static MessageItem CreateForwardMessageWithItemAttached(Item itemToAttach, UserContext userContext) { MessageItem messageItem = MessageItem.Create(userContext.MailboxSession, userContext.DraftsFolderId); messageItem[ItemSchema.ConversationIndexTracking] = true; string property; if (itemToAttach is Contact) { property = ItemUtility.GetProperty <string>(itemToAttach, StoreObjectSchema.DisplayName, string.Empty); } else if (itemToAttach is DistributionList) { property = ItemUtility.GetProperty <string>(itemToAttach, StoreObjectSchema.DisplayName, string.Empty); } else { property = ItemUtility.GetProperty <string>(itemToAttach, ItemSchema.Subject, string.Empty); } if (property.Length <= 255) { messageItem[ItemSchema.Subject] = property; } else { messageItem[ItemSchema.Subject] = property.Substring(0, 255); } using (ItemAttachment itemAttachment = messageItem.AttachmentCollection.AddExistingItem(itemToAttach)) { itemAttachment.Save(); } if (Globals.ArePerfCountersEnabled) { OwaSingleCounters.ItemsCreated.Increment(); } return(messageItem); }
private static bool IsClassificationRetained(Item item) { return(ItemUtility.GetProperty <bool>(item, ItemSchema.ClassificationKeep, false)); }
private static bool HasRight(Item item, EffectiveRights effectiveRightToCheck) { EffectiveRights property = ItemUtility.GetProperty <EffectiveRights>(item, StoreObjectSchema.EffectiveRights, EffectiveRights.None); return((property & effectiveRightToCheck) == effectiveRightToCheck); }
public static bool HasDeletePolicy(IStorePropertyBag storePropertyBag) { byte[] property = ItemUtility.GetProperty <byte[]>(storePropertyBag, StoreObjectSchema.PolicyTag, null); return(property != null); }
private bool BindItemAndShowDialog(StoreObjectId itemId, string type, StringWriter writer) { MessageItem messageItem = null; bool result; try { messageItem = Item.BindAsMessage(this.mailboxSession, itemId); if (messageItem != null) { string text = ItemUtility.GetProperty <string>(messageItem, StoreObjectSchema.ItemClass, null); if (text == null) { text = "IPM.Note"; } string property = ItemUtility.GetProperty <string>(messageItem, StoreObjectSchema.ContentClass, string.Empty); if (ObjectClass.IsOfClass(property, "rpmsg.message")) { text += ".irm"; } writer.Write("shwNwItmDlg(\""); if (messageItem.From != null && messageItem.From.DisplayName != null) { Utilities.JavascriptEncode(Utilities.HtmlEncode(messageItem.From.DisplayName), writer); } writer.Write("\",\""); if (messageItem.Subject != null) { Utilities.JavascriptEncode(Utilities.HtmlEncode(messageItem.Subject), writer); } writer.Write("\",\"" + type + "\",\""); using (StringWriter stringWriter = new StringWriter()) { SmallIconManager.RenderItemIcon(stringWriter, this.userContext, text, false, "nwItmImg", new string[0]); Utilities.JavascriptEncode(stringWriter.ToString(), writer); } writer.Write("\");"); } result = true; } catch (ObjectNotFoundException) { if (type != null) { if (!(type == "lnkNwMl")) { if (!(type == "lnkNwVMl")) { if (type == "lnkNwFx") { writer.Write("shwNF(0);"); } } else { writer.Write("shwNVM(0);"); } } else { writer.Write("shwNM(0);"); } } result = false; } finally { if (messageItem != null) { messageItem.Dispose(); } } return(result); }
private Stream LoadAttachmentDocument(bool isLoadingStream, out RightsManagedMessageDecryptionStatus decryptionStatus) { decryptionStatus = RightsManagedMessageDecryptionStatus.Success; StringBuilder stringBuilder = new StringBuilder(); List <AttachmentId> list = new List <AttachmentId>(); UserContext userContext = this.owaContext.UserContext; string queryStringParameter = Utilities.GetQueryStringParameter(this.owaContext.HttpContext.Request, "ewsid", false); bool flag = string.IsNullOrEmpty(queryStringParameter); OwaStoreObjectId owaStoreObjectId; string text; if (!flag) { stringBuilder.Append("service.svc/s/GetFileAttachment?id="); stringBuilder.Append(Utilities.UrlEncode(queryStringParameter)); string canary15CookieValue = Utilities.GetCanary15CookieValue(); if (canary15CookieValue != null) { stringBuilder.Append("&X-OWA-CANARY=" + canary15CookieValue); } IdHeaderInformation idHeaderInformation = ServiceIdConverter.ConvertFromConcatenatedId(queryStringParameter, BasicTypes.Attachment, list); owaStoreObjectId = OwaStoreObjectId.CreateFromMailboxItemId(idHeaderInformation.ToStoreObjectId()); text = owaStoreObjectId.ToString(); } else { text = Utilities.GetQueryStringParameter(this.owaContext.HttpContext.Request, "id"); owaStoreObjectId = OwaStoreObjectId.CreateFromString(text); stringBuilder.Append("attachment.ashx?attach=1&id="); stringBuilder.Append(Utilities.UrlEncode(text)); } Stream result; using (Item item = Utilities.GetItem <Item>(userContext, owaStoreObjectId, new PropertyDefinition[] { ItemSchema.SentRepresentingDisplayName, ItemSchema.Subject })) { if (!Utilities.IsPublic(item) && userContext.IsIrmEnabled && isLoadingStream) { item.OpenAsReadWrite(); } if (Utilities.IsIrmRestricted(item)) { if (!userContext.IsIrmEnabled || userContext.IsBasicExperience) { decryptionStatus = RightsManagedMessageDecryptionStatus.FeatureDisabled; return(null); } RightsManagedMessageItem rightsManagedMessageItem = (RightsManagedMessageItem)item; if (!rightsManagedMessageItem.CanDecode) { decryptionStatus = RightsManagedMessageDecryptionStatus.NotSupported; return(null); } try { Utilities.IrmDecryptIfRestricted(item, userContext, true); } catch (RightsManagementPermanentException exception) { decryptionStatus = RightsManagedMessageDecryptionStatus.CreateFromException(exception); return(null); } catch (RightsManagementTransientException exception2) { decryptionStatus = RightsManagedMessageDecryptionStatus.CreateFromException(exception2); return(null); } } this.messageFrom = ItemUtility.GetProperty <string>(item, ItemSchema.SentRepresentingDisplayName, string.Empty); this.messageSubject = ItemUtility.GetProperty <string>(item, ItemSchema.Subject, string.Empty); this.messageId = text; if (flag) { Utilities.FillAttachmentIdList(item, this.owaContext.HttpContext.Request, list); } using (StreamAttachment streamAttachment = Utilities.GetAttachment(item, list, userContext) as StreamAttachment) { if (streamAttachment == null) { throw new OwaInvalidRequestException("Attachment is not a stream attachment"); } this.mimeType = (streamAttachment.ContentType ?? streamAttachment.CalculatedContentType); this.fileName = ((!string.IsNullOrEmpty(streamAttachment.DisplayName)) ? streamAttachment.DisplayName : streamAttachment.FileName); this.fileSize = streamAttachment.Size; this.documentPath = this.fileName; this.documentIdStringBuilder.Append(Convert.ToBase64String(userContext.MailboxSession.MailboxOwner.MailboxInfo.GetDatabaseGuid().ToByteArray())); this.documentIdStringBuilder.Append("-"); for (int i = 0; i < list.Count; i++) { this.documentIdStringBuilder.Append(list[i].ToBase64String()); this.documentIdStringBuilder.Append("-"); if (flag) { stringBuilder.Append("&attid"); stringBuilder.Append(i.ToString(CultureInfo.InstalledUICulture)); stringBuilder.Append("="); stringBuilder.Append(Utilities.UrlEncode(list[i].ToBase64String())); } } if (flag) { stringBuilder.Append("&attcnt="); stringBuilder.Append(list.Count); } this.documentIdStringBuilder.Append(streamAttachment.LastModifiedTime.UtcTicks); this.openLink = stringBuilder.ToString(); if (isLoadingStream) { Stream contentStream = streamAttachment.GetContentStream(); MsoIpiResult msoIpiResult = MsoIpiResult.Unknown; try { msoIpiResult = ProtectorsManager.Instance.IsProtected(this.fileName, contentStream); } catch (AttachmentProtectionException exception3) { decryptionStatus = new RightsManagedMessageDecryptionStatus(RightsManagementFailureCode.CorruptData, exception3); return(null); } if (msoIpiResult == MsoIpiResult.Protected) { this.isIrmProtected = true; contentStream.Dispose(); if (!userContext.IsIrmEnabled || userContext.IsBasicExperience) { decryptionStatus = RightsManagedMessageDecryptionStatus.FeatureDisabled; result = null; } else { UseLicenseAndUsageRights useLicenseAndUsageRights; bool flag2; Stream stream; try { stream = StreamAttachment.OpenRestrictedAttachment(streamAttachment, this.owaContext.ExchangePrincipal.MailboxInfo.OrganizationId, this.owaContext.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), this.owaContext.LogonIdentity.UserSid, this.owaContext.ExchangePrincipal.RecipientTypeDetails, out useLicenseAndUsageRights, out flag2); } catch (RightsManagementPermanentException exception4) { decryptionStatus = RightsManagedMessageDecryptionStatus.CreateFromException(exception4); return(null); } catch (RightsManagementTransientException exception5) { decryptionStatus = RightsManagedMessageDecryptionStatus.CreateFromException(exception5); return(null); } if (flag2 && ObjectClass.IsMessage(item.ClassName, false) && !Utilities.IsIrmRestricted(item)) { object obj = item.TryGetProperty(MessageItemSchema.IsDraft); if (obj is bool && !(bool)obj && !DrmClientUtils.IsCachingOfLicenseDisabled(useLicenseAndUsageRights.UseLicense)) { streamAttachment[AttachmentSchema.DRMRights] = useLicenseAndUsageRights.UsageRights; streamAttachment[AttachmentSchema.DRMExpiryTime] = useLicenseAndUsageRights.ExpiryTime; using (Stream stream2 = streamAttachment.OpenPropertyStream(AttachmentSchema.DRMServerLicenseCompressed, PropertyOpenMode.Create)) { DrmEmailCompression.CompressUseLicense(useLicenseAndUsageRights.UseLicense, stream2); } streamAttachment[AttachmentSchema.DRMPropsSignature] = useLicenseAndUsageRights.DRMPropsSignature; streamAttachment.Save(); item.Save(SaveMode.ResolveConflicts); } } string conversationOwnerFromPublishLicense = DrmClientUtils.GetConversationOwnerFromPublishLicense(useLicenseAndUsageRights.PublishingLicense); RmsTemplate rmsTemplate = RmsTemplate.CreateFromPublishLicense(useLicenseAndUsageRights.PublishingLicense); this.isPrintRestricted = !useLicenseAndUsageRights.UsageRights.IsUsageRightGranted(ContentRight.Print); this.isCopyRestricted = !useLicenseAndUsageRights.UsageRights.IsUsageRightGranted(ContentRight.Extract); SanitizingStringBuilder <OwaHtml> sanitizingStringBuilder = new SanitizingStringBuilder <OwaHtml>(); string str = string.Format(LocalizedStrings.GetNonEncoded(-500320626), rmsTemplate.Name, rmsTemplate.Description); sanitizingStringBuilder.Append(str); if (!string.IsNullOrEmpty(conversationOwnerFromPublishLicense)) { sanitizingStringBuilder.Append("<br>"); sanitizingStringBuilder.Append(string.Format(LocalizedStrings.GetNonEncoded(1670455506), conversationOwnerFromPublishLicense)); } this.irmInfobarMessage = sanitizingStringBuilder.ToSanitizedString <SanitizedHtmlString>(); result = stream; } } else { contentStream.Seek(0L, SeekOrigin.Begin); result = contentStream; } } else { result = null; } } } return(result); }