Microsoft Information Protection (MIP) SDK for C++: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
storage_delegate.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) Microsoft Corporation.
4 * All rights reserved.
5 *
6 * This code is licensed under the MIT License.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files(the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions :
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 *
26 */
27/**
28 * @brief Defines StorageDelegate interface
29 *
30 * @file storage_delegate.h
31 */
32
33#ifndef API_MIP_STORAGE_DELEGATE_H_
34#define API_MIP_STORAGE_DELEGATE_H_
35
36#include <string>
37#include <vector>
38
39#include "mip/common_types.h"
41#include "mip/mip_namespace.h"
42#include "mip/storage_table.h"
43
44MIP_NAMESPACE_BEGIN
45
46/**
47 * @brief Describes the MIP component to be used in the application.
48 */
49enum class MipComponent : unsigned int {
50 Policy = 0, /* For Policy sdk */
51 File = 1, /* For File sdk */
52 Protection = 2, /* For Protection sdk */
53};
54
55/**
56* @brief A delegate response type for #StorageTable
57*/
58typedef mip::DelegateResponse<mip::StorageTable> StorageTableResult;
59
60/**
61* @brief A class that defines the interface to the MIP SDK storage for caching
62*/
64public:
65
66 /**
67 * @brief Creates an instance of a storage table that MIP uses for caching. If a table already exists & schema doesnt match with @p allColumns , implementatiion should drop the table and re-create new one.
68 *
69 * @param path Default path for mip storage. Will end in file extension returned from StorageSettings::OnDiskExtension()
70 * @param mipComponent #MipComponent associated with this table.
71 * @param tableName Name of the table to create.
72 * @param allColumns All columns represented in the table.
73 * @param encryptedColumns Represents the set of columns within @p allColumns that need to be encrypted. This argument is only populated if #CacheStorageType (configured via the profile settings) is not @p OnDiskEncrypted,
74 * otherwise the MIP SDK will internally encrypt the column data for these columns and modify their name with an 'encrypt_' prefix.
75 * @param keyColumns Key columns used to identify unique table entries.
76 *
77 * @return A delegate response which either contains an instance of #StorageTable or an exception.
78 */
79 virtual mip::StorageTableResult CreateStorageTable(
80 const std::string& path,
81 const MipComponent mipComponent,
82 const std::string& tableName,
83 const std::vector<std::string>& allColumns,
84 const std::vector<std::string>& encryptedColumns,
85 const std::vector<std::string>& keyColumns) const = 0;
86
87 /**
88 * @brief Settings used by StorageDelegate
89 */
91 public:
92 /**
93 * @brief Interface for configuring the storage settings.
94 *
95 * @param isRemoteStore represents if store is remote. This will be taken into account for internal encryption.
96 * @param isInMemoryStorageSupported Declares whether the delegate supports in-memory storage.
97 * @param onDiskExtension The file extension that will be used to store the data if it is needed. Should begin with ".".
98 */
100 bool isRemoteStorage,
101 bool isInMemoryStorageSupported,
102 const std::string& onDiskExtension = GetSqliteExtension())
103 : mIsRemoteStorage(isRemoteStorage),
104 mIsInMemoryStorageSupported(isInMemoryStorageSupported),
105 mOnDiskExtension(onDiskExtension) {}
106
107 /**
108 * @brief Gets whether remote storage is used or not.
109 *
110 * @return whether remote storage is used or not.
111 */
112 bool IsRemoteStorage() const { return mIsRemoteStorage; }
113
114 /**
115 * @brief Gets whether the delegate supports in-memory storage.
116 *
117 * @return \p true if the delegate supports in-memory storage.
118 */
119 bool IsInMemoryStorageSupported() const { return mIsInMemoryStorageSupported; }
120
121 /**
122 * @brief Gets the extension that the delegate will use when storing a table on disk
123 *
124 * @return The extension that will be used. Default to ".sqlite3".
125 *
126 * @note Extension will have "." preceding it
127 */
128 std::string OnDiskExtension() const { return mOnDiskExtension; }
129
130 /** @cond DOXYGEN_HIDE */
131 ~StorageSettings() { }
133 private:
134 bool mIsRemoteStorage;
135 bool mIsInMemoryStorageSupported;
136 std::string mOnDiskExtension;
137 /** @endcond */
138 };
139
140 /**
141 * @brief Gets settings used by #StorageDelegate.
142 *
143 * @return settings used by #StorageDelegate.
144 */
145 virtual StorageSettings GetSettings() const = 0;
146
147 /** @cond DOXYGEN_HIDE */
148 virtual ~StorageDelegate() {}
149
150protected:
151 StorageDelegate() {}
152 /** @endcond */
153};
154
155MIP_NAMESPACE_END
156#endif // API_MIP_STORAGE_DELEGATE_H_
157
Settings used by StorageDelegate.
StorageSettings(bool isRemoteStorage, bool isInMemoryStorageSupported, const std::string &onDiskExtension=GetSqliteExtension())
Interface for configuring the storage settings.
bool IsInMemoryStorageSupported() const
Gets whether the delegate supports in-memory storage.
std::string OnDiskExtension() const
Gets the extension that the delegate will use when storing a table on disk.
bool IsRemoteStorage() const
Gets whether remote storage is used or not.
A class that defines the interface to the MIP SDK storage for caching.
virtual StorageSettings GetSettings() const =0
Gets settings used by StorageDelegate.
virtual mip::StorageTableResult CreateStorageTable(const std::string &path, const MipComponent mipComponent, const std::string &tableName, const std::vector< std::string > &allColumns, const std::vector< std::string > &encryptedColumns, const std::vector< std::string > &keyColumns) const =0
Creates an instance of a storage table that MIP uses for caching.
A file Containing the common types used by the upe, file and protection modules.
const std::string & GetSqliteExtension()
A simple framework to create a response to delegate calls that can result in error.
MIP namespace macros.
mip::DelegateResponse< mip::StorageTable > StorageTableResult
A delegate response type for StorageTable.
MipComponent
Describes the MIP component to be used in the application.
Defines StorageTable interface.