Search in sources :

Example 1 with ActionExtensionSecurityCallback

use of org.olat.core.extensions.action.ActionExtensionSecurityCallback in project OpenOLAT by OpenOLAT.

the class AbstractExtension method getActionExtensionSecurityCallback.

/**
 * returns the defined securityCallback, if none was defined a default SecurityCallback is returned
 */
public ActionExtensionSecurityCallback getActionExtensionSecurityCallback() {
    ActionExtensionSecurityCallback securityCallback = null;
    if (secCallbackName != null) {
        // try to lazy instantiate the callback Object
        Class<?> cclazz;
        Exception re = null;
        try {
            cclazz = Thread.currentThread().getContextClassLoader().loadClass(secCallbackName);
            Object o = cclazz.newInstance();
            securityCallback = (ActionExtensionSecurityCallback) o;
        } catch (ClassNotFoundException e) {
            re = e;
        } catch (SecurityException e) {
            re = e;
        } catch (IllegalArgumentException e) {
            re = e;
        } catch (InstantiationException e) {
            re = e;
        } catch (IllegalAccessException e) {
            re = e;
        } finally {
            if (re != null) {
                throw new AssertException("Could not create ActionExtensionSecurityCallback via reflection. classname: " + secCallbackName, re);
            }
        }
    } else {
        // load a default callback
        ActionExtensionSecurityCallback aescDefault = new ActionExtensionSecurityCallback() {

            @Override
            public boolean isAllowedToLaunchActionController(UserRequest ureq) {
                return true;
            }
        };
        securityCallback = aescDefault;
    }
    return securityCallback;
}
Also used : AssertException(org.olat.core.logging.AssertException) ActionExtensionSecurityCallback(org.olat.core.extensions.action.ActionExtensionSecurityCallback) AssertException(org.olat.core.logging.AssertException) UserRequest(org.olat.core.gui.UserRequest)

Example 2 with ActionExtensionSecurityCallback

use of org.olat.core.extensions.action.ActionExtensionSecurityCallback in project openolat by klemens.

the class AbstractExtension method getActionExtensionSecurityCallback.

/**
 * returns the defined securityCallback, if none was defined a default SecurityCallback is returned
 */
public ActionExtensionSecurityCallback getActionExtensionSecurityCallback() {
    ActionExtensionSecurityCallback securityCallback = null;
    if (secCallbackName != null) {
        // try to lazy instantiate the callback Object
        Class<?> cclazz;
        Exception re = null;
        try {
            cclazz = Thread.currentThread().getContextClassLoader().loadClass(secCallbackName);
            Object o = cclazz.newInstance();
            securityCallback = (ActionExtensionSecurityCallback) o;
        } catch (ClassNotFoundException e) {
            re = e;
        } catch (SecurityException e) {
            re = e;
        } catch (IllegalArgumentException e) {
            re = e;
        } catch (InstantiationException e) {
            re = e;
        } catch (IllegalAccessException e) {
            re = e;
        } finally {
            if (re != null) {
                throw new AssertException("Could not create ActionExtensionSecurityCallback via reflection. classname: " + secCallbackName, re);
            }
        }
    } else {
        // load a default callback
        ActionExtensionSecurityCallback aescDefault = new ActionExtensionSecurityCallback() {

            @Override
            public boolean isAllowedToLaunchActionController(UserRequest ureq) {
                return true;
            }
        };
        securityCallback = aescDefault;
    }
    return securityCallback;
}
Also used : AssertException(org.olat.core.logging.AssertException) ActionExtensionSecurityCallback(org.olat.core.extensions.action.ActionExtensionSecurityCallback) AssertException(org.olat.core.logging.AssertException) UserRequest(org.olat.core.gui.UserRequest)

Aggregations

ActionExtensionSecurityCallback (org.olat.core.extensions.action.ActionExtensionSecurityCallback)2 UserRequest (org.olat.core.gui.UserRequest)2 AssertException (org.olat.core.logging.AssertException)2