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