Microsoft Information Protection (MIP) SDK for C++: Reference 1.16
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
NoPermissionsExtendedError Class Referenceabstract

The user could not get access to the content due to extended Access checks like ABAC. More...

#include <src/api/mip/error.h>

Inheritance diagram for NoPermissionsExtendedError:
Collaboration diagram for NoPermissionsExtendedError:

Public Types

enum class  Category {
  Unknown = 0 , UserNotFound = 1 , AccessDenied = 2 , AccessExpired = 3 ,
  InvalidEmail = 4 , UnknownTenant = 5 , NotOwner = 6 , NotPremiumLicenseUser = 7 ,
  ClientVersionNotSupported = 8
}
 Category of no permissions error. More...
 

Public Member Functions

void AddDebugInfo (const std::string &key, const std::string &value, bool sensitive=false)
 Add debug info entry.
 
virtual std::shared_ptr< ErrorClone () const =0
 Clone the error.
 
Category GetCategory () const
 Gets the category of no permissions failure.
 
const std::map< std::string, std::string > & GetDebugInfo () const
 Get debug info.
 
const std::string & GetErrorName () const
 Get the error name.
 
virtual ErrorType GetErrorType () const
 Get the error type.
 
const std::string & GetMessage (bool maskPII=false) const
 Get the error message.
 
std::string GetOwner () const
 Gets the owner of the document.
 
std::string GetReferrer () const
 Gets the contact in case of missing rights to the document.
 
void SetMessage (const std::string &msg)
 Set the error message.
 
char const * what () const noexcept override
 Get the error message.
 

Public Attributes

std::map< std::string, std::string > mDebugInfo
 
std::string mMessage
 
std::string mName
 
ErrorType mType
 

Private Member Functions

void AddExtendedErrorInfoToDebugInfo (const std::vector< ExtendedErrorInfo > &extendedErrorInfo)
 
std::string CreateFormattedMessage (const std::string &message) const
 
const std::string & GetCategoryString (Category category) const
 

Private Attributes

Category mCategory
 
std::vector< ExtendedErrorInfomExtendedErrorInfo
 
std::string mFormattedMessage
 
std::string mMaskedMessage
 
std::string mOwner
 
std::string mReferrer
 

Detailed Description

The user could not get access to the content due to extended Access checks like ABAC.

Definition at line 782 of file error.h.

Member Enumeration Documentation

◆ Category

enum class NoPermissionsError::Category
stronginherited

Category of no permissions error.

Enumerator
Unknown 

Unknown no permissions failure

UserNotFound 

Requested user was not found failure

AccessDenied 

Access to content or action was not permitted

AccessExpired 

Access to content or action has expired

InvalidEmail 
UnknownTenant 
NotOwner 

User needs to be owner to perform action

NotPremiumLicenseUser 

User needs to be a premium license holder to perform action. Tracking and Revocation for example

ClientVersionNotSupported 

User needs to update their client in order to support features used within this document >

Definition at line 677 of file error.h.

677 {
678 Unknown = 0, /**< Unknown no permissions failure */
679 UserNotFound = 1, /**< Requested user was not found failure */
680 AccessDenied = 2, /**< Access to content or action was not permitted */
681 AccessExpired = 3, /**< Access to content or action has expired */
682 InvalidEmail = 4,
683 UnknownTenant = 5,
684 NotOwner = 6, /**< User needs to be owner to perform action */
685 NotPremiumLicenseUser = 7, /**< User needs to be a premium license holder to perform action. Tracking and Revocation for example */
686 ClientVersionNotSupported = 8, /**< User needs to update their client in order to support features used within this document >*/
687 };

Member Function Documentation

◆ AddDebugInfo()

void Error::AddDebugInfo ( const std::string & key,
const std::string & value,
bool sensitive = false )
inlineinherited

Add debug info entry.

Parameters
keyDebug info key
valueDebug info value

Definition at line 179 of file error.h.

179 {
180 if (!key.empty() && !value.empty()) {
181 mDebugInfo[key] = value;
182 mFormattedMessage = mFormattedMessage + ", " + key + "=" + value;
183 mMaskedMessage = mMaskedMessage + ", " + key + "=" + (sensitive ? "***" : value);
184 }
185 }
std::map< std::string, std::string > mDebugInfo
Definition error.h:225
std::string mMaskedMessage
Definition error.h:241
std::string mFormattedMessage
Definition error.h:240

References Error::mDebugInfo, Error::mFormattedMessage, and Error::mMaskedMessage.

Referenced by AddExtendedErrorInfoToDebugInfo(), DelegateResponseError::DelegateResponseError(), DelegateResponseError::DelegateResponseError(), and DelegateResponseError::DelegateResponseError().

