RMS SDK for C++  0.2.1
A client library for using Microsoft RMS from Linux.
UserPolicy.h
1 /*
2  * ======================================================================
3  * Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
4  * Licensed under the MIT License.
5  * See LICENSE.md in the project root for license information.
6  * ======================================================================
7  */
8 
9 #ifndef _RMS_LIB_USERPOLICY_H_
10 #define _RMS_LIB_USERPOLICY_H_
11 
12 #include <stdint.h>
13 #include <chrono>
14 
15 #include "IAuthenticationCallback.h"
16 #include "IConsentCallback.h"
17 #include "ModernAPIExport.h"
18 #include "CacheControl.h"
19 #include "TemplateDescriptor.h"
20 #include "PolicyDescriptor.h"
21 
22 namespace rmscore {
23 namespace core {
24 class ProtectionPolicy;
25 }
26 
27 namespace modernapi {
28 class TemplateDescriptor;
29 class PolicyDescriptor;
30 
34 enum GetUserPolicyResultStatus {
38  Success = 0,
42  NoRights = 1,
46  Expired = 2
47 };
48 
49 
50 class UserPolicy;
51 
55 struct DLL_PUBLIC_RMS GetUserPolicyResult {
59  GetUserPolicyResult(GetUserPolicyResultStatus status,
60  std::shared_ptr<std::string>referrer,
61  std::shared_ptr<UserPolicy> policy);
65  GetUserPolicyResultStatus Status;
66 
70  std::shared_ptr<std::string>Referrer;
71 
75  std::shared_ptr<UserPolicy> Policy;
76 };
77 
82 enum PolicyAcquisitionOptions {
89  POL_None = 0x0,
90 
99  POL_OfflineOnly = 0x1
100 };
101 
105 enum UserPolicyCreationOptions {
106  USER_None = 0x0,
107 
111  USER_AllowAuditedExtraction = 0x1,
112 
117  USER_PreferDeprecatedAlgorithms = 0x2,
118 };
119 
123 enum UserPolicyType {
127  TemplateBased = 0,
128 
132  Custom = 1,
133 };
134 
138 class DLL_PUBLIC_RMS UserPolicy {
139 public:
140 
163  static std::shared_ptr<GetUserPolicyResult>Acquire(
164  const std::vector<unsigned char>& serializedPolicy,
165  const std::string & userId,
166  IAuthenticationCallback & authenticationCallback,
167  IConsentCallback & consentCallback,
168  PolicyAcquisitionOptions options,
169  ResponseCacheFlags cacheMask);
170 
187  static std::shared_ptr<UserPolicy>CreateFromTemplateDescriptor(
188  const TemplateDescriptor& templateDescriptor,
189  const std::string & userId,
190  IAuthenticationCallback & authenticationCallback,
191  UserPolicyCreationOptions options,
192  const AppDataHashMap & signedAppData);
193 
209  static std::shared_ptr<UserPolicy>Create(
210  PolicyDescriptor & policyDescriptor,
211  const std::string & userId,
212  IAuthenticationCallback & authenticationCallback,
213  UserPolicyCreationOptions options);
214 
222  bool AccessCheck(
223  const std::string& right) const;
224 
228  UserPolicyType Type();
229 
233  std::string Name();
234 
238  std::string Description();
239 
243  std::shared_ptr<modernapi::TemplateDescriptor> TemplateDescriptor();
244 
248  std::shared_ptr<modernapi::PolicyDescriptor> PolicyDescriptor();
249 
253  std::string Owner();
254 
258  std::string IssuedTo();
259 
263  bool IsIssuedToOwner();
264 
268  std::string ContentId();
269 
273  const AppDataHashMap EncryptedAppData();
274 
278  const AppDataHashMap SignedAppData();
279 
283  std::chrono::time_point<std::chrono::system_clock>ContentValidUntil();
284 
288  bool DoesUseDeprecatedAlgorithms();
289 
293  bool IsAuditedExtractAllowed();
294 
298  const std::vector<unsigned char> SerializedPolicy();
299 
304  std::shared_ptr<core::ProtectionPolicy> GetImpl();
305 
306 private:
307 
308  UserPolicy(std::shared_ptr<core::ProtectionPolicy>pImpl);
309 
310  std::shared_ptr<core::ProtectionPolicy> m_pImpl;
311  std::shared_ptr<modernapi::TemplateDescriptor> m_templateDescriptor;
312  std::shared_ptr<modernapi::PolicyDescriptor> m_policyDescriptor;
313 };
314 } // namespace modernapi
315 } // namespace rmscore
316 #endif // _RMS_LIB_USERPOLICY_H_
Represents the policy associated with protected content.
Definition: UserPolicy.h:138
Definition: AuthenticationCallbackImpl.h:16
Specifies users and rights assigned for a file. This is information used for custom protection...
Definition: PolicyDescriptor.h:49
Implement this interface to provide an approach for getting an OAuth access token.
Definition: IAuthenticationCallback.h:25
The result of the UserPolicy::Acquire operation.
Definition: UserPolicy.h:55
GetUserPolicyResultStatus Status
User policy result status.
Definition: UserPolicy.h:65
std::shared_ptr< std::string > Referrer
The policy referrer.
Definition: UserPolicy.h:70
Template information.
Definition: TemplateDescriptor.h:23
std::shared_ptr< UserPolicy > Policy
Pointer to the policy object.
Definition: UserPolicy.h:75
Callback to be provided by library user to notify app user of actions to be taken and request their c...
Definition: IConsentCallback.h:24