Search in sources :

Example 21 with ParamType

use of com.tremolosecurity.config.xml.ParamType in project OpenUnison by TremoloSecurity.

the class UnisonConfigManagerImpl method initializeAuthenticationMechanism.

private void initializeAuthenticationMechanism(MechanismType mt) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    AuthMechanism authMech = (AuthMechanism) Class.forName(mt.getClassName().trim()).newInstance();
    HashMap<String, Attribute> attrs = new HashMap<String, Attribute>();
    Iterator<ParamType> params = mt.getInit().getParam().iterator();
    while (params.hasNext()) {
        ParamType pt = params.next();
        Attribute attr = attrs.get(pt.getName());
        if (attr == null) {
            attr = new Attribute(pt.getName());
            attrs.put(pt.getName(), attr);
        }
        attr.getValues().add(pt.getValue());
    }
    authMech.init(ctx, attrs);
    if (this.ctxPath.equalsIgnoreCase("/")) {
        this.mechs.put(mt.getUri(), authMech);
    } else {
        this.mechs.put(this.ctxPath + mt.getUri(), authMech);
    }
    if (mt.getClassName().equals("com.tremolosecurity.proxy.auth.AlwaysFail")) {
        this.alwaysFailAuth = (AlwaysFail) authMech;
        this.alwaysFailAuthMech = mt;
    }
}
Also used : AuthMechanism(com.tremolosecurity.proxy.auth.AuthMechanism) Attribute(com.tremolosecurity.saml.Attribute) HashMap(java.util.HashMap) AuthMechParamType(com.tremolosecurity.config.xml.AuthMechParamType) ParamType(com.tremolosecurity.config.xml.ParamType)

Example 22 with ParamType

use of com.tremolosecurity.config.xml.ParamType in project OpenUnison by TremoloSecurity.

the class UnisonConfigManagerImpl method initialize.

/* (non-Javadoc)
	 * @see com.tremolosecurity.config.util.ConfigManager#initialize()
	 */
/* (non-Javadoc)
	 * @see com.tremolosecurity.config.util.UnisonConfigManager#initialize()
	 */