◆ AddExtendedErrorInfoToDebugInfo()

void NoPermissionsExtendedError::AddExtendedErrorInfoToDebugInfo ( const std::vector< ExtendedErrorInfo > & extendedErrorInfo)
inlineprivate

Definition at line 813 of file error.h.

813 {
814 std::stringstream codesStream;
815 std::stringstream messagesStream;
816 std::stringstream detailsStream;
817
818 static const std::string seperator = ",";
819 static const std::string objSeperator = ";";
820 static const std::string mapElementSeperator = "|";
821 for (size_t i = 0; i < extendedErrorInfo.size(); i++) {
822 codesStream << extendedErrorInfo[i].code;
823 messagesStream << extendedErrorInfo[i].message;
824 std::map<std::string, std::string>::const_iterator detailsIter = extendedErrorInfo[i].details.begin();
825 while (detailsIter != extendedErrorInfo[i].details.end()) {
826 detailsStream << detailsIter->first << seperator << detailsIter->second;
827 detailsIter++;
828 if (detailsIter != extendedErrorInfo[i].details.end()) {
829 detailsStream << mapElementSeperator;
830 }
831 }
832
833 if (i + 1 < extendedErrorInfo.size()) {
834 codesStream << objSeperator;
835 messagesStream << objSeperator;
836 detailsStream << objSeperator;
837 }
838 }
839
840 if (!extendedErrorInfo.empty()) {
841 AddDebugInfo(GetErrorInfoCodesKey(), codesStream.str());
842 AddDebugInfo(GetErrorInfoMessagesKey(), messagesStream.str());
843 AddDebugInfo(GetErrorInfoDetailsKey(), detailsStream.str());
844 }
845 }
void AddDebugInfo(const std::string &key, const std::string &value, bool sensitive=false)
Add debug info entry.
Definition error.h:179
constexpr const char * GetErrorInfoCodesKey()
Definition error.h:64
constexpr const char * GetErrorInfoDetailsKey()
Definition error.h:68
constexpr const char * GetErrorInfoMessagesKey()
Definition error.h:66

References Error::AddDebugInfo(), anonymous_namespace{error.h}::GetErrorInfoCodesKey(), anonymous_namespace{error.h}::GetErrorInfoDetailsKey(), and anonymous_namespace{error.h}::GetErrorInfoMessagesKey().

◆ Clone()

virtual std::shared_ptr< Error > Error::Clone ( ) const
pure virtualinherited

Clone the error.

Returns
a clone of the error.

Implemented in JustificationRequiredError.

◆ CreateFormattedMessage()

std::string Error::CreateFormattedMessage ( const std::string & message) const
inlineprivateinherited

Definition at line 230 of file error.h.

230 {
231 auto formattedMessage = message;
232
233 // Remove stray newlines
234 auto isNewlineFn = [](char c) { return c == '\n' || c == '\r'; };
235 formattedMessage.erase(std::remove_if(formattedMessage.begin(), formattedMessage.end(), isNewlineFn), formattedMessage.end());
236
237 return formattedMessage;
238 }

◆ GetCategory()

Category NoPermissionsError::GetCategory ( ) const
inlineinherited

Gets the category of no permissions failure.

Returns
Category of no permissions failure

Definition at line 755 of file error.h.

755{ return mCategory; }
Category mCategory
Definition error.h:758

References NoPermissionsError::mCategory.

◆ GetCategoryString()

const std::string & NoPermissionsError::GetCategoryString ( Category category) const
inlineprivateinherited

Definition at line 762 of file error.h.

762 {
763 static const std::string kUnrecognized = "UNRECOGNIZED";
764 static const std::map<Category, std::string> kCategories = {
765 { Category::Unknown, "Unknown" },
766 { Category::UserNotFound, "UserNotFound" },
767 { Category::AccessDenied, "AccessDenied" },
768 { Category::AccessExpired, "AccessExpired" },
769 { Category::InvalidEmail, "InvalidEmail" },
770 { Category::UnknownTenant, "UnknownTenant" },
771 { Category::NotOwner, "NotOwner" },
772 { Category::NotPremiumLicenseUser, "NotPremiumLicenseUser" },
773 { Category::ClientVersionNotSupported, "ClientVersionNotSupported" }
774 };
775 return kCategories.count(category) ? kCategories.at(category) : kUnrecognized;
776 }

References NoPermissionsError::AccessDenied, NoPermissionsError::AccessExpired, NoPermissionsError::ClientVersionNotSupported, NoPermissionsError::InvalidEmail, NoPermissionsError::NotOwner, NoPermissionsError::NotPremiumLicenseUser, NoPermissionsError::Unknown, NoPermissionsError::UnknownTenant, and NoPermissionsError::UserNotFound.

