Class MacroSecurityProcessor
- Namespace
- CMS.MacroEngine
- Assembly
- CMS.MacroEngine.dll
Class providing general macro security parameters processing.
public static class MacroSecurityProcessor
- Inheritance
-
objectMacroSecurityProcessor
Fields
RegExpComplexMacro
Defines a regular expression that detects a complex macro (in case it is matched)
public static CMSRegex RegExpComplexMacro
Field Value
Methods
AddMacroSecurityParams(string, MacroIdentityOption, string, IMacroProcessingColumnAdapter)
Adds |(hash) and |(user) security parameters to given expression.
public static string AddMacroSecurityParams(string expression, MacroIdentityOption identityOption, string saltToUse = null, IMacroProcessingColumnAdapter columnAdapter = null)
Parameters
expressionstringMacro expression to add the parameters to
identityOptionMacroIdentityOptionIdentity option to sign with
saltToUsestringSalt to use for hash function
columnAdapterIMacroProcessingColumnAdapterColumn adapter to use.
Returns
- string
AddSecurityParameters(string, MacroIdentityOption, IDictionary<string, MacroIdentityOption>, string, IMacroProcessingColumnAdapter)
Adds security parameters to every macro.
public static string AddSecurityParameters(string text, MacroIdentityOption identityOption, IDictionary<string, MacroIdentityOption> signatures, string saltToUse = null, IMacroProcessingColumnAdapter columnAdapter = null)
Parameters
textstringText with macros
identityOptionMacroIdentityOptionIdentity option to sign with
signaturesIDictionary<string, MacroIdentityOption>Dictionary with old identity options indexed by expression
saltToUsestringSalt to use for hash function
columnAdapterIMacroProcessingColumnAdapterColumn adapter to use.
Returns
- string
CheckMacroIntegrity(string, MacroIdentityOption)
Checks the integrity against given user.
public static bool CheckMacroIntegrity(string originalExpression, MacroIdentityOption expectedIdentityOption)
Parameters
originalExpressionstringExpression to check
expectedIdentityOptionMacroIdentityOptionIdentity option to check
Returns
- bool
IsSimpleMacro(string)
Returns true if the macro is simple and does not need signing.
public static bool IsSimpleMacro(string expression)
Parameters
expressionstringExpression to check
Returns
- bool
Returns true if expression does not contain none of those characters: .[}
RefreshSecurityParameters(BaseInfo, MacroIdentityOption, bool, string)
Loops through all text columns of given info and signs ALL macros (even already signed) with specified identity option.
public static bool RefreshSecurityParameters(BaseInfo info, MacroIdentityOption identityOption, bool saveObject, string saltToUse = null)
Parameters
infoBaseInfoInfo object to process
identityOptionMacroIdentityOptionIdentity option to sign with
saveObjectboolIf set to true, than saves the object to DB if any macro signature has been changed.
saltToUsestringSalt to use for hash function
Returns
- bool
RefreshSecurityParameters(BaseInfo, string, string, bool)
Loops through all text columns of given info and recreates all the macros signatures according to new specified salt. Keeps the owners of the macros untouched (verifies the integrity against old salt).
public static bool RefreshSecurityParameters(BaseInfo info, string oldSalt, string newSalt, bool saveObject)
Parameters
infoBaseInfoInfo object to process
oldSaltstringOld salt used to generate old signatures (to verify integrity of old macros); if null, the integrity is not checked
newSaltstringNew salt which should be used to generate new signatures
saveObjectboolIf set to true, than saves the object to DB if any macro signature has been changed.
Returns
- bool
RemoveMacroSecurityParams(string, out MacroIdentityOption)
Removes |(hash) and |(user) or |(identity) security parameters from given expression.
public static string RemoveMacroSecurityParams(string expression, out MacroIdentityOption identityOption)
Parameters
expressionstringMacro expression to remove the parameters from
identityOptionMacroIdentityOptionValue of the removed identity option parameter (either macro identity name or user name)
Returns
- string
RemoveMacroSecurityParams(string, out MacroIdentityOption, out string)
Removes |(hash) and |(user) or |(identity) security parameters from given expression.
public static string RemoveMacroSecurityParams(string expression, out MacroIdentityOption identityOption, out string hash)
Parameters
expressionstringMacro expression to remove the parameters from
identityOptionMacroIdentityOptionValue of the removed identity option parameter (either macro identity name or user name)
hashstringValue of the removed hash parameter
Returns
- string
RemoveSecurityParameters(string, bool, IDictionary<string, MacroIdentityOption>, bool)
Removes security parameters from all macros.
public static string RemoveSecurityParameters(string text, bool replaceWithHash, IDictionary<string, MacroIdentityOption> signatures, bool clearSignatures = true)
Parameters
textstringText with macros
replaceWithHashboolIf true, macros which contained security information will be returned with hash at the end
signaturesIDictionary<string, MacroIdentityOption>Dictionary of identity options indexed by expression to be built while removing security parameters
clearSignaturesboolIf true,
signaturesdictionary is cleared before text processing
Returns
- string
RemoveSecurityParametersAndAnonymize(string, IDictionary<string, MacroIdentityOption>)
Marks all macros int the text as anonymous.
[Obsolete("Method was not intended for public use and will be removed in the next version.")]
public static string RemoveSecurityParametersAndAnonymize(string text, IDictionary<string, MacroIdentityOption> signatures)
Parameters
textstringText with macros.
signaturesIDictionary<string, MacroIdentityOption>Dictionary of identity options indexed by expression to be built while removing security parameters
Returns
- string
Text with macros without signatures and marked as anonymous.
Remarks
This is for internal use only. Do not use it.