Exemplo n.º 1
0
        /// <summary>
        /// Publishes content using MSIPC 2.x APIs
        /// </summary>
        /// <param name="rmsContent">rmsContent instance</param>
        public void PublishContent(RmsContent rmsContent)
        {
            Debug.Assert(rmsContent.RmsContentState == RmsContentState.Original);

            //bootstrap incase current machine was not bootstrapped
            SafeNativeMethods.IpcGetTemplateList(null,
                                                 false,
                                                 true,
                                                 false,
                                                 true,
                                                 null,
                                                 null,
                                                 this.symmetricKey);

            Stream sinkStream = rmsContent.SinkStream;

            string outputFilePath = SafeFileApiNativeMethods.IpcfEncryptFileStream(rmsContent.SourceStream,
                                                                                   rmsContent.OriginalFileNameWithExtension,
                                                                                   rmsContent.RmsTemplateId,
                                                                                   SafeFileApiNativeMethods.EncryptFlags.IPCF_EF_FLAG_KEY_NO_PERSIST_DISK,
                                                                                   true,
                                                                                   false,
                                                                                   true,
                                                                                   null,
                                                                                   this.symmetricKey,
                                                                                   ref sinkStream);

            rmsContent.PublishedFileNameWithExtension = Path.GetFileName(outputFilePath);

            rmsContent.SinkStream = sinkStream;
        }