◆ GetDebugInfo()

const std::map< std::string, std::string > & Error::GetDebugInfo ( ) const
inlineinherited

Get debug info.

Returns
Debug info (keys/values)

Definition at line 192 of file error.h.

192{ return mDebugInfo; }

References Error::mDebugInfo.

◆ GetErrorName()

const std::string & Error::GetErrorName ( ) const
inlineinherited

Get the error name.

Returns
the error name.

Definition at line 144 of file error.h.

144{ return mName; }
std::string mName
Definition error.h:226

References Error::mName.

◆ GetErrorType()

virtual ErrorType Error::GetErrorType ( ) const
inlinevirtualinherited

Get the error type.

Returns
the error type.

Definition at line 137 of file error.h.

137{ return mType; }
ErrorType mType
Definition error.h:227

References Error::mType.

◆ GetMessage()

const std::string & Error::GetMessage ( bool maskPII = false) const
inlineinherited

Get the error message.

Returns
the error message.

Definition at line 151 of file error.h.

151 {
152 return maskPII ? mMaskedMessage : mFormattedMessage;
153 }

References Error::mFormattedMessage, and Error::mMaskedMessage.

◆ GetOwner()

std::string NoPermissionsError::GetOwner ( ) const
inlineinherited

Gets the owner of the document.

Returns
Document owner

Definition at line 748 of file error.h.

748{ return mOwner; }
std::string mOwner
Definition error.h:760

References NoPermissionsError::mOwner.

◆ GetReferrer()

std::string NoPermissionsError::GetReferrer ( ) const
inlineinherited

Gets the contact in case of missing rights to the document.

Returns
The contact in case of missing rights to the document.

Definition at line 741 of file error.h.

741{ return mReferrer; }
std::string mReferrer
Definition error.h:759

References NoPermissionsError::mReferrer.

◆ SetMessage()

void Error::SetMessage ( const std::string & msg)
inlineinherited

Set the error message.

Parameters
msgthe error message.

Definition at line 160 of file error.h.

160 {
161 std::string* targetStrings[] = { &mFormattedMessage, &mMaskedMessage };
162 for (auto* targetString : targetStrings) {
163 size_t pos = targetString->find(mMessage);
164 if (pos != std::string::npos) {
165 targetString->replace(pos, mMessage.length(), msg);
166 } else {
167 targetString->replace(0, 0, msg);
168 }
169 }
170 mMessage = msg;
171 }
std::string mMessage
Definition error.h:224

References Error::mFormattedMessage, Error::mMaskedMessage, and Error::mMessage.

◆ what()

char const * Error::what ( ) const
inlineoverridenoexceptinherited

Get the error message.

Returns
the error message

Definition at line 121 of file error.h.

121 {
122 return mFormattedMessage.c_str();
123 }

References Error::mFormattedMessage.

Member Data Documentation

◆ mCategory

Category NoPermissionsError::mCategory
privateinherited

Definition at line 758 of file error.h.

Referenced by NoPermissionsError::GetCategory().

◆ mDebugInfo

std::map<std::string, std::string> Error::mDebugInfo
inherited

Definition at line 225 of file error.h.

Referenced by Error::AddDebugInfo(), and Error::GetDebugInfo().

◆ mExtendedErrorInfo

std::vector<ExtendedErrorInfo> NoPermissionsExtendedError::mExtendedErrorInfo
private

Definition at line 847 of file error.h.

◆ mFormattedMessage

std::string Error::mFormattedMessage
privateinherited

Definition at line 240 of file error.h.

Referenced by Error::AddDebugInfo(), Error::GetMessage(), Error::SetMessage(), and Error::what().

◆ mMaskedMessage

std::string Error::mMaskedMessage
privateinherited

Definition at line 241 of file error.h.

Referenced by Error::AddDebugInfo(), Error::GetMessage(), and Error::SetMessage().

◆ mMessage

std::string Error::mMessage
inherited

Definition at line 224 of file error.h.

Referenced by DelegateResponseError::DelegateResponseError(), and Error::SetMessage().

◆ mName

std::string Error::mName
inherited

Definition at line 226 of file error.h.

Referenced by Error::GetErrorName().

◆ mOwner

std::string NoPermissionsError::mOwner
privateinherited

Definition at line 760 of file error.h.

Referenced by NoPermissionsError::GetOwner().

◆ mReferrer

std::string NoPermissionsError::mReferrer
privateinherited

Definition at line 759 of file error.h.

Referenced by NoPermissionsError::GetReferrer().

◆ mType

ErrorType Error::mType
inherited

Definition at line 227 of file error.h.

Referenced by Error::GetErrorType().


The documentation for this class was generated from the following file: