Search in sources :

Example 11 with OrgType

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

the class ScaleMain method checkOrg.

private void checkOrg(HashSet<String> allowedOrgs, OrgType ot, AzSys az, AuthInfo auinfo, HttpSession session) 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, session, this.appType, new HashMap<String, Object>())) {
            return;
        }
    }
    allowedOrgs.add(ot.getUuid());
    for (OrgType child : ot.getOrgs()) {
        checkOrg(allowedOrgs, child, az, auinfo, session);
    }
}
Also used : AzRuleType(com.tremolosecurity.config.xml.AzRuleType) 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)

Example 12 with OrgType

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

the class ListOrgs method doGet.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String userID = req.getParameter("uid");
    String uidAttr = req.getParameter("uidAttr");
    try {
        StringBuffer b = new StringBuffer();
        b.append("(").append(uidAttr).append("=").append(userID).append(")");
        LDAPSearchResults res = GlobalEntries.getGlobalEntries().getConfigManager().getMyVD().search(GlobalEntries.getGlobalEntries().getConfigManager().getCfg().getLdapRoot(), 2, equal(uidAttr, userID).toString(), new ArrayList<String>());
        if (!res.hasMore()) {
            throw new ProvisioningException("Could not locate user '" + userID + "'");
        }
        LDAPEntry entry = res.next();
        AuthInfo auinfo = new AuthInfo();
        auinfo.setUserDN(entry.getDN());
        LDAPAttributeSet attrs = entry.getAttributeSet();
        for (Object obj : attrs) {
            LDAPAttribute attr = (LDAPAttribute) obj;
            Attribute attrib = new Attribute(attr.getName());
            String[] vals = attr.getStringValueArray();
            for (String val : vals) {
                attrib.getValues().add(val);
            }
            auinfo.getAttribs().put(attrib.getName(), attrib);
        }
        AzSys az = new AzSys();
        OrgType ot = GlobalEntries.getGlobalEntries().getConfigManager().getCfg().getProvisioning().getOrg();
        Organization org = new Organization();
        copyOrg(org, ot, az, auinfo);
        Gson gson = new Gson();
        ProvisioningResult pres = new ProvisioningResult();
        pres.setSuccess(true);
        pres.setOrg(org);
        resp.getOutputStream().print(gson.toJson(pres));
    } catch (Exception e) {
        ProvisioningError pe = new ProvisioningError();
        pe.setError("Could not load orgs : " + e.getMessage());
        ProvisioningResult res = new ProvisioningResult();
        res.setSuccess(false);
        res.setError(pe);
        Gson gson = new Gson();
        resp.getWriter().write(gson.toJson(res));
        logger.error("Could not load orgs", e);
    }
}
Also used : LDAPAttribute(com.novell.ldap.LDAPAttribute) AuthInfo(com.tremolosecurity.proxy.auth.AuthInfo) Organization(com.tremolosecurity.provisioning.service.util.Organization) LDAPAttribute(com.novell.ldap.LDAPAttribute) Attribute(com.tremolosecurity.saml.Attribute) LDAPAttributeSet(com.novell.ldap.LDAPAttributeSet) ProvisioningResult(com.tremolosecurity.provisioning.service.util.ProvisioningResult) Gson(com.google.gson.Gson) LDAPException(com.novell.ldap.LDAPException) ServletException(javax.servlet.ServletException) MalformedURLException(java.net.MalformedURLException) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) IOException(java.io.IOException) LDAPEntry(com.novell.ldap.LDAPEntry) LDAPSearchResults(com.novell.ldap.LDAPSearchResults) ProvisioningError(com.tremolosecurity.provisioning.service.util.ProvisioningError) OrgType(com.tremolosecurity.config.xml.OrgType) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) AzSys(com.tremolosecurity.proxy.auth.AzSys)

Example 13 with OrgType

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

