Search in sources :

Example 1 with AzRuleType

use of com.tremolosecurity.config.xml.AzRuleType in project OpenUnison by TremoloSecurity.

the class ListOrgs method copyOrg.

private void copyOrg(Organization org, OrgType ot, AzSys az, AuthInfo auinfo) throws MalformedURLException, ProvisioningException {
    ConfigManager cfgMgr = GlobalEntries.getGlobalEntries().getConfigManager();
    if (ot.getAzRules() != null && ot.getAzRules().getRule().size() > 0) {
        ArrayList<AzRule> rules = new ArrayList<AzRule>();
        for (AzRuleType art : ot.getAzRules().getRule()) {
            rules.add(new AzRule(art.getScope(), art.getConstraint(), art.getClassName(), cfgMgr, null));
        }
        if (!az.checkRules(auinfo, cfgMgr, rules, null)) {
            return;
        }
    }
    org.setId(ot.getUuid());
    org.setName(ot.getName());
    org.setDescription(ot.getDescription());
    for (OrgType child : ot.getOrgs()) {
        Organization sub = new Organization();
        org.getSubOrgs().add(sub);
        copyOrg(sub, child, az, auinfo);
    }
}
Also used : AzRuleType(com.tremolosecurity.config.xml.AzRuleType) Organization(com.tremolosecurity.provisioning.service.util.Organization) OrgType(com.tremolosecurity.config.xml.OrgType) ArrayList(java.util.ArrayList) AzRule(com.tremolosecurity.proxy.az.AzRule) ConfigManager(com.tremolosecurity.config.util.ConfigManager)

Example 2 with AzRuleType

use of com.tremolosecurity.config.xml.AzRuleType in project OpenUnison by TremoloSecurity.

the class ListReports method checkOrg.

private void checkOrg(HashSet<String> allowedOrgs, OrgType ot, AzSys az, AuthInfo auinfo) throws MalformedURLException, ProvisioningException {
    ConfigManager cfgMgr = GlobalEntries.getGlobalEntries().getConfigManager();
    if (ot.getAzRules() != null && ot.getAzRules().getRule().size() > 0) {
        ArrayList<AzRule> rules = new ArrayList<AzRule>();
        for (AzRuleType art : ot.getAzRules().getRule()) {
            rules.add(new AzRule(art.getScope(), art.getConstraint(), art.getClassName(), cfgMgr, null));
        }
        if (!az.checkRules(auinfo, cfgMgr, rules, null)) {
            return;
        }
    }
    allowedOrgs.add(ot.getUuid());
    for (OrgType child : ot.getOrgs()) {
        checkOrg(allowedOrgs, child, az, auinfo);
    }
}
Also used : AzRuleType(com.tremolosecurity.config.xml.AzRuleType) OrgType(com.tremolosecurity.config.xml.OrgType) ArrayList(java.util.ArrayList) AzRule(com.tremolosecurity.proxy.az.AzRule) ConfigManager(com.tremolosecurity.config.util.ConfigManager)

Example 3 with AzRuleType

use of com.tremolosecurity.config.xml.AzRuleType in project OpenUnison by TremoloSecurity.

the class OrgTypeHolder method addOrg.

