public bool Decode(OutboundConversionOptions options, bool acquireLicense) { this.CheckDisposed("Decode"); Util.ThrowOnNullArgument(options, "options"); this.decryptionStatus = RightsManagedMessageDecryptionStatus.Success; if (this.decodedItem != null) { return(true); } if (this.InternalSession == null) { this.decryptionStatus = RightsManagedMessageDecryptionStatus.NotSupported; throw new InvalidOperationException("Decoding of in-memory messages is not supported."); } RightsManagedMessageItem.CheckSession(this.InternalSession); this.SetConversionOptions(options); using (DisposeGuard disposeGuard = default(DisposeGuard)) { try { MessageItem messageItem = ItemConversion.OpenRestrictedContent(this, this.orgId, acquireLicense, out this.licenseAcquired, out this.useLicenseValue, out this.restrictionInfo); if (messageItem == null) { ExTraceGlobals.StorageTracer.TraceError(0L, "Failed to decode protected message - no user license is present."); throw new RightsManagementPermanentException(RightsManagementFailureCode.UnknownFailure, ServerStrings.GenericFailureRMDecryption); } disposeGuard.Add <MessageItem>(messageItem); this.UpdateEffectiveRights(); this.conversationOwner = new Participant(this.restrictionInfo.ConversationOwner, this.restrictionInfo.ConversationOwner, "SMTP"); this.CheckPermission(ContentRight.View); messageItem.CoreItem.TopLevelItem = (base.CoreItem.TopLevelItem ?? base.CoreItem); this.serverUseLicense = (messageItem.TryGetProperty(MessageItemSchema.DRMServerLicense) as string); this.publishLicense = (messageItem.TryGetProperty(MessageItemSchema.DrmPublishLicense) as string); this.rmsTemplate = RmsTemplate.CreateFromPublishLicense(this.publishLicense); MsgToRpMsgConverter.CallRM(delegate { this.publishedByExternalRMS = !RmsClientManager.IsPublishedByOrganizationRMS(this.orgId, this.publishLicense); }, ServerStrings.FailedToCheckPublishLicenseOwnership(this.orgId.ToString())); this.decodedItem = messageItem; disposeGuard.Success(); } catch (RightsManagementPermanentException exception) { this.decryptionStatus = RightsManagedMessageDecryptionStatus.CreateFromException(exception); throw; } catch (RightsManagementTransientException exception2) { this.decryptionStatus = RightsManagedMessageDecryptionStatus.CreateFromException(exception2); throw; } } return(true); }
internal static ItemPartIrmInfo CreateForDecryptionFailure(Exception exception) { return(new ItemPartIrmInfo(true, ContentRight.None, string.Empty, string.Empty, string.Empty, RightsManagedMessageDecryptionStatus.CreateFromException(exception), ExDateTime.MinValue, true, false)); }