Used to access files that use a custom protection format.
More...
#include <CustomProtectedStream.h>
|
virtual std::shared_future< int64_t > | ReadAsync (uint8_t *pbBuffer, int64_t cbBuffer, int64_t cbOffset, std::launch launchType) override |
| Requests contents of the stream to be read asynchronously into pbBuffer, and returns a std::shared_future to track status of the asynchronous operation. Call .get() or .wait() on this shared_future to synchronously await its completion. More...
|
|
virtual std::shared_future< int64_t > | WriteAsync (const uint8_t *cpbBuffer, int64_t cbBuffer, int64_t cbOffset, std::launch launchType) override |
| Requests that data from *cpbBuffer be written asynchronously to stream, and returns a std::shared_future to track status of the asynchronous operation. Call .get() or .wait() on this shared_future to synchronously await its completion. More...
|
|
virtual std::future< bool > | FlushAsync (std::launch launchType) override |
| Requests that pending data be flushed asynchronously to stream, and returns a std::shared_future to track status of the asynchronous operation. Call .get() or .wait() on this shared_future to synchronously await its completion. More...
|
|
virtual int64_t | Read (uint8_t *pbBuffer, int64_t cbBuffer) override |
| Reads data from the backing stream. More...
|
|
virtual int64_t | Write (const uint8_t *cpbBuffer, int64_t cbBuffer) override |
| Writes data to the backing stream. More...
|
|
virtual bool | Flush () override |
| Flushes the data to the backing stream. More...
|
|
virtual rmscrypto::api::SharedStream | Clone () override |
| Creates a copy of the CustomProtectedStream. More...
|
|
virtual void | Seek (uint64_t u64Position) override |
| Sets the current position to the specified offset in the stream. More...
|
|
virtual bool | CanRead () const override |
| Gets a value that indicates whether the file can be read from. More...
|
|
virtual bool | CanWrite () const override |
| Gets a value that indicates whether the file can be written to. More...
|
|
virtual uint64_t | Position () override |
| Gets the current file seek offset. More...
|
|
virtual uint64_t | Size () override |
| Gets the size of the protected data in bytes. More...
|
|
virtual void | Size (uint64_t u64Value) override |
| Sets the size of the protected data in bytes. More...
|
|
virtual std::vector< uint8_t > | Read (uint64_t u64size) |
|
|
| CustomProtectedStream (std::shared_ptr< IStream >pImpl) |
|
std::shared_ptr< IStream > | GetImpl () |
|
Used to access files that use a custom protection format.
Important - RMS applications that use CustomProtectedStream may be incompatible with SharePoint, Exchange, and other RMS applications. For most applications, it is recommended that you use ProtectedFileStream instead.
bool rmscore::modernapi::CustomProtectedStream::CanRead |
( |
| ) |
const |
|
overridevirtual |
Gets a value that indicates whether the file can be read from.
- Returns
- True if the file can be read from; otherwise false.
Implements rmscrypto::api::IStream.
bool rmscore::modernapi::CustomProtectedStream::CanWrite |
( |
| ) |
const |
|
overridevirtual |
Gets a value that indicates whether the file can be written to.
- Returns
- True if the file can be written to; otherwise false.
Implements rmscrypto::api::IStream.
SharedStream rmscore::modernapi::CustomProtectedStream::Clone |
( |
| ) |
|
|
overridevirtual |
shared_ptr< CustomProtectedStream > rmscore::modernapi::CustomProtectedStream::Create |
( |
std::shared_ptr< UserPolicy > |
policy, |
|
|
rmscrypto::api::SharedStream |
stream, |
|
|
uint64_t |
contentStartPosition, |
|
|
uint64_t |
contentSize |
|
) |
| |
|
static |
Creates a CustomProtectedStream object based on the specified protection policy and a backing stream.
The CustomProtectedStream can be used for both encrypting and decrypting content. If the backing stream already contains encrypted content, you can use the stream Read* methods to decrypt and read it. You can also use stream Write* methods to encrypt and write content to the backing stream.
Warning - To avoid data loss and/or corruption, the Flush* methods must be called if you modify the created stream before the stream goes out of scope or is manually disposed.
Warning - This method must be called on a UI thread. Calling it on a worker thread may result in an unexpected behavior.
- Parameters
-
policy | The user policy to apply to protect the content. |
stream | The backing stream. |
contentStartPosition | The start position of encrypted content within the stream. |
contentSize | The size of the encrypted content within the stream. |
- Returns
- A CustomProtectedStream object that can be used to write content to the encrypted portion of the backing stream.
bool rmscore::modernapi::CustomProtectedStream::Flush |
( |
| ) |
|
|
overridevirtual |
Flushes the data to the backing stream.
- Returns
- The result of the flush operation. True if data was successfully flushed; otherwise False.
Implements rmscrypto::api::IStream.
future< bool > rmscore::modernapi::CustomProtectedStream::FlushAsync |
( |
std::launch |
launchType | ) |
|
|
overridevirtual |
Requests that pending data be flushed asynchronously to stream, and returns a std::shared_future to track status of the asynchronous operation. Call .get() or .wait() on this shared_future to synchronously await its completion.
- Parameters
-
launchType | Can be std::launch::async and/or std::launch::deferred. If deferred, flush will take place "lazily" - i.e. only when get() or wait() is called. |
- Returns
- (Future of) the result of the flush operation. True if data was successfully flushed; otherwise False.
Implements rmscrypto::api::IStream.
uint64_t rmscore::modernapi::CustomProtectedStream::GetEncryptedContentLength |
( |
std::shared_ptr< UserPolicy > |
policy, |
|
|
uint64_t |
contentLength |
|
) |
| |
|
static |
Calculates the length of the encrypted content from the length of the plaintext content.
- Parameters
-
policy | Pointer to userPolicy object. |
contentLenght | Length of the plaintext content. |
- Returns
- The encrypted content length.
uint64_t rmscore::modernapi::CustomProtectedStream::Position |
( |
| ) |
|
|
overridevirtual |
int64_t rmscore::modernapi::CustomProtectedStream::Read |
( |
uint8_t * |
pbBuffer, |
|
|
int64_t |
cbBuffer |
|
) |
| |
|
overridevirtual |
Reads data from the backing stream.
- Parameters
-
pbBuffer | The buffer into which the read operation puts the bytes that are read. |
cbBuffer | The number of bytes available in the buffer. |
- Returns
- Number of bytes actually read.
Implements rmscrypto::api::IStream.
shared_future< int64_t > rmscore::modernapi::CustomProtectedStream::ReadAsync |
( |
uint8_t * |
pbBuffer, |
|
|
int64_t |
cbBuffer, |
|
|
int64_t |
cbOffset, |
|
|
std::launch |
launchType |
|
) |
| |
|
overridevirtual |
Requests contents of the stream to be read asynchronously into pbBuffer, and returns a std::shared_future to track status of the asynchronous operation. Call .get() or .wait() on this shared_future to synchronously await its completion.
- Parameters
-
pbBuffer | The buffer into which the (asynchronous) read operation should place read bytes. |
cbBuffer | Count of bytes in this buffer. |
cbOffset | Offset into the buffer where bytes should begin being written. |
launchType | Can be std::launch::async and/or std::launch::deferred. If deferred, read will take place "lazily" - i.e. only when get() or wait() is called. |
- Returns
- (Future of) count of bytes read.
Implements rmscrypto::api::IStream.
void rmscore::modernapi::CustomProtectedStream::Seek |
( |
uint64_t |
u64Position | ) |
|
|
overridevirtual |
Sets the current position to the specified offset in the stream.
- Parameters
-
u64Position | The offset in the stream to move to. |
Implements rmscrypto::api::IStream.
uint64_t rmscore::modernapi::CustomProtectedStream::Size |
( |
| ) |
|
|
overridevirtual |
Gets the size of the protected data in bytes.
- Returns
- Size of the protected data in bytes.
Implements rmscrypto::api::IStream.
void rmscore::modernapi::CustomProtectedStream::Size |
( |
uint64_t |
u64Value | ) |
|
|
overridevirtual |
Sets the size of the protected data in bytes.
- Parameters
-
u64Value | Size of the protected data in bytes. |
Implements rmscrypto::api::IStream.
int64_t rmscore::modernapi::CustomProtectedStream::Write |
( |
const uint8_t * |
cpbBuffer, |
|
|
int64_t |
cbBuffer |
|
) |
| |
|
overridevirtual |
Writes data to the backing stream.
- Parameters
-
cpbBuffer | The buffer from which the write operation reads data to be written. |
cbBuffer | The size of the buffer. |
- Returns
- Number of bytes written.
Implements rmscrypto::api::IStream.
shared_future< int64_t > rmscore::modernapi::CustomProtectedStream::WriteAsync |
( |
const uint8_t * |
cpbBuffer, |
|
|
int64_t |
cbBuffer, |
|
|
int64_t |
cbOffset, |
|
|
std::launch |
launchType |
|
) |
| |
|
overridevirtual |
Requests that data from *cpbBuffer be written asynchronously to stream, and returns a std::shared_future to track status of the asynchronous operation. Call .get() or .wait() on this shared_future to synchronously await its completion.
- Parameters
-
cpbBuffer | Pointer to the buffer from which the write operation will read contents to be written. |
cbBuffer | Count of bytes in cpbBuffer. |
cbOffset | Offset into cpbBuffer where operation will begin reading from for write. |
launchType | Can be std::launch::async and/or std::launch::deferred. If deferred, write will take place "lazily" - i.e. only when get() or wait() is called. |
- Returns
- (Future of) count of bytes written.
Implements rmscrypto::api::IStream.
The documentation for this class was generated from the following files: