// 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: 0x06001575 RID: 5493 RVA: 0x0007E438 File Offset: 0x0007C638
        internal override Command.ExecutionState ExecuteCommand()
        {
            MessageItem     messageItem     = null;
            bool            flag            = false;
            DeleteItemFlags deletedItemFlag = DeleteItemFlags.HardDelete;

            try
            {
                base.ValidateBody();
                StoreObjectId defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Drafts);
                messageItem = MessageItem.Create(base.MailboxSession, defaultFolderId);
                base.ParseMimeToMessage(messageItem);
                Guid guid;
                if (base.IsIrmOperation(out guid))
                {
                    RmsTemplate 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 = "smcEInvalidTemplateID"
                              };
                    }
                    messageItem = RightsManagedMessageItem.Create(messageItem, AirSyncUtility.GetOutboundConversionOptions());
                    RightsManagedMessageItem rightsManagedMessageItem = messageItem as RightsManagedMessageItem;
                    rightsManagedMessageItem.SetRestriction(rmsTemplate);
                    rightsManagedMessageItem.Sender = new Participant(base.MailboxSession.MailboxOwner);
                }
                Command.CurrentCommand.ProtocolLogger.SetValue(ProtocolLoggerData.ClassName, messageItem.ClassName);
                if (!GlobalSettings.OnlyOrganizersCanSendMeetingChanges || !this.IsMeetingRelatedMessage(messageItem))
                {
                    base.SendMessage(messageItem);
                    flag = true;
                }
                else
                {
                    bool flag2 = this.CanSendMessage(messageItem);
                    if (GlobalSettings.GetGoidFromCalendarItemForMeetingResponse && base.Version < 160 && this.IsResponseMessageToSingleMeeting(messageItem))
                    {
                        GlobalObjectId goidFromItem = this.GetGoidFromItem(messageItem);
                        try
                        {
                            ResponseType       valueOrDefault    = messageItem.GetValueOrDefault <ResponseType>(MeetingResponseSchema.ResponseType);
                            DefaultFolderType  defaultFolderType = (valueOrDefault == ResponseType.Decline) ? DefaultFolderType.DeletedItems : DefaultFolderType.Calendar;
                            List <PropertyBag> list = this.QueryRelatedCalendarItems(defaultFolderType, goidFromItem);
                            if (list.Count == 0 && valueOrDefault == ResponseType.Decline)
                            {
                                list = this.QueryRelatedCalendarItems(DefaultFolderType.Calendar, goidFromItem);
                                if (list.Count == 0)
                                {
                                    list = this.QueryRelatedCalendarItems(DefaultFolderType.DeletedItems, goidFromItem);
                                }
                            }
                            this.FindAndSetMessageGoid(list, messageItem, goidFromItem);
                        }
                        catch (Exception ex)
                        {
                            AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.RequestsTracer, this, "GetRelatedCalendarItemGoid threw exception {0}", ex);
                            AirSyncDiagnostics.SendInMemoryTraceWatson(ex);
                        }
                    }
                    if (flag2)
                    {
                        base.SendMessage(messageItem);
                        flag = true;
                    }
                    else
                    {
                        AirSyncDiagnostics.TraceDebug <Participant>(ExTraceGlobals.RequestsTracer, this, "Attempt to send meeting cancellation by attendee. Sender {0}", messageItem.Sender);
                        messageItem.ClassName = "IPM.Note";
                        messageItem.Save(SaveMode.NoConflictResolution);
                        deletedItemFlag = DeleteItemFlags.MoveToDeletedItems;
                        Command.CurrentCommand.ProtocolLogger.SetValue(ProtocolLoggerData.SkipSend, true.ToString());
                    }
                }
            }
            finally
            {
                if (messageItem != null)
                {
                    if (!flag)
                    {
                        base.DeleteMessage(messageItem, deletedItemFlag);
                    }
                    messageItem.Dispose();
                }
            }
            return(Command.ExecutionState.Complete);
        }
