Search in sources :

Example 1 with SecurityManagerImpl

use of lucee.runtime.security.SecurityManagerImpl in project Lucee by lucee.

the class Admin method _fillSecData.

private void _fillSecData(SecurityManager sm) throws PageException {
    Struct sct = new StructImpl();
    pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
    sct.set("cfx_setting", Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_CFX_SETTING) == SecurityManager.VALUE_YES));
    sct.set("cfx_usage", Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_CFX_USAGE) == SecurityManager.VALUE_YES));
    sct.set("custom_tag", Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_CUSTOM_TAG) == SecurityManager.VALUE_YES));
    sct.set(KeyConstants._datasource, _fillSecDataDS(sm.getAccess(SecurityManager.TYPE_DATASOURCE)));
    sct.set("debugging", Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_DEBUGGING) == SecurityManager.VALUE_YES));
    sct.set("direct_java_access", Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_DIRECT_JAVA_ACCESS) == SecurityManager.VALUE_YES));
    sct.set("mail", Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_MAIL) == SecurityManager.VALUE_YES));
    sct.set(KeyConstants._mapping, Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_MAPPING) == SecurityManager.VALUE_YES));
    sct.set("remote", Caster.toBoolean(sm.getAccess(SecurityManagerImpl.TYPE_REMOTE) == SecurityManager.VALUE_YES));
    sct.set("setting", Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_SETTING) == SecurityManager.VALUE_YES));
    sct.set("search", Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_SEARCH) == SecurityManager.VALUE_YES));
    sct.set("scheduled_task", Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_SCHEDULED_TASK) == SecurityManager.VALUE_YES));
    sct.set(KeyConstants._cache, Caster.toBoolean(sm.getAccess(SecurityManagerImpl.TYPE_CACHE) == SecurityManager.VALUE_YES));
    sct.set("gateway", Caster.toBoolean(sm.getAccess(SecurityManagerImpl.TYPE_GATEWAY) == SecurityManager.VALUE_YES));
    sct.set(KeyConstants._orm, Caster.toBoolean(sm.getAccess(SecurityManagerImpl.TYPE_ORM) == SecurityManager.VALUE_YES));
    sct.set("tag_execute", Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_TAG_EXECUTE) == SecurityManager.VALUE_YES));
    sct.set("tag_import", Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_TAG_IMPORT) == SecurityManager.VALUE_YES));
    sct.set("tag_object", Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_TAG_OBJECT) == SecurityManager.VALUE_YES));
    sct.set("tag_registry", Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_TAG_REGISTRY) == SecurityManager.VALUE_YES));
    sct.set("access_read", SecurityManagerImpl.toStringAccessRWValue(sm.getAccess(SecurityManager.TYPE_ACCESS_READ)));
    sct.set("access_write", SecurityManagerImpl.toStringAccessRWValue(sm.getAccess(SecurityManager.TYPE_ACCESS_WRITE)));
    short accessFile = sm.getAccess(SecurityManager.TYPE_FILE);
    String str = SecurityManagerImpl.toStringAccessValue(accessFile);
    if (str.equals("yes"))
        str = "all";
    sct.set(KeyConstants._file, str);
    Array arr = new ArrayImpl();
    if (accessFile != SecurityManager.VALUE_ALL) {
        Resource[] reses = ((SecurityManagerImpl) sm).getCustomFileAccess();
        for (int i = 0; i < reses.length; i++) {
            arr.appendEL(reses[i].getAbsolutePath());
        }
    }
    sct.set("file_access", arr);
}
Also used : Array(lucee.runtime.type.Array) StructImpl(lucee.runtime.type.StructImpl) ArrayImpl(lucee.runtime.type.ArrayImpl) Resource(lucee.commons.io.res.Resource) SecurityManagerImpl(lucee.runtime.security.SecurityManagerImpl) Struct(lucee.runtime.type.Struct)

Example 2 with SecurityManagerImpl

use of lucee.runtime.security.SecurityManagerImpl in project Lucee by lucee.

the class XMLConfigWebFactory method loadSecurity.

/**
 * @param configServer
 * @param config
 * @param doc
 */
