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);
}
}
}
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();
}
}
}
Aggregations