private void addOrg(TremoloType tremolo, Object o) {
    JSONObject trustObj = (JSONObject) o;
    JSONObject metadata = (JSONObject) trustObj.get("metadata");
    JSONObject spec = (JSONObject) trustObj.get("spec");
    logger.info(metadata.get("name"));
    StringBuffer b = new StringBuffer();
    OrgType org = new OrgType();
    String label = (String) spec.get("label");
    if (label == null) {
        org.setName((String) metadata.get("name"));
    } else {
        b.setLength(0);
        OpenUnisonConfigLoader.integrateIncludes(b, label);
        org.setName(b.toString());
    }
    if (spec.get("description") != null) {
        b.setLength(0);
        OpenUnisonConfigLoader.integrateIncludes(b, (String) spec.get("description"));
        org.setDescription(b.toString());
    }
    b.setLength(0);
    OpenUnisonConfigLoader.integrateIncludes(b, (String) spec.get("uuid"));
    org.setUuid(b.toString());
    org.setShowInPortal(((Boolean) spec.get("showInPortal")));
    org.setShowInReports(((Boolean) spec.get("showInReports")));
    org.setShowInRequestsAccess(((Boolean) spec.get("showInRequestAccess")));
    org.setAzRules(new AzRulesType());
    String parentId = (String) spec.get("parent");
    JSONArray rules = (JSONArray) spec.get("azRules");
    for (Object orr : rules) {
        JSONObject rule = (JSONObject) orr;
        AzRuleType art = new AzRuleType();
        b.setLength(0);
        OpenUnisonConfigLoader.integrateIncludes(b, (String) rule.get("scope"));
        art.setScope(b.toString());
        b.setLength(0);
        OpenUnisonConfigLoader.integrateIncludes(b, (String) rule.get("constraint"));
        art.setConstraint(b.toString());
        org.getAzRules().getRule().add(art);
    }
    OrgType parent = this.findById(parentId, tremolo.getProvisioning().getOrg());
    if (parent == null) {
        for (String oid : this.orphanes.keySet()) {
            OrgType orphan = this.orphanes.get(oid);
            parent = this.findById(parentId, orphan);
            if (parent != null) {
                break;
            }
        }
    }
    if (parent == null) {
        OrgType oot = new OrgType();
        oot.setUuid(parentId);
        oot.setAzRules(new AzRulesType());
        oot.getOrgs().add(org);
        this.orphanes.put(parentId, oot);
    } else {
        this.deleteOrg(tremolo, org.getUuid());
        parent.getOrgs().add(org);
    }
    if (this.orphanes.containsKey(org.getUuid())) {
        OrgType oot = this.orphanes.remove(org.getUuid());
        org.getOrgs().addAll(oot.getOrgs());
    }
}
Also used : AzRuleType(com.tremolosecurity.config.xml.AzRuleType) JSONObject(org.json.simple.JSONObject) AzRulesType(com.tremolosecurity.config.xml.AzRulesType) OrgType(com.tremolosecurity.config.xml.OrgType) JSONArray(org.json.simple.JSONArray) JSONObject(org.json.simple.JSONObject)

Example 4 with AzRuleType

use of com.tremolosecurity.config.xml.AzRuleType in project OpenUnison by TremoloSecurity.

the class AzFilter method doFilter.

@Override
public void doFilter(HttpFilterRequest request, HttpFilterResponse response, HttpFilterChain chain) throws Exception {
    HttpSession session = request.getSession();
    AuthInfo authData = ((AuthController) request.getSession().getAttribute(ProxyConstants.AUTH_CTL)).getAuthInfo();
    UrlHolder holder = (UrlHolder) request.getAttribute(ProxyConstants.AUTOIDM_CFG);
    List<AzRuleType> rules = holder.getUrl().getAzRules().getRule();
    boolean OK = az.checkRules(authData, holder.getConfig(), holder.getAzRules(), null);
    if (OK) {
        String respGroup = az.getResponseSuccessGroup(holder);
        AccessLog.log(AccessEvent.AzSuccess, holder.getApp(), request.getServletRequest(), authData, respGroup != null ? respGroup : "NONE");
        if (respGroup != null) {
            az.processRequestResult(request.getServletRequest(), response.getServletResponse(), holder.getConfig().getResultGroup(respGroup), authData);
        }
        chain.nextFilter(request, response, chain);
        if (respGroup != null) {
            az.proccessResponseResult(request.getServletRequest(), response.getServletResponse(), holder.getConfig().getResultGroup(respGroup), false, authData, holder.getApp().getCookieConfig());
        }
    } else {
        String respGroup = az.getResponseFailGroup(holder);
        AccessLog.log(AccessEvent.AzFail, holder.getApp(), request.getServletRequest(), authData, respGroup != null ? respGroup : "NONE");
        if (respGroup != null) {
            az.proccessResponseResult(request.getServletRequest(), response.getServletResponse(), holder.getConfig().getResultGroup(respGroup), true, authData, holder.getApp().getCookieConfig());
        } else {
            ((HttpServletResponse) response).sendError(401);
        }
    }
}
Also used : UrlHolder(com.tremolosecurity.config.util.UrlHolder) AzRuleType(com.tremolosecurity.config.xml.AzRuleType) AuthInfo(com.tremolosecurity.proxy.auth.AuthInfo) HttpSession(javax.servlet.http.HttpSession) HttpServletResponse(javax.servlet.http.HttpServletResponse) AuthController(com.tremolosecurity.proxy.auth.AuthController)

