Search in sources :

Example 1 with MappingType

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

the class ParseWorkflow method createMappingTask.

private void createMappingTask(JSONObject node, String path, List<WorkflowTaskType> parent, ParsedWorkflow pw) {
    MappingType task = new MappingType();
    OptionType[] options = new OptionType[] { new OptionType("strict", false, OptionType.OptionValueType.BOOLEAN) };
    for (OptionType ot : options) {
        setAttribute(node, ot, task, MappingType.class, pw, path);
        if (pw.getError() != null) {
            return;
        }
    }
    task.setMap(new ProvisionMappingsType());
    Object o = node.get("map");
    node.remove("map");
    if (o == null) {
        pw.setError("map required and must be an array");
        pw.setErrorPath(path);
        return;
    }
    if (!(o instanceof JSONArray)) {
        pw.setError("map must be an array");
        pw.setErrorPath(path);
        return;
    }
    int ii = 0;
    JSONArray map = (JSONArray) o;
    for (Object oo : map) {
        if (!(oo instanceof JSONObject)) {
            pw.setError("All map entries must be objects");
            pw.setErrorPath(path + ".map[" + ii + "]");
            ii++;
            return;
        }
        JSONObject mapNode = (JSONObject) oo;
        options = new OptionType[] { new OptionType("targetAttributeName", true, OptionType.OptionValueType.STRING), new OptionType("sourceType", true, OptionType.OptionValueType.STRING), new OptionType("targetAttributeSource", true, OptionType.OptionValueType.STRING) };
        ProvisionMappingType pmt = new ProvisionMappingType();
        for (OptionType ot : options) {
            setAttribute(mapNode, ot, pmt, ProvisionMappingType.class, pw, path);
            if (pw.getError() != null) {
                return;
            }
        }
        if (!mapNode.isEmpty()) {
            pw.setError("Extra JSON keys : " + mapNode.toString());
            pw.setErrorPath(path + ".map[" + ii + "]");
            return;
        }
        task.getMap().getMapping().add(pmt);
    }
    loadSubTasks(node, path, pw, task);
    if (pw.getError() != null) {
        return;
    }
    if (!node.isEmpty()) {
        pw.setError("Extra JSON keys : " + node.toString());
        pw.setErrorPath(path);
        return;
    }
    parent.add(task);
}
Also used : ProvisionMappingType(com.tremolosecurity.config.xml.ProvisionMappingType) MappingType(com.tremolosecurity.config.xml.MappingType) ProvisionMappingsType(com.tremolosecurity.config.xml.ProvisionMappingsType) JSONObject(org.json.simple.JSONObject) JSONArray(org.json.simple.JSONArray) JSONObject(org.json.simple.JSONObject) ProvisionMappingType(com.tremolosecurity.config.xml.ProvisionMappingType)

Example 2 with MappingType

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

the class Mapping method init.

@Override
public void init(WorkflowTaskType taskConfig) throws ProvisioningException {
    MappingType mapCfg = (MappingType) taskConfig;
    this.strict = mapCfg.isStrict();
    this.mapper = new MapIdentity(mapCfg.getMap());
}
Also used : MappingType(com.tremolosecurity.config.xml.MappingType) MapIdentity(com.tremolosecurity.provisioning.mapping.MapIdentity)

Aggregations

MappingType (com.tremolosecurity.config.xml.MappingType)2 ProvisionMappingType (com.tremolosecurity.config.xml.ProvisionMappingType)1 ProvisionMappingsType (com.tremolosecurity.config.xml.ProvisionMappingsType)1 MapIdentity (com.tremolosecurity.provisioning.mapping.MapIdentity)1 JSONArray (org.json.simple.JSONArray)1 JSONObject (org.json.simple.JSONObject)1