@Override
public void initialize(String name) throws JAXBException, Exception, IOException, FileNotFoundException, InstantiationException, IllegalAccessException, ClassNotFoundException, LDAPException, KeyStoreException, NoSuchAlgorithmException, CertificateException, ProvisioningException {
    JAXBContext jc = JAXBContext.newInstance("com.tremolosecurity.config.xml");
    Unmarshaller unmarshaller = jc.createUnmarshaller();
    String path = configXML;
    this.threads = new ArrayList<StopableThread>();
    // path = path.substring(path.lastIndexOf('/') - 1);
    // path = path.substring(path.lastIndexOf('/') - 1);
    path = path.substring(0, path.lastIndexOf('/'));
    JAXBElement<TremoloType> autoidmcfg = this.loadUnisonConfiguration(unmarshaller);
    this.cfg = autoidmcfg.getValue();
    this.byHost = new HashMap<String, ArrayList<UrlHolder>>();
    this.cache = new HashMap<String, UrlHolder>();
    this.upgradeManager = (HttpUpgradeRequestManager) Class.forName(this.cfg.getUpgradeHandler()).newInstance();
    String myVdPath = cfg.getMyvdConfig();
    this.loadKeystore(path, myVdPath);
    this.initSSL();
    this.loadMyVD(path, myVdPath);
    if (cfg.getApplications().getErrorPage() != null) {
        for (ErrorPage ep : cfg.getApplications().getErrorPage()) {
            this.errorPages.put(ep.getCode(), ep.getLocation());
        }
    }
    this.customAzRules = new HashMap<String, CustomAuthorization>();
    if (this.cfg.getCustomAzRules() != null) {
        for (CustomAzRuleType azrule : this.cfg.getCustomAzRules().getAzRule()) {
            createCustomAuthorizationRule(azrule);
        }
    }
    loadApplicationObjects();
    this.authChains = new HashMap<String, AuthChainType>();
    if (cfg.getAuthChains() != null) {
        Iterator<AuthChainType> itac = cfg.getAuthChains().getChain().iterator();
        while (itac.hasNext()) {
            AuthChainType ac = itac.next();
            this.authChains.put(ac.getName(), ac);
        }
    }
    this.authMechs = new HashMap<String, MechanismType>();
    if (cfg.getAuthMechs() != null) {
        Iterator<MechanismType> itmt = cfg.getAuthMechs().getMechanism().iterator();
        while (itmt.hasNext()) {
            MechanismType mt = itmt.next();
            authMechs.put(mt.getName(), mt);
        }
    }
    this.resGroups = new HashMap<String, ResultGroupType>();
    if (cfg.getResultGroups() != null) {
        Iterator<ResultGroupType> itrgt = cfg.getResultGroups().getResultGroup().iterator();
        while (itrgt.hasNext()) {
            ResultGroupType rgt = itrgt.next();
            this.resGroups.put(rgt.getName(), rgt);
        }
    }
    this.apps = new HashMap<String, ApplicationType>();
    Iterator<ApplicationType> itApp = cfg.getApplications().getApplication().iterator();
    while (itApp.hasNext()) {
        ApplicationType app = itApp.next();
        this.apps.put(app.getName(), app);
    }
    this.provEnvgine = new ProvisioningEngineImpl(this);
    this.provEnvgine.initWorkFlows();
    this.provEnvgine.initMessageConsumers();
    this.provEnvgine.initScheduler();
    this.provEnvgine.initListeners();
    this.provEnvgine.initReports();
    try {
        if (this.getCfg().getResultGroups() != null && this.getCfg().getResultGroups().getDynamicResultGroups() != null && this.getCfg().getResultGroups().getDynamicResultGroups().isEnabled()) {
            DynamicPortalUrlsType dynamicResultGroups = this.getCfg().getResultGroups().getDynamicResultGroups();
            String className = dynamicResultGroups.getClassName();
            HashMap<String, Attribute> cfgAttrs = new HashMap<String, Attribute>();
            for (ParamType pt : dynamicResultGroups.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());
            }
            DynamicResultGroups dynResGroups = (DynamicResultGroups) Class.forName(className).newInstance();
            dynResGroups.loadDynamicResultGroups(this, this.getProvisioningEngine(), cfgAttrs);
        }
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        throw new ProvisioningException("Could not initialize dynamic targets", e);
    }
    try {
        if (this.getCfg().getCustomAzRules() != null && this.getCfg().getCustomAzRules().getDynamicCustomAuthorizations() != null && this.getCfg().getCustomAzRules().getDynamicCustomAuthorizations().isEnabled()) {
            DynamicPortalUrlsType dynamicCustomAuthorization = this.getCfg().getCustomAzRules().getDynamicCustomAuthorizations();
            String className = dynamicCustomAuthorization.getClassName();
            HashMap<String, Attribute> cfgAttrs = new HashMap<String, Attribute>();
            for (ParamType pt : dynamicCustomAuthorization.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());
            }
            DynamicAuthorizations dynCustomAz = (DynamicAuthorizations) Class.forName(className).newInstance();
            dynCustomAz.loadDynamicAuthorizations(this, this.getProvisioningEngine(), cfgAttrs);
        }
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        throw new ProvisioningException("Could not initialize dynamic targets", e);
    }
    try {
        if (this.getCfg().getAuthChains() != null && this.getCfg().getAuthChains().getDynamicAuthChains() != null && this.getCfg().getAuthChains().getDynamicAuthChains().isEnabled()) {
            DynamicPortalUrlsType dynamicAuthChains = this.getCfg().getAuthChains().getDynamicAuthChains();
            String className = dynamicAuthChains.getClassName();
            HashMap<String, Attribute> cfgAttrs = new HashMap<String, Attribute>();
            for (ParamType pt : dynamicAuthChains.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());
            }
            DynamicAuthChains dynAuthChains = (DynamicAuthChains) Class.forName(className).newInstance();
            dynAuthChains.loadDynamicAuthChains(this, provEnvgine, cfgAttrs);
        }
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        throw new ProvisioningException("Could not initialize dynamic targets", e);
    }
    try {
        if (this.getCfg().getApplications() != null && this.getCfg().getApplications().getDynamicApplications() != null && this.getCfg().getApplications().getDynamicApplications().isEnabled()) {
            DynamicPortalUrlsType dynamicApps = this.getCfg().getApplications().getDynamicApplications();
            String className = dynamicApps.getClassName();
            HashMap<String, Attribute> cfgAttrs = new HashMap<String, Attribute>();
            for (ParamType pt : dynamicApps.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());
            }
            DynamicApplications dynApps = (DynamicApplications) Class.forName(className).newInstance();
            dynApps.loadDynamicApplications(this, provEnvgine, cfgAttrs);
        }
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        throw new ProvisioningException("Could not initialize dynamic targets", e);
    }
    this.postInitialize();
}
Also used : ErrorPage(com.tremolosecurity.config.xml.ApplicationsType.ErrorPage) TremoloType(com.tremolosecurity.config.xml.TremoloType) Attribute(com.tremolosecurity.saml.Attribute) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) JAXBContext(javax.xml.bind.JAXBContext) DynamicApplications(com.tremolosecurity.proxy.dynamicloaders.DynamicApplications) ProvisioningEngineImpl(com.tremolosecurity.provisioning.core.ProvisioningEngineImpl) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) StopableThread(com.tremolosecurity.server.StopableThread) CustomAzRuleType(com.tremolosecurity.config.xml.CustomAzRuleType) MechanismType(com.tremolosecurity.config.xml.MechanismType) Unmarshaller(javax.xml.bind.Unmarshaller) AuthChainType(com.tremolosecurity.config.xml.AuthChainType) DynamicAuthChains(com.tremolosecurity.proxy.dynamicloaders.DynamicAuthChains) CustomAuthorization(com.tremolosecurity.proxy.az.CustomAuthorization) AuthMechParamType(com.tremolosecurity.config.xml.AuthMechParamType) ParamType(com.tremolosecurity.config.xml.ParamType) DynamicAuthorizations(com.tremolosecurity.proxy.dynamicloaders.DynamicAuthorizations) ApplicationType(com.tremolosecurity.config.xml.ApplicationType) DynamicResultGroups(com.tremolosecurity.proxy.dynamicloaders.DynamicResultGroups) DynamicPortalUrlsType(com.tremolosecurity.config.xml.DynamicPortalUrlsType) ResultGroupType(com.tremolosecurity.config.xml.ResultGroupType)

