Search in sources :

Example 36 with SecurityException

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

the class XMLConfigAdmin method updateQueue.

public void updateQueue(Integer max, Integer timeout, Boolean enable) throws SecurityException {
    checkWriteAccess();
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_SETTING);
    if (!hasAccess)
        throw new SecurityException("no access to update queue settings");
    Element queue = _getRootElement("queue");
    // max
    if (max == null)
        queue.removeAttribute("max");
    else
        queue.setAttribute("max", Caster.toString(max, ""));
    // total
    if (timeout == null)
        queue.removeAttribute("timeout");
    else
        queue.setAttribute("timeout", Caster.toString(timeout, ""));
    // enable
    if (enable == null)
        queue.removeAttribute("enable");
    else
        queue.setAttribute("enable", Caster.toString(enable, ""));
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException)

Example 37 with SecurityException

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

the class XMLConfigAdmin method updateTimeServer.

/**
 * update the timeServer
 * @param timeServer
 * @param useTimeServer
 * @throws PageException
 */
public void updateTimeServer(String timeServer, Boolean useTimeServer) throws PageException {
    checkWriteAccess();
    if (useTimeServer != null && useTimeServer.booleanValue() && !StringUtil.isEmpty(timeServer, true)) {
        try {
            new NtpClient(timeServer).getOffset();
        } catch (IOException e) {
            try {
                new NtpClient(timeServer).getOffset();
            } catch (IOException ee) {
                throw Caster.toPageException(ee);
            }
        }
    }
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_SETTING);
    if (!hasAccess)
        throw new SecurityException("no access to update regional setting");
    Element scope = _getRootElement("regional");
    scope.setAttribute("timeserver", timeServer.trim());
    if (useTimeServer != null)
        scope.setAttribute("use-timeserver", Caster.toString(useTimeServer));
    else
        scope.removeAttribute("use-timeserver");
}
Also used : NtpClient(lucee.runtime.net.ntp.NtpClient) Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException) IOException(java.io.IOException)

Example 38 with SecurityException

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

the class XMLConfigAdmin method updateProxy.

public void updateProxy(boolean enabled, String server, int port, String username, String password) throws SecurityException {
    checkWriteAccess();
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_SETTING);
    if (!hasAccess)
        throw new SecurityException("no access to update listener type");
    Element proxy = _getRootElement("proxy");
    proxy.setAttribute("enabled", Caster.toString(enabled));
    if (!StringUtil.isEmpty(server))
        proxy.setAttribute("server", server);
    if (port > 0)
        proxy.setAttribute("port", Caster.toString(port));
    if (!StringUtil.isEmpty(username))
        proxy.setAttribute("username", username);
    if (!StringUtil.isEmpty(password))
        proxy.setAttribute("password", password);
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException)

Example 39 with SecurityException

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

the class XMLConfigAdmin method updateSessionManagement.

/*public void removeProxy() throws SecurityException {
        boolean hasAccess=ConfigWebUtil.hasAccess(config,SecurityManager.TYPE_SETTING);
        if(!hasAccess) throw new SecurityException("no access to remove proxy settings");
        
        Element proxy=_getRootElement("proxy");
        proxy.removeAttribute("server");
        proxy.removeAttribute("port");
        proxy.removeAttribute("username");
        proxy.removeAttribute("password");
    }*/
/**
 * enable or desable session management
 * @param sessionManagement
 * @throws SecurityException
 */
public void updateSessionManagement(Boolean sessionManagement) 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("scope");
    scope.setAttribute("sessionmanagement", Caster.toString(sessionManagement, ""));
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException)

Example 40 with SecurityException

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

the class XMLConfigAdmin method updateCacheDefaultConnection.

public void updateCacheDefaultConnection(int type, String name) throws PageException {
    checkWriteAccess();
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManagerImpl.TYPE_CACHE);
    if (!hasAccess)
        throw new SecurityException("no access to update cache default connections");
    Element parent = _getRootElement("cache");
    if (type == ConfigImpl.CACHE_TYPE_OBJECT) {
        parent.setAttribute("default-object", name);
    } else if (type == ConfigImpl.CACHE_TYPE_TEMPLATE) {
        parent.setAttribute("default-template", name);
    } else if (type == ConfigImpl.CACHE_TYPE_QUERY) {
        parent.setAttribute("default-query", name);
    } else if (type == ConfigImpl.CACHE_TYPE_RESOURCE) {
        parent.setAttribute("default-resource", name);
    } else if (type == ConfigImpl.CACHE_TYPE_FUNCTION) {
        parent.setAttribute("default-function", name);
    } else if (type == ConfigImpl.CACHE_TYPE_INCLUDE) {
        parent.setAttribute("default-include", name);
    } else if (type == ConfigImpl.CACHE_TYPE_HTTP) {
        parent.setAttribute("default-http", name);
    } else if (type == ConfigImpl.CACHE_TYPE_FILE) {
        parent.setAttribute("default-file", name);
    } else if (type == ConfigImpl.CACHE_TYPE_WEBSERVICE) {
        parent.setAttribute("default-webservice", name);
    }
}
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