Table of Contents

Class MacroSecurityProcessor

Namespace
CMS.MacroEngine
Assembly
CMS.MacroEngine.dll

Class providing general macro security parameters processing.

public static class MacroSecurityProcessor
Inheritance
object
MacroSecurityProcessor

Fields

RegExpComplexMacro

Defines a regular expression that detects a complex macro (in case it is matched)

public static CMSRegex RegExpComplexMacro

Field Value

CMSRegex

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

expression string

Macro expression to add the parameters to

identityOption MacroIdentityOption

Identity option to sign with

saltToUse string

Salt to use for hash function

columnAdapter IMacroProcessingColumnAdapter

Column 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

text string

Text with macros

identityOption MacroIdentityOption

Identity option to sign with

signatures IDictionary<string, MacroIdentityOption>

Dictionary with old identity options indexed by expression

saltToUse string

Salt to use for hash function

columnAdapter IMacroProcessingColumnAdapter

Column adapter to use.

Returns

string

CheckMacroIntegrity(string, MacroIdentityOption)

Checks the integrity against given user.

public static bool CheckMacroIntegrity(string originalExpression, MacroIdentityOption expectedIdentityOption)

Parameters

originalExpression string

Expression to check

expectedIdentityOption MacroIdentityOption

Identity 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

expression string

Expression 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

info BaseInfo

Info object to process

identityOption MacroIdentityOption

Identity option to sign with

saveObject bool

If set to true, than saves the object to DB if any macro signature has been changed.

saltToUse string

Salt 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

info BaseInfo

Info object to process

oldSalt string

Old salt used to generate old signatures (to verify integrity of old macros); if null, the integrity is not checked

newSalt string

New salt which should be used to generate new signatures

saveObject bool

If 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

expression string

Macro expression to remove the parameters from

identityOption MacroIdentityOption

Value 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

expression string

Macro expression to remove the parameters from

identityOption MacroIdentityOption

Value of the removed identity option parameter (either macro identity name or user name)

hash string

Value 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

text string

Text with macros

replaceWithHash bool

If true, macros which contained security information will be returned with hash at the end

signatures IDictionary<string, MacroIdentityOption>

Dictionary of identity options indexed by expression to be built while removing security parameters

clearSignatures bool

If true, signatures dictionary 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.")]
[ObsoleteSince(28, 3)]
public static string RemoveSecurityParametersAndAnonymize(string text, IDictionary<string, MacroIdentityOption> signatures)

Parameters

text string

Text with macros.

signatures IDictionary<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.