Search in sources :

Example 76 with SecurityException

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

the class XMLConfigAdmin method setMailSpoolEnable.

/**
 * sets if spool is enable or not
 * @param spoolEnable
 * @throws SecurityException
 */
public void setMailSpoolEnable(Boolean spoolEnable) throws SecurityException {
    checkWriteAccess();
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_MAIL);
    if (!hasAccess)
        throw new SecurityException("no access to update mail server settings");
    Element mail = _getRootElement("mail");
    mail.setAttribute("spool-enable", Caster.toString(spoolEnable, ""));
// config.setMailSpoolEnable(spoolEnable);
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException)

Example 77 with SecurityException

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

the class XMLConfigAdmin method setMailTimeout.

/* *
     * sets if er interval is enable or not
     * @param interval
     * @throws SecurityException
     * /
    public void setMailSpoolInterval(Integer interval) throws SecurityException {
    	checkWriteAccess();
    	boolean hasAccess=ConfigWebUtil.hasAccess(config,SecurityManager.TYPE_MAIL);
        if(!hasAccess)
            throw new SecurityException("no access to update mail server settings");
        Element mail=_getRootElement("mail");
        mail.setAttribute("spool-interval",Caster.toString(interval,""));
        //config.setMailSpoolInterval(interval);
    }*/
/**
 * sets the timeout for the spooler for one job
 * @param timeout
 * @throws SecurityException
 */
public void setMailTimeout(Integer timeout) throws SecurityException {
    checkWriteAccess();
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_MAIL);
    if (!hasAccess)
        throw new SecurityException("no access to update mail server settings");
    Element mail = _getRootElement("mail");
    mail.setAttribute("timeout", Caster.toString(timeout, ""));
// config.setMailTimeout(timeout);
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException)

Example 78 with SecurityException

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

the class XMLConfigAdmin method updateJavaCFX.

/**
 * insert or update a Java CFX Tag
 * @param name
 * @param strClass
 * @throws PageException
 */
public void updateJavaCFX(String name, ClassDefinition cd) throws PageException {
    checkWriteAccess();
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_CFX_SETTING);
    if (!hasAccess)
        throw new SecurityException("no access to change cfx settings");
    if (name == null || name.length() == 0)
        throw new ExpressionException("class name can't 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 (!"java".equalsIgnoreCase(el.getAttribute("type")))
                throw new ExpressionException("there is already a c++ cfx tag with this name");
            setClass(el, CustomTag.class, "", cd);
            el.setAttribute("type", "java");
            return;
        }
    }
    // Insert
    Element el = doc.createElement("ext-tag");
    tags.appendChild(el);
    setClass(el, CustomTag.class, "", cd);
    el.setAttribute("name", name);
    el.setAttribute("type", "java");
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException) ExpressionException(lucee.runtime.exp.ExpressionException)

Example 79 with SecurityException

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

the class XMLConfigAdmin method _updateMapping.

