Search in sources :

Example 1 with MacroPermissionPolicy

use of org.xwiki.rendering.macro.script.MacroPermissionPolicy in project xwiki-platform by xwiki.

the class DefaultScriptMacroPermissionPolicy method hasPermission.

@Override
public boolean hasPermission(ScriptMacroParameters parameters, MacroTransformationContext context) {
    boolean hasPermission;
    try {
        MacroPermissionPolicy policy = this.componentManager.getInstance(MacroPermissionPolicy.class, ((DefaultScriptMacroParameters) parameters).getLanguage());
        hasPermission = policy.hasPermission(parameters, context);
    } catch (ComponentLookupException e) {
        // No policy for that Macro, use the default implementation which forbids execution if the doc doesn't
        // have Programming Rights.
        hasPermission = super.hasPermission(parameters, context);
    }
    return hasPermission;
}
Also used : AbstractScriptMacroPermissionPolicy(org.xwiki.rendering.macro.script.AbstractScriptMacroPermissionPolicy) MacroPermissionPolicy(org.xwiki.rendering.macro.script.MacroPermissionPolicy) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException)

Aggregations

ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)1 AbstractScriptMacroPermissionPolicy (org.xwiki.rendering.macro.script.AbstractScriptMacroPermissionPolicy)1 MacroPermissionPolicy (org.xwiki.rendering.macro.script.MacroPermissionPolicy)1