Example #1
0
        internal static void DecodeIrmMessage(StoreSession storeSession, Item mailboxItem, bool acquireLicense)
        {
            RightsManagedMessageItem rightsManagedMessageItem = mailboxItem as RightsManagedMessageItem;

            if (rightsManagedMessageItem == null)
            {
                return;
            }
            if (!IrmUtils.DoesSessionSupportIrm(storeSession))
            {
                return;
            }
            if (!rightsManagedMessageItem.IsRestricted)
            {
                return;
            }
            if (!rightsManagedMessageItem.CanDecode)
            {
                return;
            }
            if (rightsManagedMessageItem.IsDecoded)
            {
                return;
            }
            OutboundConversionOptions outboundConversionOptions = IrmUtils.GetOutboundConversionOptions(storeSession.MailboxOwner.MailboxInfo.OrganizationId);

            rightsManagedMessageItem.TryDecode(outboundConversionOptions, acquireLicense);
        }
Example #2
0
        public override IAttachment Read(string attachmentId)
        {
            IList <AttachmentId> attachmentIds = IdConverter.GetAttachmentIds(attachmentId);
            IAttachment          result;

            using (IItem item = this.BindToParentItem())
            {
                using (DisposeGuard disposeGuard = default(DisposeGuard))
                {
                    IItem      item2      = item;
                    Attachment attachment = null;
                    for (int i = 0; i < attachmentIds.Count; i++)
                    {
                        attachment = IrmUtils.GetAttachmentCollection(item2).Open(attachmentIds[i]);
                        disposeGuard.Add <Attachment>(attachment);
                        if (i < attachmentIds.Count - 1)
                        {
                            if (!(attachment is ItemAttachment))
                            {
                                throw new CorruptDataException(Strings.ErrorAllButLastNestedAttachmentMustBeItemAttachment);
                            }
                            ItemAttachment itemAttachment = attachment as ItemAttachment;
                            item2 = itemAttachment.GetItem();
                            disposeGuard.Add <IItem>(item2);
                        }
                    }
                    StorageTranslator <IAttachment, IAttachment> attachmentTranslator = this.GetAttachmentTranslator(attachment.AttachmentType, false);
                    IAttachment attachment2 = attachmentTranslator.ConvertToEntity(attachment);
                    attachment2.Id = attachmentId;
                    result         = attachment2;
                }
            }
            return(result);
        }
Example #3
0
        internal static string GetItemPreview(Item xsoItem)
        {
            Body body = IrmUtils.GetBody(xsoItem);

            if (body == null)
            {
                return(null);
            }
            return(body.PreviewText);
        }
Example #4
0
        internal static OutboundConversionOptions GetOutboundConversionOptions(OrganizationId orgId)
        {
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(orgId), 211, "GetOutboundConversionOptions", "f:\\15.00.1497\\sources\\dev\\Entities\\src\\Common\\DataProviders\\IrmUtils.cs");

            return(new OutboundConversionOptions(IrmUtils.GetDefaultAcceptedDomainName(orgId))
            {
                ClearCategories = false,
                AllowPartialStnefConversion = true,
                DemoteBcc = true,
                UserADSession = tenantOrRootOrgRecipientSession
            });
        }
Example #5
0
 public IEnumerable <IAttachment> GetAllAttachments()
 {
     using (IItem parentItem = this.BindToParentItem())
     {
         AttachmentCollection attachmentCollection = IrmUtils.GetAttachmentCollection(parentItem);
         foreach (AttachmentHandle attachmentHandle in attachmentCollection.GetHandles())
         {
             using (Attachment attachment = attachmentCollection.Open(attachmentHandle))
             {
                 StorageTranslator <IAttachment, IAttachment> translator = this.GetAttachmentTranslator(attachment.AttachmentType, false);
                 IAttachment resultAttachment = translator.ConvertToEntity(attachment);
                 yield return(resultAttachment);
             }
         }
     }
     yield break;
 }
Example #6
0
        private static RmsTemplate LookupRmsTemplate(Guid templateId, MailboxSession session)
        {
            OrganizationId organizationId = session.MailboxOwner.MailboxInfo.OrganizationId;

            IrmUtils.ThrowIfInternalLicensingDisabled(organizationId);
            IEnumerable <RmsTemplate> source = RmsClientManager.AcquireRmsTemplates(organizationId, false);
            RmsTemplate result;

            try
            {
                result = source.SingleOrDefault((RmsTemplate template) => template.Id.Equals(templateId));
            }
            catch (InvalidOperationException)
            {
                throw new RightsManagementPermanentException(Strings.ErrorRightsManagementDuplicateTemplateId(templateId.ToString()), null);
            }
            return(result);
        }
Example #7
0
        private static bool TryLookupRmsTemplate(string complianceIdString, StoreSession session, out RmsTemplate template)
        {
            template = null;
            MailboxSession mailboxSession = session as MailboxSession;

            if (mailboxSession == null)
            {
                return(false);
            }
            Guid guid;

            if (!GuidHelper.TryParseGuid(complianceIdString, out guid) || Guid.Empty.Equals(guid))
            {
                return(false);
            }
            Exception ex = null;

            try
            {
                template = IrmUtils.LookupRmsTemplate(guid, mailboxSession);
            }
            catch (RightsManagementPermanentException ex2)
            {
                ex = ex2;
            }
            catch (RightsManagementTransientException ex3)
            {
                ex = ex3;
            }
            catch (ExchangeConfigurationException ex4)
            {
                ex = ex4;
            }
            if (ex != null)
            {
                ExTraceGlobals.CommonTracer.TraceError <Exception>(0L, "Failed to lookup RMS template due to: {0}", ex);
            }
            return(null != template);
        }
Example #8
0
 protected virtual AttachmentCollection GetAttachmentCollection(IItem parentItem)
 {
     return(IrmUtils.GetAttachmentCollection(parentItem));
 }
Example #9
0
 internal static AttachmentCollection GetAttachmentCollection(IItem xsoItem)
 {
     return(IrmUtils.IsMessageRestrictedAndDecoded(xsoItem) ? ((RightsManagedMessageItem)xsoItem).ProtectedAttachmentCollection : xsoItem.AttachmentCollection);
 }
Example #10
0
 internal static bool IsIrmEnabled(bool clientSupportsIrm, StoreSession mailboxSession)
 {
     return(clientSupportsIrm && IrmUtils.DoesSessionSupportIrm(mailboxSession));
 }
Example #11
0
 internal static bool IsApplyingRmsTemplate(string complianceString, StoreSession session, out RmsTemplate template)
 {
     template = null;
     return(!string.IsNullOrEmpty(complianceString) && "0" != complianceString && IrmUtils.TryLookupRmsTemplate(complianceString, session, out template));
 }