private static void loadSecurity(ConfigServerImpl configServer, ConfigImpl config, Document doc) {
    // Serial Number
    if (config instanceof ConfigServer) {
        Element luceeConfiguration = doc.getDocumentElement();
        String serial = getAttr(luceeConfiguration, "serial-number");
        if (!StringUtil.isEmpty(serial))
            config.setSerialNumber(serial);
    } else if (configServer != null) {
        config.setSerialNumber(configServer.getSerialNumber());
    }
    // Security Manger
    SecurityManager securityManager = null;
    if (config instanceof ConfigServerImpl) {
        ConfigServerImpl cs = (ConfigServerImpl) config;
        Element security = getChildByName(doc.getDocumentElement(), "security");
        // Default SecurityManager
        SecurityManagerImpl sm = _toSecurityManager(security);
        // addional file accesss directories
        Element[] elFileAccesses = getChildren(security, "file-access");
        sm.setCustomFileAccess(_loadFileAccess(config, elFileAccesses));
        cs.setDefaultSecurityManager(sm);
        // Web SecurityManager
        Element[] accessors = getChildren(security, "accessor");
        for (int i = 0; i < accessors.length; i++) {
            String id = getAttr(accessors[i], "id");
            if (id != null) {
                sm = _toSecurityManager(accessors[i]);
                elFileAccesses = getChildren(accessors[i], "file-access");
                sm.setCustomFileAccess(_loadFileAccess(config, elFileAccesses));
                cs.setSecurityManager(id, sm);
            }
        }
    } else if (configServer != null) {
        securityManager = configServer.getSecurityManager(config.getIdentification().getId());
    }
    if (config instanceof ConfigWebImpl) {
        if (securityManager == null)
            securityManager = SecurityManagerImpl.getOpenSecurityManager();
        ((ConfigWebImpl) config).setSecurityManager(securityManager);
    }
}
Also used : SecurityManager(lucee.runtime.security.SecurityManager) Element(org.w3c.dom.Element) SecurityManagerImpl(lucee.runtime.security.SecurityManagerImpl) lucee.aprint(lucee.aprint)

Example 3 with SecurityManagerImpl

use of lucee.runtime.security.SecurityManagerImpl in project Lucee by lucee.

the class XMLConfigAdmin method createSecurityManager.

/**
 * creates a individual security manager based on the default security manager
 * @param id
 * @throws DOMException
 * @throws PageException
 */
public void createSecurityManager(Password password, String id) throws DOMException, PageException {
    checkWriteAccess();
    ConfigServerImpl cs = (ConfigServerImpl) ConfigImpl.getConfigServer(config, password);
    SecurityManagerImpl dsm = (SecurityManagerImpl) cs.getDefaultSecurityManager().cloneSecurityManager();
    cs.setSecurityManager(id, dsm);
    Element security = _getRootElement("security");
    Element accessor = null;
    Element[] children = XMLConfigWebFactory.getChildren(security, "accessor");
    for (int i = 0; i < children.length; i++) {
        if (id.equals(children[i].getAttribute("id"))) {
            accessor = children[i];
        }
    }
    if (accessor == null) {
        accessor = doc.createElement("accessor");
        security.appendChild(accessor);
    }
    updateSecurityFileAccess(accessor, dsm.getCustomFileAccess(), dsm.getAccess(SecurityManager.TYPE_FILE));
    accessor.setAttribute("id", id);
    accessor.setAttribute("setting", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_SETTING)));
    accessor.setAttribute("file", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_FILE)));
    accessor.setAttribute("direct_java_access", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_DIRECT_JAVA_ACCESS)));
    accessor.setAttribute("mail", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_MAIL)));
    accessor.setAttribute("datasource", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_DATASOURCE)));
    accessor.setAttribute("mapping", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_MAPPING)));
    accessor.setAttribute("custom_tag", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_CUSTOM_TAG)));
    accessor.setAttribute("cfx_setting", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_CFX_SETTING)));
    accessor.setAttribute("cfx_usage", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_CFX_USAGE)));
    accessor.setAttribute("debugging", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_DEBUGGING)));
    accessor.setAttribute("cache", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManagerImpl.TYPE_CACHE)));
    accessor.setAttribute("gateway", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManagerImpl.TYPE_GATEWAY)));
    accessor.setAttribute("orm", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManagerImpl.TYPE_ORM)));
    accessor.setAttribute("tag_execute", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_TAG_EXECUTE)));
    accessor.setAttribute("tag_import", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_TAG_IMPORT)));
    accessor.setAttribute("tag_object", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_TAG_OBJECT)));
    accessor.setAttribute("tag_registry", SecurityManagerImpl.toStringAccessValue(dsm.getAccess(SecurityManager.TYPE_TAG_REGISTRY)));
}
Also used : Element(org.w3c.dom.Element) SecurityManagerImpl(lucee.runtime.security.SecurityManagerImpl)

Aggregations

SecurityManagerImpl (lucee.runtime.security.SecurityManagerImpl)3 Element (org.w3c.dom.Element)2 lucee.aprint (lucee.aprint)1 Resource (lucee.commons.io.res.Resource)1 SecurityManager (lucee.runtime.security.SecurityManager)1 Array (lucee.runtime.type.Array)1 ArrayImpl (lucee.runtime.type.ArrayImpl)1 Struct (lucee.runtime.type.Struct)1 StructImpl (lucee.runtime.type.StructImpl)1