Wraps a std::iostream to provide transparent encryption and decryption on read and write.
More...
#include <ProtectedFileStream.h>
|
virtual std::shared_future< int64_t > | ReadAsync (uint8_t *pbBuffer, int64_t cbBuffer, int64_t cbOffset, std::launch launchType) override |
| Returns an asynchronous byte reader object. More...
|
|
virtual std::shared_future< int64_t > | WriteAsync (const uint8_t *cpbBuffer, int64_t cbBuffer, int64_t cbOffset, std::launch launchType) override |
| Writes data asynchronously to the protected file. More...
|
|
virtual std::future< bool > | FlushAsync (std::launch launchType) override |
| Flushes the data asynchronously to the protected file. More...
|
|
virtual int64_t | Read (uint8_t *pbBuffer, int64_t cbBuffer) override |
| Returns an byte reader object. More...
|
|
virtual int64_t | Write (const uint8_t *cpbBuffer, int64_t cbBuffer) override |
| Writes data to the protected file. More...
|
|
virtual bool | Flush () override |
| Flushes the data to the protected file. More...
|
|
virtual rmscrypto::api::SharedStream | Clone () override |
| Creates a new instance of ProtectedFileStream over the protected file. More...
|
|
virtual void | Seek (uint64_t u64Position) override |
| Sets the current position to the specified number of bytes from the start of the file. 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 position in bytes. 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...
|
|
std::shared_ptr< UserPolicy > | Policy () |
|
std::string | OriginalFileExtension () |
|
virtual std::vector< uint8_t > | Read (uint64_t u64size) |
|
|
static std::shared_ptr< GetProtectedFileStreamResult > | Acquire (rmscrypto::api::SharedStream stream, const std::string &userId, IAuthenticationCallback &authenticationCallback, IConsentCallback &consentCallback, PolicyAcquisitionOptions options, ResponseCacheFlags cacheMask=static_cast< ResponseCacheFlags >(RESPONSE_CACHE_INMEMORY|RESPONSE_CACHE_ONDISK|RESPONSE_CACHE_ENCRYPTED)) |
| Wrap an existing stream as a protected stream. More...
|
|
static std::shared_ptr< ProtectedFileStream > | Create (std::shared_ptr< UserPolicy > policy, rmscrypto::api::SharedStream stream, const std::string &originalFileExtension) |
| Wrap a new stream as a protected stream. More...
|
|
Wraps a std::iostream to provide transparent encryption and decryption on read and write.
Use ProtectedFileStream::Acquire when working with encrypted (PFile) content. Use ProtectedFileStream::Create to wrap and encrypt a new stream.
shared_ptr< GetProtectedFileStreamResult > rmscore::modernapi::ProtectedFileStream::Acquire |
( |
rmscrypto::api::SharedStream |
stream, |
|
|
const std::string & |
userId, |
|
|
IAuthenticationCallback & |
authenticationCallback, |
|
|
IConsentCallback & |
consentCallback, |
|
|
PolicyAcquisitionOptions |
options, |
|
|
ResponseCacheFlags |
cacheMask = static_cast<ResponseCacheFlags>(RESPONSE_CACHE_INMEMORY | RESPONSE_CACHE_ONDISK | RESPONSE_CACHE_ENCRYPTED) |
|
) |
| |
|
static |
Wrap an existing stream as a protected stream.
Creates a ProtectedFileStream object from a backing stream. This method is used to open PFILEs. The PFILE is loaded from the specified backing stream. After ProtectedFileStream object is created, apps can use ProtectedFileStream::Policy property to get the UserPolicy object that defines the policy used to protect the PFILE. The resulting ProtectedFileStream can be used to read the contents of the PFILE (as a regular IRandomAccessStream).
- Parameters
-
stream | The std::iostream to be wrapped. |
userId | The email address of the user consuming the protected content. This parameter is also used as a hint for auth dialogs. |
authenticationCallback | A callback which will return authentication details for the current user. |
consentCallback | A consent callback to ensure user consent. |
options | |
cacheMask | How API responses should be cached. |
- Returns
- A GetProtectedFileStreamResult struct with status and pointer to wrapped stream.
bool rmscore::modernapi::ProtectedFileStream::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::ProtectedFileStream::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::ProtectedFileStream::Clone |
( |
| ) |
|
|
overridevirtual |
Creates a new instance of ProtectedFileStream over the protected file.
- Returns
- A ProtectedFileStream object that represents the new stream. The initial, internal position of the stream is 0. The internal position and lifetime of the new stream are independent from the position and lifetime of the cloned stream.
Implements rmscrypto::api::IStream.
shared_ptr< ProtectedFileStream > rmscore::modernapi::ProtectedFileStream::Create |
( |
std::shared_ptr< UserPolicy > |
policy, |
|
|
rmscrypto::api::SharedStream |
stream, |
|
|
const std::string & |
originalFileExtension |
|
) |
| |
|
static |
Wrap a new stream as a protected stream.
Creates a new ProtectedFileStream from a UserPolicy object and a backing stream. This method is used to create new PFiles. The PFile is written to the backing stream. The policy used to protect the PFile is defined by the specified UserPolicy object. The resulting ProtectedFileStream can be used to write the actual content of the PFile using APIs from std::io.
- Parameters
-
policy | The UserPolicy object that defines the policy used to protect the created PFile |
stream | The backing stream, where encrypted content will be written. |
originalFileExtension | The file extension of the original unprotected file. |
- Returns
- A ProtectedFileStream.
bool rmscore::modernapi::ProtectedFileStream::Flush |
( |
| ) |
|
|
overridevirtual |
Flushes the data to the protected file.
- Returns
- For the stream flush operation; null is returned if an exception occurs. Upon completion, IAsyncOperation.GetResults returns True if the file has been successfully flushed; otherwise, false.
Implements rmscrypto::api::IStream.
future< bool > rmscore::modernapi::ProtectedFileStream::FlushAsync |
( |
std::launch |
launchType | ) |
|
|
overridevirtual |
Flushes the data asynchronously to the protected file.
- Parameters
-
launchType | BRP072315 - ??? |
- Returns
- The stream flush operation. Null is returned if an exception occurs.
Implements rmscrypto::api::IStream.
uint64_t rmscore::modernapi::ProtectedFileStream::Position |
( |
| ) |
|
|
overridevirtual |
Gets the current file position in bytes.
- Returns
- Current file position in bytes.
Implements rmscrypto::api::IStream.
int64_t rmscore::modernapi::ProtectedFileStream::Read |
( |
uint8_t * |
pbBuffer, |
|
|
int64_t |
cbBuffer |
|
) |
| |
|
overridevirtual |
Returns an byte reader object.
- Parameters
-
pbBuffer | The buffer into which the read operation places the bytes that are read. |
cbBuffer | The number of bytes to read that is less than or equal to the capacity of the buffer. |
- Returns
- Count of bytes read.
Implements rmscrypto::api::IStream.
shared_future< int64_t > rmscore::modernapi::ProtectedFileStream::ReadAsync |
( |
uint8_t * |
pbBuffer, |
|
|
int64_t |
cbBuffer, |
|
|
int64_t |
cbOffset, |
|
|
std::launch |
launchType |
|
) |
| |
|
overridevirtual |
Returns an asynchronous byte reader object.
- Parameters
-
pbBuffer | The buffer into which the asynchronous read operation places the bytes that are read. |
cbBuffer | The number of bytes to read that is less than or equal to the capacity of the buffer. |
cbOffset | BRP072315 - ??? |
launchType | BRP072315 - ??? |
- Returns
- Count of bytes read.
Implements rmscrypto::api::IStream.
void rmscore::modernapi::ProtectedFileStream::Seek |
( |
uint64_t |
u64Position | ) |
|
|
overridevirtual |
Sets the current position to the specified number of bytes from the start of the file.
- Parameters
-
u64Position | Number of bytes from the start of the file |
Implements rmscrypto::api::IStream.
uint64_t rmscore::modernapi::ProtectedFileStream::Size |
( |
| ) |
|
|
overridevirtual |
void rmscore::modernapi::ProtectedFileStream::Size |
( |
uint64_t |
u64Value | ) |
|
|
overridevirtual |
Sets the size of the protected data in bytes.
- Parameters
-
u64Value | Number of bytes of protected data. |
Implements rmscrypto::api::IStream.
int64_t rmscore::modernapi::ProtectedFileStream::Write |
( |
const uint8_t * |
cpbBuffer, |
|
|
int64_t |
cbBuffer |
|
) |
| |
|
overridevirtual |
Writes data to the protected file.
- Parameters
-
pbBuffer | The buffer into which the write operation writes. |
cbBuffer | BRP072315 - ??? |
- Returns
- Count of bytes written.
Implements rmscrypto::api::IStream.
shared_future< int64_t > rmscore::modernapi::ProtectedFileStream::WriteAsync |
( |
const uint8_t * |
cpbBuffer, |
|
|
int64_t |
cbBuffer, |
|
|
int64_t |
cbOffset, |
|
|
std::launch |
launchType |
|
) |
| |
|
overridevirtual |
Writes data asynchronously to the protected file.
- Parameters
-
pbBuffer | The buffer into which the asynchronous write operation writes. |
cbBuffer | BRP072315 - ??? |
cbOffset | BRP072315 - ??? |
launchType | BRP072315 - ??? |
- Returns
- Count of bytes read.
Implements rmscrypto::api::IStream.
The documentation for this class was generated from the following files: