Microsoft Information Protection (MIP) SDK for C++: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
protection_descriptor_builder.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 ProtectionDescriptor interface
29 *
30 * @file protection_descriptor_builder.h
31 */
32
33#ifndef API_MIP_PROTECTION_DESCRIPTOR_BUILDER_H_
34#define API_MIP_PROTECTION_DESCRIPTOR_BUILDER_H_
35
36#include <map>
37
38#include "mip/mip_export.h"
39#include "mip/mip_namespace.h"
41#include "mip/user_rights.h"
42#include "mip/user_roles.h"
43
44MIP_NAMESPACE_BEGIN
45
46/**
47* @brief Constructs a ProtectionDescriptor that describes protection associated with a piece of content
48*/
50public:
51 /**
52 * @brief License type to create a specialized license
53 */
54 enum class LicenseType {
55 /**
56 * @brief Defines a do not forward license type
57 */
58 DoNotForward = 0,
59 /**
60 * @brief Defines an encrypt only license type
61 */
63 };
64
65 /**
66 * @brief Creates a ProtectionDescriptorBuilder whose access permissions are defined by users and rights
67 *
68 * @param usersAndRights Collection of users-to-rights mappings
69 *
70 * @return New ProtectionDescriptorBuilder instance
71 */
72 MIP_API static std::shared_ptr<ProtectionDescriptorBuilder> CreateFromUserRights(
73 const std::vector<UserRights>& usersAndRights);
74
75 /**
76 * @brief Creates a ProtectionDescriptorBuilder whose access permissions are defined by users and roles
77 *
78 * @param usersAndRoles Collection of users-to-roles mappings
79 *
80 * @return New ProtectionDescriptorBuilder instance
81 */
82 MIP_API static std::shared_ptr<ProtectionDescriptorBuilder> CreateFromUserRoles(
83 const std::vector<UserRoles>& usersAndRoles);
84
85 /**
86 * @brief Creates a ProtectionDescriptorBuilder whose access permissions are defined by the protection template
87 *
88 * @param templateId protection template ID
89 *
90 * @return New ProtectionDescriptorBuilder instance
91 */
92 MIP_API static std::shared_ptr<ProtectionDescriptorBuilder> CreateFromTemplate(const std::string& templateId);
93
94 /**
95 * @brief Creates a ProtectionDescriptorBuilder whose access permissions are defined by the protection template
96 *
97 * @param serializedTemplate protection template
98 *
99 * @return New ProtectionDescriptorBuilder instance
100 */
101 MIP_API static std::shared_ptr<ProtectionDescriptorBuilder> CreateFromSerializedTemplate(
102 const std::vector<uint8_t>& serializedTemplate);
103
104 /**
105 * @brief Creates a ProtectionDescriptorBuilder whose access permissions are defined by a protection descriptor
106 *
107 * @param protectionDescriptor protection descriptor
108 *
109 * @return New ProtectionDescriptorBuilder instance
110 */
111 MIP_API static std::shared_ptr<ProtectionDescriptorBuilder> CreateFromProtectionDescriptor(const ProtectionDescriptor& protectionDescriptor);
112
113 /**
114 * @brief Creates a ProtectionDescriptorBuilder for a license type with the specified users
115 *
116 * @param licenseType The license type to create this ProtectionDescriptorBuilder for
117 * @param usersWithDefaultRights Collection of users to add to the license with default rights for the specific type
118 * @param additionalUsersAndRights Optional additional collection of users-to-rights mappings
119 *
120 * @return New ProtectionDescriptorBuilder instance
121 */
122 MIP_API static std::shared_ptr<ProtectionDescriptorBuilder> CreateFromLicenseType(
123 LicenseType licenseType,
124 const std::vector<std::string>& usersWithDefaultRights,
125 const std::vector<UserRights>& additionalUsersAndRights);
126
127 /**
128 * @brief Creates a ProtectionDescriptor whose access permissions are defined by this ProtectionDescriptorBuilder instance
129 *
130 * @return New ProtectionDescriptor instance
131 */
132 MIP_API virtual std::shared_ptr<ProtectionDescriptor> Build() = 0;
133
134 /**
135 * @brief Sets protection policy name
136 *
137 * @param value Protection policy name
138 */
139 virtual void SetName(const std::string& value) = 0;
140
141 /**
142 * @brief Sets protection policy description
143 *
144 * @param value Policy description
145 */
146 virtual void SetDescription(const std::string& value) = 0;
147
148 /**
149 * @brief Sets protection policy expiration time
150 *
151 * @param value Policy expiration time
152 */
153 virtual void SetContentValidUntil(const std::chrono::time_point<std::chrono::system_clock>& value) = 0;
154
155 /**
156 * @brief Sets if protection policy allows offline content access or not
157 *
158 * @param value If policy allows offline content access or not
159 */
160 virtual void SetAllowOfflineAccess(bool value) = 0;
161
162 /**
163 * @brief Sets protection policy referrer address
164 *
165 * @param uri Policy referrer address
166 *
167 * @note The referrer is a URI that can be displayed to the user upon failed protection policy acquisition that contains
168 * information on how that user can gain permission to access the content.
169 */
170 virtual void SetReferrer(const std::string& uri) = 0;
171
172 /**
173 * @brief Sets app-specific data that should be encrypted
174 *
175 * @param value App-specific data
176 *
177 * @note An application can specify a dictionary of app-specific data that will be encrypted by the protection service. This
178 * encrypted data is independent of the signed data set by SetSignedAppData.
179 */
180 virtual void SetEncryptedAppData(const std::map<std::string, std::string>& value) = 0;
181
182 /**
183 * @brief Sets app-specific data that should be signed
184 *
185 * @param value App-specific data
186 *
187 * @note An application can specify a dictionary of app-specific data that will be signed by the protection service. This
188 * signed data is independent of the encrypted data set by SetEncryptedAppData.
189 */
190 virtual void SetSignedAppData(const std::map<std::string, std::string>& value) = 0;
191
192 /**
193 * @brief Sets the double key url to be used for custom protection
194 *
195 * @param doubleKeyUrl Double key url
196 */
197 virtual void SetDoubleKeyUrl(const std::string& doubleKeyUrl) = 0;
198
199 /**
200 * @brief Sets the label id and tenant id for UDP protection. Only allowed for custom protection type.
201 *
202 * @param LabelInfo label info containing labelId and tenantId.
203 */
204 virtual void SetLabelInfo(const LabelInfo& labelId) = 0;
205
206 /** @cond DOXYGEN_HIDE */
208protected:
210 /** @endcond */
211};
212
213MIP_NAMESPACE_END
214
215#endif //API_MIP_PROTECTION_DESCRIPTOR_BUILDER_H_
Constructs a ProtectionDescriptor that describes protection associated with a piece of content.
virtual void SetSignedAppData(const std::map< std::string, std::string > &value)=0
Sets app-specific data that should be signed.
static MIP_API std::shared_ptr< ProtectionDescriptorBuilder > CreateFromTemplate(const std::string &templateId)
Creates a ProtectionDescriptorBuilder whose access permissions are defined by the protection template...
virtual void SetReferrer(const std::string &uri)=0
Sets protection policy referrer address.
static MIP_API std::shared_ptr< ProtectionDescriptorBuilder > CreateFromUserRoles(const std::vector< UserRoles > &usersAndRoles)
Creates a ProtectionDescriptorBuilder whose access permissions are defined by users and roles.
virtual void SetDoubleKeyUrl(const std::string &doubleKeyUrl)=0
Sets the double key url to be used for custom protection.
virtual void SetEncryptedAppData(const std::map< std::string, std::string > &value)=0
Sets app-specific data that should be encrypted.
virtual void SetName(const std::string &value)=0
Sets protection policy name.
LicenseType
License type to create a specialized license.
@ EncryptOnly
Defines an encrypt only license type.
@ DoNotForward
Defines a do not forward license type.
static MIP_API std::shared_ptr< ProtectionDescriptorBuilder > CreateFromLicenseType(LicenseType licenseType, const std::vector< std::string > &usersWithDefaultRights, const std::vector< UserRights > &additionalUsersAndRights)
Creates a ProtectionDescriptorBuilder for a license type with the specified users.
static MIP_API std::shared_ptr< ProtectionDescriptorBuilder > CreateFromSerializedTemplate(const std::vector< uint8_t > &serializedTemplate)
Creates a ProtectionDescriptorBuilder whose access permissions are defined by the protection template...
virtual void SetContentValidUntil(const std::chrono::time_point< std::chrono::system_clock > &value)=0
Sets protection policy expiration time.
virtual void SetLabelInfo(const LabelInfo &labelId)=0
Sets the label id and tenant id for UDP protection.
virtual MIP_API std::shared_ptr< ProtectionDescriptor > Build()=0
Creates a ProtectionDescriptor whose access permissions are defined by this ProtectionDescriptorBuild...
virtual void SetAllowOfflineAccess(bool value)=0
Sets if protection policy allows offline content access or not.
static MIP_API std::shared_ptr< ProtectionDescriptorBuilder > CreateFromUserRights(const std::vector< UserRights > &usersAndRights)
Creates a ProtectionDescriptorBuilder whose access permissions are defined by users and rights.
static MIP_API std::shared_ptr< ProtectionDescriptorBuilder > CreateFromProtectionDescriptor(const ProtectionDescriptor &protectionDescriptor)
Creates a ProtectionDescriptorBuilder whose access permissions are defined by a protection descriptor...
virtual void SetDescription(const std::string &value)=0
Sets protection policy description.
Description of protection associated with a piece of content.
A file export/import macros.
MIP namespace macros.
Defines ProtectionDescriptor interface.
Label information for a template or ad-hoc (custom) protection.
Defines UserRights class.
Defines UserRoles class.