Exemplo n.º 1
0
 public static RmsTemplate LookupRmsTemplate(OrganizationId organizationId, Guid templateId)
 {
     foreach (RmsTemplate rmsTemplate in RmsTemplateReaderCache.GetRmsTemplates(organizationId))
     {
         if (rmsTemplate.Id == templateId)
         {
             return(rmsTemplate);
         }
     }
     return(null);
 }
        // 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);
        }
Exemplo n.º 3
0
 private void ProcessGet()
 {
     using (this.user.Context.Tracker.Start(TimeId.RMSProcessGet))
     {
         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Processing RightsManagementInformationSetting - Get");
         XmlNode xmlNode  = base.Response.OwnerDocument.CreateElement("Get", "Settings:");
         XmlNode xmlNode2 = base.Response.OwnerDocument.CreateElement("RightsManagementTemplates", "RightsManagement:");
         try
         {
             if (this.user.IrmEnabled)
             {
                 List <RmsTemplate>      list     = new List <RmsTemplate>(RmsTemplateReaderCache.GetRmsTemplates(this.user.OrganizationId));
                 IComparer <RmsTemplate> comparer = new RightsManagementInformationSetting.RmsTemplateNameComparer(this.cultureInfo);
                 list.Sort(comparer);
                 int count           = list.Count;
                 int maxRmsTemplates = GlobalSettings.MaxRmsTemplates;
                 if (count > maxRmsTemplates)
                 {
                     list.RemoveRange(maxRmsTemplates, count - maxRmsTemplates);
                 }
                 using (List <RmsTemplate> .Enumerator enumerator = list.GetEnumerator())
                 {
                     while (enumerator.MoveNext())
                     {
                         RmsTemplate rmsTemplate = enumerator.Current;
                         AirSyncDiagnostics.TraceInfo <Guid>(ExTraceGlobals.RequestsTracer, this, "Found RMS template {0}", rmsTemplate.Id);
                         XmlNode xmlNode3 = base.Response.OwnerDocument.CreateElement("RightsManagementTemplate", "RightsManagement:");
                         XmlNode xmlNode4 = base.Response.OwnerDocument.CreateElement("TemplateID", "RightsManagement:");
                         xmlNode4.InnerText = rmsTemplate.Id.ToString();
                         xmlNode3.AppendChild(xmlNode4);
                         XmlNode xmlNode5 = base.Response.OwnerDocument.CreateElement("TemplateName", "RightsManagement:");
                         xmlNode5.InnerText = rmsTemplate.GetName(this.cultureInfo);
                         xmlNode3.AppendChild(xmlNode5);
                         XmlNode xmlNode6 = base.Response.OwnerDocument.CreateElement("TemplateDescription", "RightsManagement:");
                         xmlNode6.InnerText = rmsTemplate.GetDescription(this.cultureInfo);
                         xmlNode3.AppendChild(xmlNode6);
                         xmlNode2.AppendChild(xmlNode3);
                     }
                     goto IL_205;
                 }
             }
             AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, this, "IRM feature disabled for user {0}", this.user.DisplayName);
             this.status = StatusCode.IRM_FeatureDisabled;
             IL_205 :;
         }
         catch (AirSyncPermanentException ex)
         {
             AirSyncDiagnostics.TraceError <AirSyncPermanentException>(ExTraceGlobals.RequestsTracer, this, "AirSyncPermanentException encountered while processing RightsManagementInformationSetting->Get {0}", ex);
             if (base.ProtocolLogger != null && !string.IsNullOrEmpty(ex.ErrorStringForProtocolLogger))
             {
                 base.ProtocolLogger.SetValueIfNotSet(ProtocolLoggerData.Error, ex.ErrorStringForProtocolLogger);
             }
             this.ProcessException(ex);
             this.status = ex.AirSyncStatusCode;
         }
         XmlNode xmlNode7 = base.Response.OwnerDocument.CreateElement("Status", "Settings:");
         XmlNode xmlNode8 = xmlNode7;
         int     num      = (int)this.status;
         xmlNode8.InnerText = num.ToString(CultureInfo.InvariantCulture);
         base.Response.AppendChild(xmlNode7);
         xmlNode.AppendChild(xmlNode2);
         base.Response.AppendChild(xmlNode);
         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Done processing RightsManagementInformationSetting - Get.");
     }
 }
Exemplo n.º 4
0
        // 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);
        }