Search in sources :

Example 11 with WorkflowType

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

the class LoadWorkflowsFromK8s method createWorkflow.

private WorkflowType createWorkflow(JSONObject item, String name) throws ProvisioningException {
    WorkflowType wft = new WorkflowType();
    JSONObject spec = (JSONObject) item.get("spec");
    String jsonString = spec.toJSONString();
    StringBuffer b = new StringBuffer();
    b.setLength(0);
    OpenUnisonConfigLoader.integrateIncludes(b, jsonString);
    try {
        spec = (JSONObject) new JSONParser().parse(b.toString());
    } catch (ParseException e1) {
        throw new ProvisioningException("Could not parse workflow", e1);
    }
    wft.setName(name);
    wft.setInList(((Boolean) spec.get("inList")));
    wft.setLabel((String) spec.get("label"));
    wft.setOrgid((String) spec.get("orgId"));
    wft.setDescription((String) spec.get("description"));
    JSONObject dynWfJson = (JSONObject) spec.get("dynamicConfiguration");
    if (dynWfJson != null) {
        DynamicWorkflowType dwt = new DynamicWorkflowType();
        wft.setDynamicConfiguration(dwt);
        Boolean isdyn = (Boolean) dynWfJson.get("dynamic");
        if (isdyn != null) {
            dwt.setDynamic(isdyn.booleanValue());
        }
        dwt.setClassName((String) dynWfJson.get("className"));
        JSONArray params = (JSONArray) dynWfJson.get("params");
        for (Object o : params) {
            JSONObject p = (JSONObject) o;
            ParamType pt = new ParamType();
            pt.setName((String) p.get("name"));
            pt.setValue((String) p.get("value"));
            dwt.getParam().add(pt);
        }
    }
    String wfJson = null;
    try {
        wfJson = convertYamlToJson((String) spec.get("tasks"));
        ParsedWorkflow pw = new ParseWorkflow().parseWorkflow(wfJson);
        if (pw.getError() != null) {
            throw new ProvisioningException("Invalid workflow '" + pw.getError() + "', path='" + pw.getErrorPath() + "'");
        }
        wft.setTasks(pw.getWft().getTasks());
    } catch (JsonProcessingException e) {
        throw new ProvisioningException("Could not parse workflow tasks for '" + name + "'", e);
    }
    return wft;
}
Also used : JSONArray(org.json.simple.JSONArray) DynamicWorkflowType(com.tremolosecurity.config.xml.DynamicWorkflowType) ParamType(com.tremolosecurity.config.xml.ParamType) JSONObject(org.json.simple.JSONObject) DynamicWorkflowType(com.tremolosecurity.config.xml.DynamicWorkflowType) WorkflowType(com.tremolosecurity.config.xml.WorkflowType) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) JSONParser(org.json.simple.parser.JSONParser) JSONObject(org.json.simple.JSONObject) ParseException(org.json.simple.parser.ParseException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

WorkflowType (com.tremolosecurity.config.xml.WorkflowType)11 DynamicWorkflowType (com.tremolosecurity.config.xml.DynamicWorkflowType)4 ParamType (com.tremolosecurity.config.xml.ParamType)4 ProvisioningException (com.tremolosecurity.provisioning.core.ProvisioningException)4 Attribute (com.tremolosecurity.saml.Attribute)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 OrgType (com.tremolosecurity.config.xml.OrgType)3 LastMile (com.tremolosecurity.lastmile.LastMile)3 AuthController (com.tremolosecurity.proxy.auth.AuthController)3 AuthInfo (com.tremolosecurity.proxy.auth.AuthInfo)3 AzSys (com.tremolosecurity.proxy.auth.AzSys)3 IOException (java.io.IOException)3 JSONObject (org.json.simple.JSONObject)3 Gson (com.google.gson.Gson)2 LDAPAttribute (com.novell.ldap.LDAPAttribute)2 LDAPException (com.novell.ldap.LDAPException)2 ConfigManager (com.tremolosecurity.config.util.ConfigManager)2 AzRuleType (com.tremolosecurity.config.xml.AzRuleType)2 PortalUrlType (com.tremolosecurity.config.xml.PortalUrlType)2