Microsoft Information Protection (MIP) SDK for C++: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
action.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 * @brief A file containing the Action base class and the ActionType enumerator.
28 *
29 * @file action.h
30 */
31
32#ifndef API_MIP_UPE_ACTION_H_
33#define API_MIP_UPE_ACTION_H_
34
35#include <string>
36
37#include "mip/mip_namespace.h"
38
39MIP_NAMESPACE_BEGIN
40
41/**
42 * @brief Different action types.
43 *
44 * @note CUSTOM is the generic action type. Every other action type is a specific action with a specific meaning.
45 */
46enum class ActionType : unsigned int {
47 ADD_CONTENT_FOOTER = 1 << 0, /**< Add a content footer to the document action type.*/
48 ADD_CONTENT_HEADER = 1 << 1, /**< Add a content header to the document action type.*/
49 ADD_WATERMARK = 1 << 2, /**< Add a water mark to the entire document action type.*/
50 CUSTOM = 1 << 3, /**< A custom defined action type.*/
51 JUSTIFY = 1 << 4, /**< A justify action type.*/
52 METADATA = 1 << 5, /**< A Meta data change action type.*/
53 PROTECT_ADHOC = 1 << 6, /**< A protect by adhoc policy action type.*/
54 PROTECT_BY_TEMPLATE = 1 << 7, /**< A protect by template action type.*/
55 PROTECT_DO_NOT_FORWARD = 1 << 8, /**< A protect by do not forward action type.*/
56 REMOVE_CONTENT_FOOTER = 1 << 9, /**< Remove content footer action type.*/
57 REMOVE_CONTENT_HEADER = 1 << 10, /**< Remove content header action type.*/
58 REMOVE_PROTECTION = 1 << 11, /**< Remove protection action type.*/
59 REMOVE_WATERMARK = 1 << 12, /**< Remove watermarking action type.*/
60 APPLY_LABEL = 1 << 13, /**< Apply label action type.*/
61 RECOMMEND_LABEL = 1 << 14, /**< Recommend label action type.*/
62 PROTECT_ADHOC_DK = 1 << 15, /**< A protect by adhoc policy action type.*/
63 // 1 << 16 reserved
64 PROTECT_DO_NOT_FORWARD_DK = 1 << 17, /**< A protect by do not forward action type with double key.*/
65 PROTECT_BY_ENCRYPT_ONLY = 1 << 18, /**< A protect by encryption only action type.*/
66 ADD_DYNAMIC_WATERMARK = 1 << 19, /**< Add a dynamic watermark to the entire document action type.*/
67 REMOVE_DYNAMIC_WATERMARK = 1 << 20, /**< Remove dynamic watermark action type.*/
68};
69
70/**
71 * @brief Or (|) operator for Action type enum.
72 */
74 return static_cast<ActionType>(static_cast<unsigned int>(a) | static_cast<unsigned int>(b));
75}
76/**
77 * @brief And (&) operator for Action type enum.
78 */
80 return static_cast<ActionType>(static_cast<unsigned int>(a) & static_cast<unsigned int>(b));
81}
82/**
83 * @brief Xor (^) operator for Action type enum.
84 */
86 return static_cast<ActionType>(static_cast<unsigned int>(a) ^ static_cast<unsigned int>(b));
87}
88
89/**
90 * @brief Interface for an action. Each action translates to a step that needs to be taken by the application to apply
91 * the label (as defined in the policy)
92 */
93class Action {
94public:
95 /**
96 * @brief Get the type of Action.
97 *
98 * @return ActionType The type of derived action this base class can be cast to.
99 */
100 virtual ActionType GetType() const = 0;
101 /** @cond DOXYGEN_HIDE */
102 virtual ~Action() {}
103 virtual void Link() {}
104 virtual const std::string& GetId() const { return mId; }
105 virtual bool operator==(const Action& action) const {
106 return ((GetId() == action.GetId()) && (GetType() == action.GetType()) && IsEqual(action));
107 };
108
109protected:
110 virtual bool IsEqual(const Action& action) const = 0;
111 Action() {}
112 Action(const std::string& id) : mId(id) {}
113
114private:
115 std::string mId;
116 /** @endcond */
117};
118
119MIP_NAMESPACE_END
120
121#endif // API_MIP_UPE_ACTION_H_
constexpr ActionType operator|(ActionType a, ActionType b)
Or (|) operator for Action type enum.
Definition action.h:73
constexpr ActionType operator^(ActionType a, ActionType b)
Xor (^) operator for Action type enum.
Definition action.h:85
ActionType
Different action types.
Definition action.h:46
@ REMOVE_CONTENT_FOOTER
Remove content footer action type.
@ APPLY_LABEL
Apply label action type.
@ ADD_DYNAMIC_WATERMARK
Add a dynamic watermark to the entire document action type.
@ ADD_WATERMARK
Add a water mark to the entire document action type.
@ REMOVE_CONTENT_HEADER
Remove content header action type.
@ JUSTIFY
A justify action type.
@ PROTECT_DO_NOT_FORWARD
A protect by do not forward action type.
@ ADD_CONTENT_FOOTER
Add a content footer to the document action type.
@ REMOVE_WATERMARK
Remove watermarking action type.
@ PROTECT_BY_ENCRYPT_ONLY
A protect by encryption only action type.
@ CUSTOM
A custom defined action type.
@ METADATA
A Meta data change action type.
@ REMOVE_DYNAMIC_WATERMARK
Remove dynamic watermark action type.
@ PROTECT_ADHOC
A protect by adhoc policy action type.
@ ADD_CONTENT_HEADER
Add a content header to the document action type.
@ PROTECT_BY_TEMPLATE
A protect by template action type.
@ REMOVE_PROTECTION
Remove protection action type.
@ PROTECT_DO_NOT_FORWARD_DK
A protect by do not forward action type with double key.
@ RECOMMEND_LABEL
Recommend label action type.
@ PROTECT_ADHOC_DK
A protect by adhoc policy action type.
constexpr ActionType operator&(ActionType a, ActionType b)
And (&) operator for Action type enum.
Definition action.h:79
Interface for an action.
Definition action.h:93
virtual ActionType GetType() const =0
Get the type of Action.
MIP namespace macros.