the class ListReports method doGet.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String userID = req.getParameter("uid");
    String uidAttr = req.getParameter("uidAttr");
    try {
        StringBuffer b = new StringBuffer();
        LDAPSearchResults res = GlobalEntries.getGlobalEntries().getConfigManager().getMyVD().search(GlobalEntries.getGlobalEntries().getConfigManager().getCfg().getLdapRoot(), 2, equal(uidAttr, userID).toString(), new ArrayList<String>());
        if (!res.hasMore()) {
            throw new ProvisioningException("Could not locate user '" + userID + "'");
        }
        LDAPEntry entry = res.next();
        AuthInfo auinfo = new AuthInfo();
        auinfo.setUserDN(entry.getDN());
        LDAPAttributeSet attrs = entry.getAttributeSet();
        for (Object obj : attrs) {
            LDAPAttribute attr = (LDAPAttribute) obj;
            Attribute attrib = new Attribute(attr.getName());
            String[] vals = attr.getStringValueArray();
            for (String val : vals) {
                attrib.getValues().add(val);
            }
            auinfo.getAttribs().put(attrib.getName(), attrib);
        }
        AzSys az = new AzSys();
        HashSet<String> allowedOrgs = new HashSet<String>();
        OrgType root = GlobalEntries.getGlobalEntries().getConfigManager().getCfg().getProvisioning().getOrg();
        this.checkOrg(allowedOrgs, root, az, auinfo);
        ReportsType reports = GlobalEntries.getGlobalEntries().getConfigManager().getCfg().getProvisioning().getReports();
        ReportsList reportsList = new ReportsList();
        reportsList.setReports(new ArrayList<ReportInformation>());
        for (ReportType report : reports.getReport()) {
            if (allowedOrgs.contains(report.getOrgID())) {
                ReportInformation ri = new ReportInformation();
                ri.setName(report.getName());
                ri.setDescription(report.getDescription());
                ri.setOrgID(report.getOrgID());
                ri.setParameters(new ArrayList<String>());
                ri.getParameters().addAll(report.getParamater());
                reportsList.getReports().add(ri);
            }
        }
        Gson gson = new Gson();
        ProvisioningResult pres = new ProvisioningResult();
        pres.setSuccess(true);
        pres.setReportsList(reportsList);
        resp.getOutputStream().print(gson.toJson(pres));
    } catch (Exception e) {
        ProvisioningError pe = new ProvisioningError();
        pe.setError("Could not load urls : " + e.getMessage());
        ProvisioningResult res = new ProvisioningResult();
        res.setSuccess(false);
        res.setError(pe);
        Gson gson = new Gson();
        resp.getWriter().write(gson.toJson(res));
        logger.error("Could not load urls", e);
    }
}
Also used : LDAPAttribute(com.novell.ldap.LDAPAttribute) Attribute(com.tremolosecurity.saml.Attribute) Gson(com.google.gson.Gson) ReportInformation(com.tremolosecurity.provisioning.service.util.ReportInformation) LDAPEntry(com.novell.ldap.LDAPEntry) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) ReportType(com.tremolosecurity.config.xml.ReportType) HashSet(java.util.HashSet) LDAPAttribute(com.novell.ldap.LDAPAttribute) AuthInfo(com.tremolosecurity.proxy.auth.AuthInfo) ReportsList(com.tremolosecurity.provisioning.service.util.ReportsList) LDAPAttributeSet(com.novell.ldap.LDAPAttributeSet) ProvisioningResult(com.tremolosecurity.provisioning.service.util.ProvisioningResult) ServletException(javax.servlet.ServletException) MalformedURLException(java.net.MalformedURLException) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) IOException(java.io.IOException) LDAPSearchResults(com.novell.ldap.LDAPSearchResults) ProvisioningError(com.tremolosecurity.provisioning.service.util.ProvisioningError) OrgType(com.tremolosecurity.config.xml.OrgType) AzSys(com.tremolosecurity.proxy.auth.AzSys) ReportsType(com.tremolosecurity.config.xml.ReportsType)

Example 14 with OrgType

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

the class OrgTypeHolder method loadDynamicOrgs.

@Override
public void loadDynamicOrgs(ConfigManager cfgMgr, ProvisioningEngine provisioningEngine, Map<String, Attribute> init) throws ProvisioningException {
    this.tremolo = cfgMgr.getCfg();
    String k8sTarget = init.get("k8starget").getValues().get(0);
    String namespace = init.get("namespace").getValues().get(0);
    String uri = "/apis/openunison.tremolo.io/v1/namespaces/" + namespace + "/orgs";
    this.orphanes = new HashMap<String, OrgType>();
    this.k8sWatch = new K8sWatcher(k8sTarget, namespace, uri, this, cfgMgr, provisioningEngine);
    this.k8sWatch.initalRun();
}
Also used : OrgType(com.tremolosecurity.config.xml.OrgType) K8sWatcher(com.tremolosecurity.k8s.watch.K8sWatcher)

Aggregations

OrgType (com.tremolosecurity.config.xml.OrgType)14 AzRuleType (com.tremolosecurity.config.xml.AzRuleType)7 AuthInfo (com.tremolosecurity.proxy.auth.AuthInfo)7 AzSys (com.tremolosecurity.proxy.auth.AzSys)7 ArrayList (java.util.ArrayList)7 ConfigManager (com.tremolosecurity.config.util.ConfigManager)6 HashSet (java.util.HashSet)6 AuthController (com.tremolosecurity.proxy.auth.AuthController)5 AzRule (com.tremolosecurity.proxy.az.AzRule)5 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 LDAPAttribute (com.novell.ldap.LDAPAttribute)4 ReportType (com.tremolosecurity.config.xml.ReportType)4 ProvisioningException (com.tremolosecurity.provisioning.core.ProvisioningException)4 Organization (com.tremolosecurity.provisioning.service.util.Organization)4 Attribute (com.tremolosecurity.saml.Attribute)4 ScaleError (com.tremolosecurity.scalejs.data.ScaleError)4 RichTextString (org.apache.poi.ss.usermodel.RichTextString)4 XSSFRichTextString (org.apache.poi.xssf.usermodel.XSSFRichTextString)4 Gson (com.google.gson.Gson)3