Beispiel #3
0
        // Token: 0x06000C4C RID: 3148 RVA: 0x00040FE8 File Offset: 0x0003F1E8
        private void IrmRemoveRestriction(Item item)
        {
            if (!Command.CurrentCommand.Context.User.IrmEnabled || !Command.CurrentCommand.Context.Request.IsSecureConnection)
            {
                AirSyncDiagnostics.TraceError <string, bool, bool>(ExTraceGlobals.RequestsTracer, null, "User {0} is not IrmEnabled or the client access server is not IrmEnabled or request received over non SSL. IrmEnabled: {1}, SSLConnection: {2}.", Command.CurrentCommand.Context.User.DisplayName, Command.CurrentCommand.Context.User.IrmEnabled, Command.CurrentCommand.Context.Request.IsSecureConnection);
                throw new AirSyncPermanentException(StatusCode.IRM_FeatureDisabled, false)
                      {
                          ErrorStringForProtocolLogger = "RemoveRestrictionFeatureDisabled"
                      };
            }
            if (AirSyncUtility.IsProtectedVoicemailItem(item))
            {
                AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, null, "User {0} called remove restrictions on protected voice mail - not supported", Command.CurrentCommand.Context.User.DisplayName);
                throw new AirSyncPermanentException(StatusCode.IRM_OperationNotPermitted, false)
                      {
                          ErrorStringForProtocolLogger = "RemoveRestrictionOnProtectedVoicemail"
                      };
            }
            RightsManagedMessageItem rightsManagedMessageItem = item as RightsManagedMessageItem;

            if (rightsManagedMessageItem == null)
            {
                AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, null, "User {0} called remove restrictions on non IRM message", Command.CurrentCommand.Context.User.DisplayName);
                throw new AirSyncPermanentException(StatusCode.IRM_OperationNotPermitted, false)
                      {
                          ErrorStringForProtocolLogger = "RemoveRestrictionOnNonIRMMessage"
                      };
            }
            rightsManagedMessageItem.OpenAsReadWrite();
            RightsManagedMessageDecryptionStatus rightsManagedMessageDecryptionStatus = RightsManagedMessageDecryptionStatus.Success;

            try
            {
                rightsManagedMessageItem.Decode(AirSyncUtility.GetOutboundConversionOptions(), true);
            }
            catch (RightsManagementPermanentException exception)
            {
                rightsManagedMessageDecryptionStatus = RightsManagedMessageDecryptionStatus.CreateFromException(exception);
            }
            catch (RightsManagementTransientException exception2)
            {
                rightsManagedMessageDecryptionStatus = RightsManagedMessageDecryptionStatus.CreateFromException(exception2);
            }
            if (rightsManagedMessageDecryptionStatus.Failed)
            {
                AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, null, "Failed to decode item : {0}", rightsManagedMessageDecryptionStatus.FailureCode.ToString());
                throw new AirSyncPermanentException(StatusCode.IRM_PermanentError, rightsManagedMessageDecryptionStatus.Exception, false)
                      {
                          ErrorStringForProtocolLogger = "RemoveRestrictionDecodeFailed"
                      };
            }
            try
            {
                rightsManagedMessageItem.SetRestriction(null);
            }
            catch (RightsManagementPermanentException ex)
            {
                if (ex.FailureCode == RightsManagementFailureCode.UserRightNotGranted)
                {
                    AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, null, "Failed to remove restrictions on item : {0}", ex.ToString());
                    throw new AirSyncPermanentException(StatusCode.IRM_OperationNotPermitted, ex, false)
                          {
                              ErrorStringForProtocolLogger = "RemoveRestrictionRightNotGranted"
                          };
                }
                throw;
            }
            ConflictResolutionResult conflictResolutionResult = rightsManagedMessageItem.Save(SaveMode.ResolveConflicts);

            if (conflictResolutionResult.SaveStatus == SaveResult.IrresolvableConflict)
            {
                AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, null, "Failed to remove restrictions on item because of conflicts");
                throw new AirSyncPermanentException(StatusCode.IRM_PermanentError, false)
                      {
                          ErrorStringForProtocolLogger = "RemoveRestrictionConflict"
                      };
            }
            item.Load();
        }