Search in sources :

Example 6 with TargetType

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

the class FullMappingAuthMech method doGet.

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response, AuthStep step) throws IOException, ServletException {
    HttpSession session = ((HttpServletRequest) request).getSession();
    UrlHolder holder = (UrlHolder) request.getAttribute(ProxyConstants.AUTOIDM_CFG);
    if (holder == null) {
        throw new ServletException("Holder is null");
    }
    RequestHolder reqHolder = ((AuthController) session.getAttribute(ProxyConstants.AUTH_CTL)).getHolder();
    HashMap<String, Attribute> authParams = (HashMap<String, Attribute>) session.getAttribute(ProxyConstants.AUTH_MECH_PARAMS);
    TargetType tt = new TargetType();
    Attribute map = authParams.get("map");
    for (String mapping : map.getValues()) {
        int firstPipe = mapping.indexOf('|');
        int secondPipe = mapping.indexOf('|', firstPipe + 1);
        String destAttr = mapping.substring(0, firstPipe);
        String type = mapping.substring(firstPipe + 1, secondPipe);
        String value = mapping.substring(secondPipe + 1);
        TargetAttributeType tat = new TargetAttributeType();
        tat.setName(destAttr);
        tat.setSourceType(type);
        tat.setSource(value);
        tt.getTargetAttribute().add(tat);
    }
    try {
        MapIdentity mapper = new MapIdentity(tt);
        AuthController ac = ((AuthController) request.getSession().getAttribute(ProxyConstants.AUTH_CTL));
        User orig = new User(ac.getAuthInfo().getUserDN());
        orig.getAttribs().putAll(ac.getAuthInfo().getAttribs());
        User mapped = mapper.mapUser(orig);
        ac.getAuthInfo().getAttribs().clear();
        ac.getAuthInfo().getAttribs().putAll(mapped.getAttribs());
    } catch (ProvisioningException e) {
        throw new ServletException("Could not map user", e);
    }
    step.setSuccess(true);
    holder.getConfig().getAuthManager().nextAuth(request, response, session, false);
}
Also used : User(com.tremolosecurity.provisioning.core.User) Attribute(com.tremolosecurity.saml.Attribute) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) MapIdentity(com.tremolosecurity.provisioning.mapping.MapIdentity) HttpServletRequest(javax.servlet.http.HttpServletRequest) UrlHolder(com.tremolosecurity.config.util.UrlHolder) ServletException(javax.servlet.ServletException) TargetAttributeType(com.tremolosecurity.config.xml.TargetAttributeType) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) TargetType(com.tremolosecurity.config.xml.TargetType)

Example 7 with TargetType

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

the class LoadTargetsFromK8s method deleteObject.

@Override
public void deleteObject(TremoloType cfg, JSONObject item) throws ProvisioningException {
    JSONObject metadata = (JSONObject) item.get("metadata");
    String name = (String) metadata.get("name");
    logger.info("Deleting target '" + name + "'");
    synchronized (this.tremolo.getProvisioning().getTargets().getTarget()) {
        int found = -1;
        int ii = 0;
        for (TargetType tt : this.tremolo.getProvisioning().getTargets().getTarget()) {
            if (tt.getName().equals(name)) {
                found = ii;
                break;
            }
            ii++;
        }
        if (found >= 0) {
            this.tremolo.getProvisioning().getTargets().getTarget().remove(found);
        }
    }
    this.provisioningEngine.removeTarget(name);
}
Also used : JSONObject(org.json.simple.JSONObject) TargetType(com.tremolosecurity.config.xml.TargetType)

Example 8 with TargetType

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

the class WorkflowListClusters method generateWorkflows.

@Override
public List<Map<String, String>> generateWorkflows(WorkflowType wf, ConfigManager cfg, HashMap<String, Attribute> params) throws ProvisioningException {
    List<TargetType> targets = GlobalEntries.getGlobalEntries().getConfigManager().getCfg().getProvisioning().getTargets().getTarget();
    List<Map<String, String>> k8sTargets = new ArrayList<Map<String, String>>();
    for (TargetType tt : targets) {
        if (tt.getClassName().equalsIgnoreCase("com.tremolosecurity.unison.openshiftv3.OpenShiftTarget")) {
            OpenShiftTarget target = (OpenShiftTarget) GlobalEntries.getGlobalEntries().getConfigManager().getProvisioningEngine().getTarget(tt.getName()).getProvider();
            Map<String, String> wfParams = new HashMap<String, String>();
            wfParams.put("cluster", tt.getName());
            wfParams.put("clusterlabel", target.getLabel());
            k8sTargets.add(wfParams);
        }
    }
    return k8sTargets;
}
Also used : HashMap(java.util.HashMap) TargetType(com.tremolosecurity.config.xml.TargetType) ArrayList(java.util.ArrayList) OpenShiftTarget(com.tremolosecurity.unison.openshiftv3.OpenShiftTarget) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

TargetType (com.tremolosecurity.config.xml.TargetType)8 JSONObject (org.json.simple.JSONObject)4 HashMap (java.util.HashMap)3 ParamType (com.tremolosecurity.config.xml.ParamType)2 TargetAttributeType (com.tremolosecurity.config.xml.TargetAttributeType)2 ProvisioningException (com.tremolosecurity.provisioning.core.ProvisioningException)2 Attribute (com.tremolosecurity.saml.Attribute)2 OpenShiftTarget (com.tremolosecurity.unison.openshiftv3.OpenShiftTarget)2 ArrayList (java.util.ArrayList)2 LDAPAttribute (com.novell.ldap.LDAPAttribute)1 UrlHolder (com.tremolosecurity.config.util.UrlHolder)1 DynamicPortalUrlsType (com.tremolosecurity.config.xml.DynamicPortalUrlsType)1 TargetConfigType (com.tremolosecurity.config.xml.TargetConfigType)1 User (com.tremolosecurity.provisioning.core.User)1 MapIdentity (com.tremolosecurity.provisioning.mapping.MapIdentity)1 Targets (com.tremolosecurity.provisioning.objects.Targets)1 DynamicTargets (com.tremolosecurity.provisioning.targets.DynamicTargets)1 HttpCon (com.tremolosecurity.provisioning.util.HttpCon)1 NVP (com.tremolosecurity.util.NVP)1 IOException (java.io.IOException)1