Search in sources :

Example 1 with Targets

use of com.tremolosecurity.provisioning.objects.Targets in project OpenUnison by TremoloSecurity.

the class SendMessageThread method generateTargets.

private void generateTargets(ConfigManager cfgMgr) throws ProvisioningException {
    if (cfgMgr.getCfg().getProvisioning() == null) {
        return;
    }
    this.targetIDs = new HashMap<String, Targets>();
    Iterator<TargetType> it = cfgMgr.getCfg().getProvisioning().getTargets().getTarget().iterator();
    while (it.hasNext()) {
        TargetType targetCfg = it.next();
        addTarget(cfgMgr, targetCfg);
    }
    if (cfgMgr.getCfg().getProvisioning().getTargets().getDynamicTargets() != null && cfgMgr.getCfg().getProvisioning().getTargets().getDynamicTargets().isEnabled()) {
        DynamicPortalUrlsType dynamicTargets = cfgMgr.getCfg().getProvisioning().getTargets().getDynamicTargets();
        String className = dynamicTargets.getClassName();
        HashMap<String, Attribute> cfgAttrs = new HashMap<String, Attribute>();
        for (ParamType pt : dynamicTargets.getParams()) {
            Attribute attr = cfgAttrs.get(pt.getName());
            if (attr == null) {
                attr = new Attribute(pt.getName());
                cfgAttrs.put(pt.getName(), attr);
            }
            attr.getValues().add(pt.getValue());
        }
        try {
            DynamicTargets dynTargets = (DynamicTargets) Class.forName(className).newInstance();
            dynTargets.loadDynamicTargets(cfgMgr, this, cfgAttrs);
        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
            throw new ProvisioningException("Could not initialize dynamic targets", e);
        }
    }
}
Also used : DynamicTargets(com.tremolosecurity.provisioning.targets.DynamicTargets) Attribute(com.tremolosecurity.saml.Attribute) LDAPAttribute(com.novell.ldap.LDAPAttribute) HashMap(java.util.HashMap) DynamicTargets(com.tremolosecurity.provisioning.targets.DynamicTargets) Targets(com.tremolosecurity.provisioning.objects.Targets) ParamType(com.tremolosecurity.config.xml.ParamType) DynamicPortalUrlsType(com.tremolosecurity.config.xml.DynamicPortalUrlsType) TargetType(com.tremolosecurity.config.xml.TargetType)

Example 2 with Targets

use of com.tremolosecurity.provisioning.objects.Targets in project OpenUnison by TremoloSecurity.

the class SendMessageThread method addTargetToDb.

private void addTargetToDb(TargetType targetCfg) {
    if (sessionFactory != null && this.cfgMgr.getCfg().getProvisioning() != null && this.cfgMgr.getCfg().getProvisioning().getApprovalDB() != null && this.cfgMgr.getCfg().getProvisioning().getApprovalDB().isEnabled()) {
        org.hibernate.Session session = sessionFactory.openSession();
        try {
            List<Targets> targets = session.createCriteria(Targets.class).list();
            for (Targets target : targets) {
                this.targetIDs.put(target.getName(), target);
            }
            session.beginTransaction();
            if (!this.targetIDs.containsKey(targetCfg.getName())) {
                Targets target = new Targets();
                target.setName(targetCfg.getName());
                session.save(target);
                this.targetIDs.put(target.getName(), target);
            }
            session.getTransaction().commit();
        } finally {
            session.close();
        }
    }
}
Also used : DynamicTargets(com.tremolosecurity.provisioning.targets.DynamicTargets) Targets(com.tremolosecurity.provisioning.objects.Targets)

Aggregations

Targets (com.tremolosecurity.provisioning.objects.Targets)2 DynamicTargets (com.tremolosecurity.provisioning.targets.DynamicTargets)2 LDAPAttribute (com.novell.ldap.LDAPAttribute)1 DynamicPortalUrlsType (com.tremolosecurity.config.xml.DynamicPortalUrlsType)1 ParamType (com.tremolosecurity.config.xml.ParamType)1 TargetType (com.tremolosecurity.config.xml.TargetType)1 Attribute (com.tremolosecurity.saml.Attribute)1 HashMap (java.util.HashMap)1