use of com.tremolosecurity.provisioning.mapping.MapIdentity in project OpenUnison by TremoloSecurity.
the class SendMessageThread method addTarget.
private void addTarget(ConfigManager cfgMgr, TargetType targetCfg) throws ProvisioningException {
HashMap<String, Attribute> cfg = new HashMap<String, Attribute>();
Iterator<ParamType> params = targetCfg.getParams().getParam().iterator();
while (params.hasNext()) {
ParamType param = params.next();
Attribute attr = cfg.get(param.getName());
if (attr == null) {
attr = new Attribute(param.getName());
cfg.put(attr.getName(), attr);
}
attr.getValues().add(param.getValue());
}
UserStoreProvider provider = null;
synchronized (this.userStores) {
try {
provider = (UserStoreProvider) Class.forName(targetCfg.getClassName()).newInstance();
} catch (Exception e) {
throw new ProvisioningException("Could not initialize target " + targetCfg.getName(), e);
}
MapIdentity mapper = new MapIdentity(targetCfg);
this.userStores.put(targetCfg.getName(), new ProvisioningTargetImpl(targetCfg.getName(), provider, mapper));
provider.init(cfg, cfgMgr, targetCfg.getName());
}
}
use of com.tremolosecurity.provisioning.mapping.MapIdentity 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());
}
use of com.tremolosecurity.provisioning.mapping.MapIdentity 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.provisioning.mapping.MapIdentity in project OpenUnison by TremoloSecurity.
the class IdpHolder method configIdp.
public void configIdp(ApplicationType app, UrlType url, IdpType idp, ServletConfig config) throws ServletException {
String idpName = app.getName();
String className = idp.getClassName();
IdentityProvider identityProvider = null;
try {
identityProvider = (IdentityProvider) Class.forName(className).newInstance();
} catch (Exception e) {
StringBuffer b = new StringBuffer();
b.append("Could not instanciate identity provider '").append(idpName).append("'");
logger.error(b.toString(), e);
throw new ServletException(b.toString(), e);
}
HashMap<String, Attribute> initParams = new HashMap<String, Attribute>();
for (ParamType param : idp.getParams()) {
Attribute attr = initParams.get(param.getName());
if (attr == null) {
attr = new Attribute(param.getName());
initParams.put(attr.getName(), attr);
}
attr.getValues().add(param.getValue());
}
HashMap<String, HashMap<String, Attribute>> trusts = new HashMap<String, HashMap<String, Attribute>>();
for (TrustType trust : idp.getTrusts().getTrust()) {
HashMap<String, Attribute> trustCfg = new HashMap<String, Attribute>();
for (ParamType param : trust.getParam()) {
Attribute attr = trustCfg.get(param.getName());
if (attr == null) {
attr = new Attribute(param.getName());
trustCfg.put(attr.getName(), attr);
}
attr.getValues().add(param.getValue());
}
// System.out.println(trust.getName());
trusts.put(trust.getName(), trustCfg);
}
try {
identityProvider.init(app.getName(), config.getServletContext(), initParams, trusts, new MapIdentity(idp.getMappings()));
} catch (ProvisioningException e) {
throw new ServletException("Could not initiate IDP", e);
}
IdpHolder holder = new IdpHolder();
holder.idp = identityProvider;
holder.idpConfig = idp;
this.idps.put(idpName.toLowerCase(), holder);
}
Aggregations