Example 23 with ParamType

use of com.tremolosecurity.config.xml.ParamType in project OpenUnison by TremoloSecurity.

the class SendMessageThread method initListeners.

@Override
public void initListeners() throws ProvisioningException {
    this.listenerSessions = new HashMap<String, JMSSessionHolder>();
    if (this.cfgMgr.getCfg().getProvisioning() == null || this.cfgMgr.getCfg().getProvisioning().getListeners() == null) {
        logger.warn("No listeners defined");
        return;
    }
    try {
        for (MessageListenerType mlt : this.cfgMgr.getCfg().getProvisioning().getListeners().getListener()) {
            addMessageListener(mlt);
        }
        if (cfgMgr.getCfg().getProvisioning().getListeners().getDynamicListeners() != null && cfgMgr.getCfg().getProvisioning().getListeners().getDynamicListeners().isEnabled()) {
            DynamicPortalUrlsType dynamicMessageListeners = cfgMgr.getCfg().getProvisioning().getListeners().getDynamicListeners();
            String className = dynamicMessageListeners.getClassName();
            HashMap<String, Attribute> cfgAttrs = new HashMap<String, Attribute>();
            for (ParamType pt : dynamicMessageListeners.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());
            }
            DynamicQueueListeners dynamicQueueListener = (DynamicQueueListeners) Class.forName(className).newInstance();
            dynamicQueueListener.loadDynamicQueueListeners(cfgMgr, this, cfgAttrs);
        }
    } catch (Exception e) {
        logger.warn("Could not initialize listeners", e);
    }
}
Also used : Attribute(com.tremolosecurity.saml.Attribute) LDAPAttribute(com.novell.ldap.LDAPAttribute) HashMap(java.util.HashMap) DynamicPortalUrlsType(com.tremolosecurity.config.xml.DynamicPortalUrlsType) JMSSessionHolder(com.tremolosecurity.provisioning.jms.JMSSessionHolder) DynamicQueueListeners(com.tremolosecurity.provisioning.listeners.DynamicQueueListeners) 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) MessageListenerType(com.tremolosecurity.config.xml.MessageListenerType)

