internal MsgToRpMsgConverter(MessageItem envelopeMessage, OrganizationId orgId, string publishLicense, string serverUseLicense, OutboundConversionOptions options) { using (DisposeGuard disposeGuard = this.Guard()) { this.serverUseLicense = serverUseLicense; this.publishLicense = publishLicense; this.options = options; this.charset = ConvertUtils.GetItemMimeCharset(envelopeMessage.CoreItem.PropertyBag); this.messageId = envelopeMessage.InternetMessageId; this.orgId = RmsClientManagerUtils.OrgIdFromPublishingLicenseOrDefault(publishLicense, orgId); this.InitTenantLicenses(); MsgToRpMsgConverter.CallRM(delegate { DrmClientUtils.GetContentIdFromLicense(this.publishLicense, out this.contentId, out this.contentIdType); }, ServerStrings.FailedToParseUseLicense); disposeGuard.Success(); } }
protected override void OnBeforeSave() { if (this.decodedItem == null && !base.AttachmentCollection.IsDirty && base.IsRestricted && (base.Recipients.IsDirty || base.IsPropertyDirty(ItemSchema.Sender))) { this.EnsureIsDecoded(); } if (this.decodedItem != null) { string contentClass = base.TryGetProperty(InternalSchema.ContentClass) as string; if (this.rmsTemplate == null) { this.UnprotectAllAttachments(); RightsManagedMessageItem.CopyProtectableData(this.decodedItem, this); if (ObjectClass.IsRightsManagedContentClass(contentClass)) { base.Delete(StoreObjectSchema.ContentClass); } } else { this.charsetDetectionStringForProtectedData = new StringBuilder((int)Math.Min(this.ProtectedBody.Size, 2147483647L)); this.GetCharsetDetectionStringFromProtectedData(this.charsetDetectionStringForProtectedData); if (!ObjectClass.IsRightsManagedContentClass(contentClass)) { this[StoreObjectSchema.ContentClass] = "rpmsg.message"; } if (this.isSending) { byte[][] valueOrDefault = base.GetValueOrDefault <byte[][]>(InternalSchema.DRMLicense); if (valueOrDefault != null && valueOrDefault.Length == RightsManagedMessageItem.EmptyDrmLicense.Length && valueOrDefault[0].Length == RightsManagedMessageItem.EmptyDrmLicense[0].Length) { base.DeleteProperties(new PropertyDefinition[] { InternalSchema.DRMLicense }); } } else if (base.IsDraft && base.GetValueOrDefault <byte[][]>(InternalSchema.DRMLicense) == null) { this[InternalSchema.DRMLicense] = RightsManagedMessageItem.EmptyDrmLicense; } base.AttachmentCollection.RemoveAll(); using (StreamAttachment streamAttachment = base.AttachmentCollection.Create(AttachmentType.Stream) as StreamAttachment) { streamAttachment.FileName = "message.rpmsg"; streamAttachment.ContentType = "application/x-microsoft-rpmsg-message"; using (Stream stream = new PooledMemoryStream(131072)) { if (this.serverUseLicense == null || ((this.UsageRights & ContentRight.Owner) == ContentRight.Owner && this.rmsTemplate.RequiresRepublishingWhenRecipientsChange && this.CanRepublish && (base.Recipients.IsDirty || (base.IsPropertyDirty(ItemSchema.Sender) && this.conversationOwner == null)))) { if (this.ConversationOwner == null) { throw new InvalidOperationException("Conversation owner must be set before protecting the message."); } this.UnprotectAllAttachments(); using (MsgToRpMsgConverter msgToRpMsgConverter = new MsgToRpMsgConverter(this, this.ConversationOwner, this.orgId, this.rmsTemplate, this.options)) { msgToRpMsgConverter.Convert(this.decodedItem, stream); using (Stream stream2 = base.OpenPropertyStream(MessageItemSchema.DRMServerLicenseCompressed, PropertyOpenMode.Create)) { DrmEmailCompression.CompressUseLicense(msgToRpMsgConverter.ServerUseLicense, stream2); } if (this.InternalSession != null && this.InternalSession.MailboxOwner.Sid != null) { ExDateTime useLicenseExpiryTime = RmsClientManagerUtils.GetUseLicenseExpiryTime(msgToRpMsgConverter.ServerUseLicense, this.UsageRights); this[MessageItemSchema.DRMRights] = (int)this.UsageRights; this[MessageItemSchema.DRMExpiryTime] = useLicenseExpiryTime; using (RightsSignatureBuilder rightsSignatureBuilder = new RightsSignatureBuilder(msgToRpMsgConverter.ServerUseLicense, msgToRpMsgConverter.PublishLicense, RmsClientManager.EnvironmentHandle, msgToRpMsgConverter.LicensePair)) { this[MessageItemSchema.DRMPropsSignature] = rightsSignatureBuilder.Sign(this.UsageRights, useLicenseExpiryTime, this.InternalSession.MailboxOwner.Sid); } } goto IL_362; } } using (MsgToRpMsgConverter msgToRpMsgConverter2 = new MsgToRpMsgConverter(this, this.orgId, this.publishLicense, this.serverUseLicense, this.options)) { msgToRpMsgConverter2.Convert(this.decodedItem, stream); } IL_362: using (Stream contentStream = streamAttachment.GetContentStream(PropertyOpenMode.Create)) { stream.Seek(0L, SeekOrigin.Begin); Util.StreamHandler.CopyStreamData(stream, contentStream); } } bool flag = false; foreach (AttachmentHandle handle in this.decodedItem.AttachmentCollection) { if (!CoreAttachmentCollection.IsInlineAttachment(handle)) { flag = true; break; } } this[InternalSchema.AllAttachmentsHidden] = !flag; streamAttachment.Save(); } } this.decodedItem.Dispose(); this.decodedItem = null; this.effectiveRights = ContentRight.Owner; this.publishLicense = null; this.restrictionInfo = null; this.rmsTemplate = null; this.serverUseLicense = null; this.conversationOwner = null; } base.OnBeforeSave(); }
private void ValidateRmsVersion(Uri uri, ServiceType serviceType) { if (serviceType == ServiceType.LicensingService) { uri = RmsoProxyUtil.GetLicenseServerRedirectUrl(uri); } if (serviceType == ServiceType.CertificationService) { uri = RmsoProxyUtil.GetCertificationServerRedirectUrl(uri); } if ((this.DataObject.IsChanged(IRMConfigurationSchema.InternalLicensingEnabled) && this.DataObject.InternalLicensingEnabled) || (this.DataObject.IsChanged(IRMConfigurationSchema.LicensingLocation) && serviceType == ServiceType.LicensingService)) { using (ServerWSManager serverWSManager = new ServerWSManager(uri, serviceType, null, null, RmsClientManagerUtils.GetLocalServerProxy(this.datacenter), RmsClientManager.AppSettings.RmsSoapQueriesTimeout)) { if (serviceType == ServiceType.CertificationService && !serverWSManager.ValidateCertificationServiceVersion()) { base.WriteError(new RmsVersionMismatchException(uri), ErrorCategory.InvalidOperation, base.Identity); } if (serviceType == ServiceType.LicensingService && !serverWSManager.ValidateLicensingServiceVersion()) { base.WriteError(new RmsVersionMismatchException(uri), ErrorCategory.InvalidOperation, base.Identity); } } } }
private bool ValidateRmsVersion(Uri uri, ServiceType serviceType) { if (this.datacenter) { return(true); } using (ServerWSManager serverWSManager = new ServerWSManager(uri, serviceType, null, null, RmsClientManagerUtils.GetLocalServerProxy(this.datacenter), RmsClientManager.AppSettings.RmsSoapQueriesTimeout)) { if (serviceType == ServiceType.CertificationService && serverWSManager.ValidateCertificationServiceVersion()) { return(true); } if (serviceType == ServiceType.LicensingService && serverWSManager.ValidateLicensingServiceVersion()) { return(true); } } return(false); }
private void Initialize() { ServerManagerLog.instance.logInstance = new Log(RmsClientManagerUtils.GetUniqueFileNameForProcess("OfflineRMSLog", true), new LogHeaderFormatter(ServerManagerLog.LogSchema), "OfflineRMSServerLog"); ServerManagerLog.instance.logInstance.Configure(Path.Combine(ExchangeSetupContext.InstallPath, "TransportRoles\\Logs\\OfflineRMS\\"), ServerManagerLog.LogMaxAge, 262144000L, 10485760L); }