Example 5 with AzRuleType

use of com.tremolosecurity.config.xml.AzRuleType in project OpenUnison by TremoloSecurity.

the class ScaleMain method copyOrg.

private boolean copyOrg(Organization org, OrgType ot, AzSys az, AuthInfo auinfo) throws MalformedURLException, ProvisioningException {
    ConfigManager cfgMgr = GlobalEntries.getGlobalEntries().getConfigManager();
    if (ot.getAzRules() != null && ot.getAzRules().getRule().size() > 0) {
        ArrayList<AzRule> rules = new ArrayList<AzRule>();
        for (AzRuleType art : ot.getAzRules().getRule()) {
            rules.add(new AzRule(art.getScope(), art.getConstraint(), art.getClassName(), cfgMgr, null));
        }
        if (!az.checkRules(auinfo, cfgMgr, rules, new HashMap<String, Object>())) {
            return false;
        }
    }
    org.setId(ot.getUuid());
    org.setName(ot.getName());
    org.setDescription(ot.getDescription());
    org.setShowInPortal(ot.isShowInPortal());
    org.setShowInReports(ot.isShowInReports());
    org.setShowInRequest(ot.isShowInRequestsAccess());
    for (OrgType child : ot.getOrgs()) {
        Organization sub = new Organization();
        if (copyOrg(sub, child, az, auinfo)) {
            org.getSubOrgs().add(sub);
        }
    }
    return true;
}
Also used : AzRuleType(com.tremolosecurity.config.xml.AzRuleType) Organization(com.tremolosecurity.provisioning.service.util.Organization) HashMap(java.util.HashMap) OrgType(com.tremolosecurity.config.xml.OrgType) ArrayList(java.util.ArrayList) AzRule(com.tremolosecurity.proxy.az.AzRule) ConfigManager(com.tremolosecurity.config.util.ConfigManager)

Aggregations

AzRuleType (com.tremolosecurity.config.xml.AzRuleType)12 ConfigManager (com.tremolosecurity.config.util.ConfigManager)6 OrgType (com.tremolosecurity.config.xml.OrgType)6 AzRule (com.tremolosecurity.proxy.az.AzRule)6 ArrayList (java.util.ArrayList)6 JSONArray (org.json.simple.JSONArray)4 JSONObject (org.json.simple.JSONObject)4 AzRulesType (com.tremolosecurity.config.xml.AzRulesType)3 PortalUrlType (com.tremolosecurity.config.xml.PortalUrlType)3 Organization (com.tremolosecurity.provisioning.service.util.Organization)3 AuthInfo (com.tremolosecurity.proxy.auth.AuthInfo)3 HashMap (java.util.HashMap)3 Gson (com.google.gson.Gson)2 UrlHolder (com.tremolosecurity.config.util.UrlHolder)2 PortalUrlsType (com.tremolosecurity.config.xml.PortalUrlsType)2 ProvisioningException (com.tremolosecurity.provisioning.core.ProvisioningException)2 PortalURL (com.tremolosecurity.provisioning.service.util.PortalURL)2 PortalURLs (com.tremolosecurity.provisioning.service.util.PortalURLs)2 AuthController (com.tremolosecurity.proxy.auth.AuthController)2 AzSys (com.tremolosecurity.proxy.auth.AzSys)2