Search in sources :

Example 1 with MapIdentity

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());
    }
}
Also used : Attribute(com.tremolosecurity.saml.Attribute) LDAPAttribute(com.novell.ldap.LDAPAttribute) HashMap(java.util.HashMap) MapIdentity(com.tremolosecurity.provisioning.mapping.MapIdentity) ParamType(com.tremolosecurity.config.xml.ParamType) InvocationTargetException(java.lang.reflect.InvocationTargetException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException) LDAPException(com.novell.ldap.LDAPException) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) SocketException(java.net.SocketException) SQLException(java.sql.SQLException) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException) MessagingException(javax.mail.MessagingException) IllegalBlockSizeException(javax.crypto.IllegalBlockSizeException) JMSException(javax.jms.JMSException) JAXBException(javax.xml.bind.JAXBException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NoSuchPaddingException(javax.crypto.NoSuchPaddingException) BadPaddingException(javax.crypto.BadPaddingException)

Example 2 with MapIdentity

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());
}
Also used : MappingType(com.tremolosecurity.config.xml.MappingType) MapIdentity(com.tremolosecurity.provisioning.mapping.MapIdentity)

Example 3 with MapIdentity

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);
}
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 4 with MapIdentity

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);
}
Also used : Attribute(com.tremolosecurity.saml.Attribute) HashMap(java.util.HashMap) TrustType(com.tremolosecurity.config.xml.TrustType) MapIdentity(com.tremolosecurity.provisioning.mapping.MapIdentity) ServletException(javax.servlet.ServletException) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) IOException(java.io.IOException) ParamType(com.tremolosecurity.config.xml.ParamType) ServletException(javax.servlet.ServletException) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException)

Aggregations

MapIdentity (com.tremolosecurity.provisioning.mapping.MapIdentity)4 Attribute (com.tremolosecurity.saml.Attribute)3 HashMap (java.util.HashMap)3 ParamType (com.tremolosecurity.config.xml.ParamType)2 ProvisioningException (com.tremolosecurity.provisioning.core.ProvisioningException)2 IOException (java.io.IOException)2 ServletException (javax.servlet.ServletException)2 LDAPAttribute (com.novell.ldap.LDAPAttribute)1 LDAPException (com.novell.ldap.LDAPException)1 UrlHolder (com.tremolosecurity.config.util.UrlHolder)1 MappingType (com.tremolosecurity.config.xml.MappingType)1 TargetAttributeType (com.tremolosecurity.config.xml.TargetAttributeType)1 TargetType (com.tremolosecurity.config.xml.TargetType)1 TrustType (com.tremolosecurity.config.xml.TrustType)1 User (com.tremolosecurity.provisioning.core.User)1 FileNotFoundException (java.io.FileNotFoundException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 SocketException (java.net.SocketException)1 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1