Search in sources :

Example 6 with SecurityException

use of lucee.runtime.exp.SecurityException in project Lucee by lucee.

the class XMLConfigAdmin method updateCPPCFX.

public void updateCPPCFX(String name, String procedure, String strServerLibrary, boolean keepAlive) throws PageException {
    checkWriteAccess();
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_CFX_SETTING);
    if (!hasAccess)
        throw new SecurityException("no access to change cfx settings");
    // name
    if (StringUtil.isEmpty(name))
        throw new ExpressionException("name cannot be a empty value");
    // serverLibrary
    if (StringUtil.isEmpty(strServerLibrary))
        throw new ExpressionException("serverLibrary cannot be a empty value");
    Resource serverLibrary = ResourceUtil.toResourceExisting(config, strServerLibrary);
    // procedure
    if (StringUtil.isEmpty(procedure))
        throw new ExpressionException("procedure cannot be a empty value");
    renameOldstyleCFX();
    Element tags = _getRootElement("ext-tags");
    // Update
    Element[] children = XMLConfigWebFactory.getChildren(tags, "ext-tag");
    for (int i = 0; i < children.length; i++) {
        String n = children[i].getAttribute("name");
        if (n != null && n.equalsIgnoreCase(name)) {
            Element el = children[i];
            if (!"cpp".equalsIgnoreCase(el.getAttribute("type")))
                throw new ExpressionException("there is already a java cfx tag with this name");
            el.setAttribute("server-library", serverLibrary.getAbsolutePath());
            el.setAttribute("procedure", procedure);
            el.setAttribute("keep-alive", Caster.toString(keepAlive));
            el.setAttribute("type", "cpp");
            return;
        }
    }
    // Insert
    Element el = doc.createElement("ext-tag");
    tags.appendChild(el);
    el.setAttribute("server-library", serverLibrary.getAbsolutePath());
    el.setAttribute("procedure", procedure);
    el.setAttribute("keep-alive", Caster.toString(keepAlive));
    el.setAttribute("name", name);
    el.setAttribute("type", "cpp");
}
Also used : Element(org.w3c.dom.Element) Resource(lucee.commons.io.res.Resource) SecurityException(lucee.runtime.exp.SecurityException) ExpressionException(lucee.runtime.exp.ExpressionException)

Example 7 with SecurityException

use of lucee.runtime.exp.SecurityException in project Lucee by lucee.

the class XMLConfigAdmin method updateCachedWithin.

public void updateCachedWithin(int type, Object value) throws SecurityException, ApplicationException {
    checkWriteAccess();
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_SETTING);
    if (!hasAccess)
        throw new SecurityException("no access to update cachedwithin setting");
    String t = AppListenerUtil.toCachedWithinType(type, "");
    if (t == null)
        throw new ApplicationException("invalid cachedwithin type defintion");
    String v = Caster.toString(value, null);
    Element app = _getRootElement("application");
    if (v != null)
        app.setAttribute("cached-within-" + t, v);
    else
        app.removeAttribute("cached-within-" + t);
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException)

Example 8 with SecurityException

use of lucee.runtime.exp.SecurityException in project Lucee by lucee.

the class XMLConfigAdmin method updateComponentDataMemberDefaultAccess.

/**
 * update the Component Data Member default access type
 * @param strAccess
 * @throws SecurityException
 * @throws ExpressionException
 */
public void updateComponentDataMemberDefaultAccess(String strAccess) throws SecurityException, ApplicationException {
    checkWriteAccess();
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_SETTING);
    if (!hasAccess)
        throw new SecurityException("no access to update component setting");
    Element scope = _getRootElement("component");
    if (StringUtil.isEmpty(strAccess)) {
        scope.setAttribute("data-member-default-access", "");
    } else {
        scope.setAttribute("data-member-default-access", ComponentUtil.toStringAccess(ComponentUtil.toIntAccess(strAccess)));
    }
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException)

Example 9 with SecurityException

use of lucee.runtime.exp.SecurityException in project Lucee by lucee.

the class XMLConfigAdmin method updateContentLength.

public void updateContentLength(Boolean value) throws SecurityException {
    checkWriteAccess();
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_SETTING);
    if (!hasAccess)
        throw new SecurityException("no access to update scope setting");
    Element scope = _getRootElement("setting");
    scope.setAttribute("content-length", Caster.toString(value, ""));
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException)

Example 10 with SecurityException

use of lucee.runtime.exp.SecurityException in project Lucee by lucee.

the class XMLConfigAdmin method updateComponentPathCache.

public void updateComponentPathCache(Boolean componentPathCache) throws SecurityException {
    checkWriteAccess();
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_SETTING);
    if (!hasAccess)
        throw new SecurityException("no access to update component Cache Path");
    Element scope = _getRootElement("component");
    if (!Caster.toBooleanValue(componentPathCache, false))
        config.clearComponentCache();
    scope.setAttribute("use-cache-path", Caster.toString(componentPathCache, ""));
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException)

Aggregations

SecurityException (lucee.runtime.exp.SecurityException)91 Element (org.w3c.dom.Element)83 ExpressionException (lucee.runtime.exp.ExpressionException)14 SecurityManager (lucee.runtime.security.SecurityManager)6 ApplicationException (lucee.runtime.exp.ApplicationException)5 IOException (java.io.IOException)4 Resource (lucee.commons.io.res.Resource)2 ClassException (lucee.commons.lang.ClassException)2 PageException (lucee.runtime.exp.PageException)2 ServiceException (coldfusion.server.ServiceException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 UnknownHostException (java.net.UnknownHostException)1 SQLException (java.sql.SQLException)1 Entry (java.util.Map.Entry)1 lucee.aprint (lucee.aprint)1 Cache (lucee.commons.io.cache.Cache)1 FileResourceProvider (lucee.commons.io.res.type.file.FileResourceProvider)1 CacheConnection (lucee.runtime.cache.CacheConnection)1 CFXTagException (lucee.runtime.cfx.CFXTagException)1