// Token: 0x06001567 RID: 5479 RVA: 0x0007DF30 File Offset: 0x0007C130 protected MessageItem GetRightsManagedReplyForward(MessageItem smartReply, SendMailBase.IrmAction irmAction, RmsTemplate rmsTemplate) { if (smartReply == null) { throw new ArgumentNullException("smartReply"); } if (irmAction != SendMailBase.IrmAction.CreateNewPublishingLicense && irmAction != SendMailBase.IrmAction.CreateNewPublishingLicenseInlineOriginalBody && irmAction != SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Unexpected irmAction value: {0}", new object[] { irmAction })); } RightsManagedMessageItem rightsManagedMessageItem = smartReply as RightsManagedMessageItem; if (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseInlineOriginalBody) { rightsManagedMessageItem.SetRestriction(rmsTemplate); } else if (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicense || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) { rightsManagedMessageItem = RightsManagedMessageItem.Create(smartReply, AirSyncUtility.GetOutboundConversionOptions()); rightsManagedMessageItem.SetRestriction(rmsTemplate); rightsManagedMessageItem.Sender = new Participant(base.MailboxSession.MailboxOwner); } return(rightsManagedMessageItem); }
// Token: 0x06001589 RID: 5513 RVA: 0x0007F070 File Offset: 0x0007D270 internal override Command.ExecutionState ExecuteCommand() { MessageItem clientMessage = null; Item item = null; MessageItem messageItem = null; VersionedId versionedId = null; CalendarItemBase calendarItemBase = null; try { base.ValidateBody(); StoreObjectId defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Drafts); clientMessage = MessageItem.Create(base.MailboxSession, defaultFolderId); base.ParseMimeToMessage(clientMessage); clientMessage.Save(SaveMode.NoConflictResolution); clientMessage.Load(); versionedId = clientMessage.Id; clientMessage.Dispose(); clientMessage = MessageItem.Bind(base.MailboxSession, versionedId); item = base.GetSmartItem(); RmsTemplate rmsTemplate = null; bool isReplyAll = false; SendMailBase.IrmAction irmAction = base.GetIrmAction(delegate(RightsManagedMessageItem originalRightsManagedItem) { if (originalRightsManagedItem == null) { throw new ArgumentNullException("originalRightsManagedItem"); } isReplyAll = this.IsIrmReplyAll(originalRightsManagedItem, clientMessage); }, ref item, out rmsTemplate); Microsoft.Exchange.Data.Storage.BodyFormat bodyFormat = clientMessage.Body.Format; MeetingMessage meetingMessage = item as MeetingMessage; string text; if ((base.ReplaceMime || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) && meetingMessage != null && !meetingMessage.IsDelegated() && (meetingMessage is MeetingCancellation || meetingMessage is MeetingRequest)) { text = string.Empty; } else { using (TextReader textReader = clientMessage.Body.OpenTextReader(bodyFormat)) { text = textReader.ReadToEnd(); } Body body = (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseInlineOriginalBody || irmAction == SendMailBase.IrmAction.ReusePublishingLicenseInlineOriginalBody) ? ((RightsManagedMessageItem)item).ProtectedBody : item.Body; if (body.Format == Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml) { if (bodyFormat == Microsoft.Exchange.Data.Storage.BodyFormat.TextPlain) { XmlDocument xmlDocument = new SafeXmlDocument(); XmlNode xmlNode = xmlDocument.CreateElement("PRE"); XmlAttribute xmlAttribute = xmlDocument.CreateAttribute("STYLE"); xmlAttribute.Value = "word-wrap:break-word; font-size:10.0pt; font-family:Tahoma; color:black"; xmlNode.Attributes.Append(xmlAttribute); xmlNode.InnerText = text; text = xmlNode.OuterXml; } bodyFormat = Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml; } } ReplyForwardConfiguration replyForwardConfiguration = new ReplyForwardConfiguration(bodyFormat); replyForwardConfiguration.ConversionOptionsForSmime = AirSyncUtility.GetInboundConversionOptions(); replyForwardConfiguration.AddBodyPrefix(text); if (item is MessageItem) { MessageItem messageItem2 = (MessageItem)item; if (!messageItem2.IsReplyAllowed) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ReplyNotAllowed"); AirSyncPermanentException ex = new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MessageReplyNotAllowed, null, false); throw ex; } if (isReplyAll) { messageItem = messageItem2.CreateReplyAll(defaultFolderId, replyForwardConfiguration); } else { messageItem = messageItem2.CreateReply(defaultFolderId, replyForwardConfiguration); } if (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicense || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseInlineOriginalBody || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) { messageItem = base.GetRightsManagedReplyForward(messageItem, irmAction, rmsTemplate); } } else if (item is CalendarItem) { CalendarItem item2 = (CalendarItem)item; calendarItemBase = base.GetCalendarItemBaseToReplyOrForward(item2); messageItem = calendarItemBase.CreateReply(defaultFolderId, replyForwardConfiguration); } if (messageItem == null) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ReplyFailed"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MailSubmissionFailed, null, false); } base.CopyMessageContents(clientMessage, messageItem, true, (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) ? item : null); base.SendMessage(messageItem); } finally { if (clientMessage != null) { if (versionedId != null) { base.MailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[] { versionedId }); } clientMessage.Dispose(); } if (item != null) { item.Dispose(); } if (messageItem != null) { messageItem.Dispose(); } if (calendarItemBase != null) { calendarItemBase.Dispose(); } } return(Command.ExecutionState.Complete); }
private Command.ExecutionState ForwardUsingXso(StoreObjectId smartId) { Item smartItem = base.GetSmartItem(smartId); MessageItem messageItem = null; VersionedId versionedId = null; MessageItem messageItem2 = null; CalendarItemBase calendarItemBase = null; try { StoreObjectId defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Drafts); messageItem = MessageItem.Create(base.MailboxSession, defaultFolderId); base.ParseMimeToMessage(messageItem); messageItem.Save(SaveMode.NoConflictResolution); messageItem.Load(); versionedId = messageItem.Id; messageItem.Dispose(); messageItem = MessageItem.Bind(base.MailboxSession, versionedId); RmsTemplate rmsTemplate = null; SendMailBase.IrmAction irmAction = base.GetIrmAction(delegate(RightsManagedMessageItem originalRightsManagedItem) { if (originalRightsManagedItem == null) { throw new ArgumentNullException("originalRightsManagedItem"); } if (!originalRightsManagedItem.UsageRights.IsUsageRightGranted(ContentRight.Forward)) { throw new AirSyncPermanentException(StatusCode.IRM_OperationNotPermitted, false) { ErrorStringForProtocolLogger = "sfcEOperationNotPermitted" }; } }, ref smartItem, out rmsTemplate); Microsoft.Exchange.Data.Storage.BodyFormat bodyFormat = messageItem.Body.Format; MeetingMessage meetingMessage = smartItem as MeetingMessage; string text; if ((base.ReplaceMime || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) && meetingMessage != null && !meetingMessage.IsDelegated() && (meetingMessage is MeetingRequest || meetingMessage is MeetingCancellation)) { text = string.Empty; } else { using (TextReader textReader = messageItem.Body.OpenTextReader(bodyFormat)) { text = textReader.ReadToEnd(); } Body body = (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseInlineOriginalBody || irmAction == SendMailBase.IrmAction.ReusePublishingLicenseInlineOriginalBody) ? ((RightsManagedMessageItem)smartItem).ProtectedBody : smartItem.Body; if (body.Format == Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml) { if (bodyFormat == Microsoft.Exchange.Data.Storage.BodyFormat.TextPlain) { XmlDocument xmlDocument = new SafeXmlDocument(); XmlNode xmlNode = xmlDocument.CreateElement("PRE"); XmlAttribute xmlAttribute = xmlDocument.CreateAttribute("STYLE"); xmlAttribute.Value = "word-wrap:break-word; font-size:10.0pt; font-family:Tahoma; color:black"; xmlNode.Attributes.Append(xmlAttribute); xmlNode.InnerText = text; text = xmlNode.OuterXml; } bodyFormat = Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml; } } ReplyForwardConfiguration replyForwardConfiguration = new ReplyForwardConfiguration(bodyFormat); replyForwardConfiguration.ConversionOptionsForSmime = AirSyncUtility.GetInboundConversionOptions(); replyForwardConfiguration.AddBodyPrefix(text); if (base.Version >= 120) { if (smartItem is MessageItem) { messageItem2 = ((MessageItem)smartItem).CreateForward(defaultFolderId, replyForwardConfiguration); if (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicense || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseInlineOriginalBody || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) { messageItem2 = base.GetRightsManagedReplyForward(messageItem2, irmAction, rmsTemplate); } } else if (smartItem is CalendarItem) { CalendarItem calendarItem = (CalendarItem)smartItem; calendarItemBase = base.GetCalendarItemBaseToReplyOrForward(calendarItem); messageItem2 = calendarItemBase.CreateForward(defaultFolderId, replyForwardConfiguration); if (!calendarItem.IsMeeting) { BodyConversionUtilities.CopyBody(messageItem, messageItem2); } } if (messageItem2 == null) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ForwardFailed"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MailSubmissionFailed, null, false); } if (base.ReplaceMime || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) { RightsManagedMessageItem rightsManagedMessageItem = messageItem2 as RightsManagedMessageItem; if (rightsManagedMessageItem != null) { rightsManagedMessageItem.ProtectedAttachmentCollection.RemoveAll(); } else { messageItem2.AttachmentCollection.RemoveAll(); } } base.CopyMessageContents(messageItem, messageItem2, false, (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) ? smartItem : null); base.SendMessage(messageItem2); } else if (smartItem is MessageItem) { using (ItemAttachment itemAttachment = messageItem.AttachmentCollection.AddExistingItem(smartItem)) { MessageItem messageItem3 = (MessageItem)smartItem; itemAttachment.FileName = messageItem3.Subject + itemAttachment.FileExtension; itemAttachment.Save(); } base.SendMessage(messageItem); } else if (smartItem is CalendarItem) { CalendarItem calendarItem2 = (CalendarItem)smartItem; messageItem2 = calendarItem2.CreateForward(defaultFolderId, replyForwardConfiguration); if (messageItem2 == null) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ForwardFailed2"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MailSubmissionFailed, null, false); } if (!calendarItem2.IsMeeting) { BodyConversionUtilities.CopyBody(messageItem, messageItem2); } base.CopyMessageContents(messageItem, messageItem2, false, null); base.SendMessage(messageItem2); } } finally { if (messageItem != null) { if (versionedId != null) { base.MailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[] { versionedId }); } messageItem.Dispose(); } if (smartItem != null) { smartItem.Dispose(); } if (messageItem2 != null) { messageItem2.Dispose(); } if (calendarItemBase != null) { calendarItemBase.Dispose(); } } return(Command.ExecutionState.Complete); }
// Token: 0x06001568 RID: 5480 RVA: 0x0007DFC4 File Offset: 0x0007C1C4 protected SendMailBase.IrmAction GetIrmAction(SendMailBase.GetIrmActionCallback irmActionDelegate, ref Item smartItem, out RmsTemplate rmsTemplate) { if (irmActionDelegate == null) { throw new ArgumentNullException("irmActionDelegate"); } if (smartItem == null) { throw new ArgumentNullException("smartItem"); } SendMailBase.IrmAction irmAction = SendMailBase.IrmAction.None; rmsTemplate = null; Guid guid; if (this.IsIrmOperation(out guid)) { RightsManagedMessageItem rightsManagedMessageItem = smartItem as RightsManagedMessageItem; if (rightsManagedMessageItem != null) { if (!rightsManagedMessageItem.IsRestricted || !rightsManagedMessageItem.CanDecode) { AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, this, "Either the original IRM message was not properly formatted or it could not be decoded"); throw new AirSyncPermanentException(StatusCode.IRM_OperationNotPermitted, false) { ErrorStringForProtocolLogger = "smbGiaOperationNotPermitted" }; } rightsManagedMessageItem.Decode(AirSyncUtility.GetOutboundConversionOptions(), true); irmActionDelegate(rightsManagedMessageItem); irmAction = SendMailBase.GetIrmActionForReplyForward(rightsManagedMessageItem.UsageRights, this.ReplaceMime, rightsManagedMessageItem.Restriction.Id == guid); AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "GetIrmActionForReplyForward: originalMessageRights={0}; originalTemplate={1}; newTemplate={2}; irmAction={3}", new object[] { rightsManagedMessageItem.UsageRights, rightsManagedMessageItem.Restriction.Id, guid, irmAction }); if (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicense || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) { smartItem.Dispose(); smartItem = this.GetSmartItem(); } } else { irmAction = SendMailBase.IrmAction.CreateNewPublishingLicense; } if (irmAction == SendMailBase.IrmAction.None) { throw new InvalidOperationException("irmAction should not be None here."); } if (irmAction != SendMailBase.IrmAction.ReusePublishingLicense && irmAction != SendMailBase.IrmAction.ReusePublishingLicenseInlineOriginalBody && guid != Guid.Empty) { rmsTemplate = RmsTemplateReaderCache.LookupRmsTemplate(base.User.OrganizationId, guid); if (rmsTemplate == null) { AirSyncDiagnostics.TraceError <Guid>(ExTraceGlobals.RequestsTracer, this, "Template {0} not found in cache", guid); throw new AirSyncPermanentException(StatusCode.IRM_InvalidTemplateID, false) { ErrorStringForProtocolLogger = "smbGiaInvalidTemplateID" }; } } } if ((irmAction == SendMailBase.IrmAction.ReusePublishingLicense && !this.ReplaceMime) || ((irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseInlineOriginalBody || irmAction == SendMailBase.IrmAction.ReusePublishingLicenseInlineOriginalBody || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) && this.ReplaceMime)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "irmAction = {0}, ReplaceMime = {1}", new object[] { irmAction, this.ReplaceMime })); } return(irmAction); }