Example 24 with ParamType

use of com.tremolosecurity.config.xml.ParamType in project OpenUnison by TremoloSecurity.

the class SendMessageThread method initWorkFlows.

/* (non-Javadoc)
	 * @see com.tremolosecurity.provisioning.core.ProvisioningEngine#initWorkFlows()
	 */
@Override
public void initWorkFlows() throws ProvisioningException {
    Iterator<String> wfNames = this.workflows.keySet().iterator();
    while (wfNames.hasNext()) {
        String name = wfNames.next();
        this.workflows.get(name).init();
    }
    try {
        if (cfgMgr.getCfg().getProvisioning() != null && cfgMgr.getCfg().getProvisioning().getWorkflows() != null && cfgMgr.getCfg().getProvisioning().getWorkflows().getDynamicWorkflows() != null && cfgMgr.getCfg().getProvisioning().getWorkflows().getDynamicWorkflows().isEnabled()) {
            DynamicPortalUrlsType dynamicWorkflows = cfgMgr.getCfg().getProvisioning().getWorkflows().getDynamicWorkflows();
            String className = dynamicWorkflows.getClassName();
            HashMap<String, Attribute> cfgAttrs = new HashMap<String, Attribute>();
            for (ParamType pt : dynamicWorkflows.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());
            }
            DynamicWorkflows dynWorkflows = (DynamicWorkflows) Class.forName(className).newInstance();
            dynWorkflows.loadDynamicWorkflows(cfgMgr, this, cfgAttrs);
        }
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        throw new ProvisioningException("Could not initialize dynamic targets", e);
    }
}
Also used : Attribute(com.tremolosecurity.saml.Attribute) LDAPAttribute(com.novell.ldap.LDAPAttribute) HashMap(java.util.HashMap) ParamType(com.tremolosecurity.config.xml.ParamType) DynamicPortalUrlsType(com.tremolosecurity.config.xml.DynamicPortalUrlsType) DynamicWorkflows(com.tremolosecurity.provisioning.workflows.DynamicWorkflows)

Example 25 with ParamType

use of com.tremolosecurity.config.xml.ParamType 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

ParamType (com.tremolosecurity.config.xml.ParamType)27 HashMap (java.util.HashMap)17 Attribute (com.tremolosecurity.saml.Attribute)14 IOException (java.io.IOException)12 LDAPAttribute (com.novell.ldap.LDAPAttribute)8 AuthMechParamType (com.tremolosecurity.config.xml.AuthMechParamType)7 DynamicPortalUrlsType (com.tremolosecurity.config.xml.DynamicPortalUrlsType)7 ProvisioningException (com.tremolosecurity.provisioning.core.ProvisioningException)7 FileNotFoundException (java.io.FileNotFoundException)7 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)7 JAXBException (javax.xml.bind.JAXBException)7 JSONObject (org.json.simple.JSONObject)7 JSONArray (org.json.simple.JSONArray)6 ApplicationType (com.tremolosecurity.config.xml.ApplicationType)5 TrustType (com.tremolosecurity.config.xml.TrustType)5 ServletException (javax.servlet.ServletException)5 LDAPException (com.novell.ldap.LDAPException)4 HttpCon (com.tremolosecurity.provisioning.util.HttpCon)4 KeyStoreException (java.security.KeyStoreException)4 UnrecoverableKeyException (java.security.UnrecoverableKeyException)4