Search in sources :

Example 16 with SecurityException

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

the class XMLConfigAdmin method updateAllowImplicidQueryCall.

/**
 * sets if allowed implicid query call
 * @param allow
 * @throws SecurityException
 */
public void updateAllowImplicidQueryCall(Boolean allow) 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("cascade-to-resultset", Caster.toString(allow, ""));
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException)

Example 17 with SecurityException

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

the class XMLConfigAdmin method updateMailServer.

/**
 * insert or update a mailserver on system
 * @param hostName
 * @param username
 * @param password
 * @param port
 * @param ssl
 * @param tls
 * @throws PageException
 */
public void updateMailServer(int id, String hostName, String username, String password, int port, boolean tls, boolean ssl, long lifeTimeSpan, long idleTimeSpan, boolean reuseConnections) throws PageException {
    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");
    if (port < 1)
        port = 21;
    if (hostName == null || hostName.trim().length() == 0)
        throw new ExpressionException("Host (SMTP) can be a empty value");
    hostName = hostName.trim();
    Element[] children = XMLConfigWebFactory.getChildren(mail, "server");
    boolean checkId = id > 0;
    // Update
    Element server = null;
    String _hostName, _username;
    for (int i = 0; i < children.length; i++) {
        Element el = children[i];
        if (checkId) {
            if (i + 1 == id) {
                server = el;
                break;
            }
        } else {
            _hostName = StringUtil.emptyIfNull(el.getAttribute("smtp"));
            _username = StringUtil.emptyIfNull(el.getAttribute("username"));
            if (_hostName.equalsIgnoreCase(hostName) && _username.equals(StringUtil.emptyIfNull(username))) {
                server = el;
                break;
            }
        }
    }
    // Insert
    if (server == null) {
        server = doc.createElement("server");
        mail.appendChild(XMLCaster.toRawNode(server));
    }
    server.setAttribute("smtp", hostName);
    server.setAttribute("username", username);
    server.setAttribute("password", ConfigWebUtil.encrypt(password));
    server.setAttribute("port", Caster.toString(port));
    server.setAttribute("tls", Caster.toString(tls));
    server.setAttribute("ssl", Caster.toString(ssl));
    server.setAttribute("life", Caster.toString(lifeTimeSpan));
    server.setAttribute("idle", Caster.toString(idleTimeSpan));
    server.setAttribute("reuse-connection", Caster.toString(reuseConnections));
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException) ExpressionException(lucee.runtime.exp.ExpressionException)

Example 18 with SecurityException

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

the class XMLConfigAdmin method updateClientTimeout.

/**
 * updates session timeout value
 * @param span
 * @throws SecurityException
 */
public void updateClientTimeout(TimeSpan span) 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");
    if (span != null)
        scope.setAttribute("clienttimeout", span.getDay() + "," + span.getHour() + "," + span.getMinute() + "," + span.getSecond());
    else
        scope.removeAttribute("clienttimeout");
    // deprecated
    if (scope.hasAttribute("client-max-age"))
        scope.removeAttribute("client-max-age");
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException)

Example 19 with SecurityException

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

the class XMLConfigAdmin method updateRestList.

public void updateRestList(Boolean list) throws SecurityException {
    checkWriteAccess();
    // TODO ConfigWebUtil.hasAccess(config,SecurityManager.TYPE_REST);
    boolean hasAccess = true;
    if (!hasAccess)
        throw new SecurityException("no access to update rest setting");
    Element rest = _getRootElement("rest");
    if (list == null) {
        if (rest.hasAttribute("list"))
            rest.removeAttribute("list");
    } else
        rest.setAttribute("list", Caster.toString(list.booleanValue()));
}
Also used : Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException)

Example 20 with SecurityException

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

the class XMLConfigAdmin method updateRequestTimeout.

/**
 * updates request timeout value
 * @param span
 * @throws SecurityException
 * @throws ApplicationException
 */
public void updateRequestTimeout(TimeSpan span) throws SecurityException, ApplicationException {
    checkWriteAccess();
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_SETTING);
    if (!hasAccess)
        throw new SecurityException("no access to update scope setting");
    Element scope = _getRootElement("scope");
    Element application = _getRootElement("application");
    if (span != null) {
        if (span.getMillis() <= 0)
            throw new ApplicationException("value must be a positive number");
        application.setAttribute("requesttimeout", span.getDay() + "," + span.getHour() + "," + span.getMinute() + "," + span.getSecond());
    } else
        application.removeAttribute("requesttimeout");
    // remove deprecated attribute
    if (scope.hasAttribute("requesttimeout"))
        scope.removeAttribute("requesttimeout");
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) 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