private void _updateMapping(String virtual, String physical, String archive, String primary, short inspect, boolean toplevel, int listenerMode, int listenerType, boolean readOnly) throws ExpressionException, SecurityException {
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_MAPPING);
    virtual = virtual.trim();
    if (physical == null)
        physical = "";
    else
        physical = physical.trim();
    if (archive == null)
        archive = "";
    else
        archive = archive.trim();
    primary = primary.trim();
    if (!hasAccess)
        throw new SecurityException("no access to update mappings");
    // check virtual
    if (virtual == null || virtual.length() == 0)
        throw new ExpressionException("virtual path cannot be a empty value");
    virtual = virtual.replace('\\', '/');
    if (!virtual.equals("/") && virtual.endsWith("/"))
        virtual = virtual.substring(0, virtual.length() - 1);
    if (virtual.charAt(0) != '/')
        throw new ExpressionException("virtual path must start with [/]");
    boolean isArchive = primary.equalsIgnoreCase("archive");
    if ((physical.length() + archive.length()) == 0)
        throw new ExpressionException("physical or archive must have a value");
    if (isArchive && archive.length() == 0)
        isArchive = false;
    if (!isArchive && archive.length() > 0 && physical.length() == 0)
        isArchive = true;
    Element mappings = _getRootElement("mappings");
    // do we already have a record for it?
    Element[] children = XMLConfigWebFactory.getChildren(mappings, "mapping");
    Element el = null;
    for (int i = 0; i < children.length; i++) {
        String v = children[i].getAttribute("virtual");
        if (v != null) {
            if (!v.equals("/") && v.endsWith("/"))
                v = v.substring(0, v.length() - 1);
            if (v.equals(virtual)) {
                el = children[i];
                el.removeAttribute("trusted");
                break;
            }
        }
    }
    // create element if necessary
    boolean update = el != null;
    if (el == null) {
        el = doc.createElement("mapping");
        mappings.appendChild(el);
        el.setAttribute("virtual", virtual);
    }
    // physical
    if (physical.length() > 0) {
        el.setAttribute("physical", physical);
    } else if (el.hasAttribute("physical")) {
        el.removeAttribute("physical");
    }
    // archive
    if (archive.length() > 0) {
        el.setAttribute("archive", archive);
    } else if (el.hasAttribute("archive")) {
        el.removeAttribute("archive");
    }
    // primary
    el.setAttribute("primary", isArchive ? "archive" : "physical");
    // listener-type
    String type = ConfigWebUtil.toListenerType(listenerType, null);
    if (type != null) {
        el.setAttribute("listener-type", type);
    } else if (el.hasAttribute("listener-type")) {
        el.removeAttribute("listener-type");
    }
    // listener-mode
    String mode = ConfigWebUtil.toListenerMode(listenerMode, null);
    if (mode != null) {
        el.setAttribute("listener-mode", mode);
    } else if (el.hasAttribute("listener-mode")) {
        el.removeAttribute("listener-mode");
    }
    // others
    el.setAttribute("inspect-template", ConfigWebUtil.inspectTemplate(inspect, ""));
    el.setAttribute("toplevel", Caster.toString(toplevel));
    el.setAttribute("readonly", Caster.toString(readOnly));
    // set / to the end
    if (!update) {
        children = XMLConfigWebFactory.getChildren(mappings, "mapping");
        for (int i = 0; i < children.length; i++) {
            String v = children[i].getAttribute("virtual");
            if (v != null && v.equals("/")) {
                el = children[i];
                mappings.removeChild(el);
                mappings.appendChild(el);
                return;
            }
        }
    }
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException) ExpressionException(lucee.runtime.exp.ExpressionException)

Example 80 with SecurityException

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

the class XMLConfigAdmin method updateRemoteClient.

public void updateRemoteClient(String label, String url, String type, String securityKey, String usage, String adminPassword, String serverUsername, String serverPassword, String proxyServer, String proxyUsername, String proxyPassword, String proxyPort) throws PageException {
    checkWriteAccess();
    // SNSN
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManagerImpl.TYPE_REMOTE);
    if (!hasAccess)
        throw new SecurityException("no access to update remote client settings");
    Element clients = _getRootElement("remote-clients");
    if (StringUtil.isEmpty(url))
        throw new ExpressionException("url can be a empty value");
    if (StringUtil.isEmpty(securityKey))
        throw new ExpressionException("securityKey can be a empty value");
    if (StringUtil.isEmpty(adminPassword))
        throw new ExpressionException("adminPassword can be a empty value");
    url = url.trim();
    securityKey = securityKey.trim();
    adminPassword = adminPassword.trim();
    Element[] children = XMLConfigWebFactory.getChildren(clients, "remote-client");
    // Update
    for (int i = 0; i < children.length; i++) {
        Element el = children[i];
        String _url = el.getAttribute("url");
        if (_url != null && _url.equalsIgnoreCase(url)) {
            el.setAttribute("label", label);
            el.setAttribute("type", type);
            el.setAttribute("usage", usage);
            el.setAttribute("server-username", serverUsername);
            el.setAttribute("proxy-server", proxyServer);
            el.setAttribute("proxy-username", proxyUsername);
            el.setAttribute("proxy-port", proxyPort);
            el.setAttribute("security-key", ConfigWebUtil.encrypt(securityKey));
            el.setAttribute("admin-password", ConfigWebUtil.encrypt(adminPassword));
            el.setAttribute("server-password", ConfigWebUtil.encrypt(serverPassword));
            el.setAttribute("proxy-password", ConfigWebUtil.encrypt(proxyPassword));
            return;
        }
    }
    // Insert
    Element el = doc.createElement("remote-client");
    el.setAttribute("label", label);
    el.setAttribute("url", url);
    el.setAttribute("type", type);
    el.setAttribute("usage", usage);
    el.setAttribute("server-username", serverUsername);
    el.setAttribute("proxy-server", proxyServer);
    el.setAttribute("proxy-username", proxyUsername);
    el.setAttribute("proxy-port", proxyPort);
    el.setAttribute("security-key", ConfigWebUtil.encrypt(securityKey));
    el.setAttribute("admin-password", ConfigWebUtil.encrypt(adminPassword));
    el.setAttribute("server-password", ConfigWebUtil.encrypt(serverPassword));
    el.setAttribute("proxy-password", ConfigWebUtil.encrypt(proxyPassword));
    clients.appendChild(el);
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException) ExpressionException(lucee.runtime.exp.ExpressionException)

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