Search in sources :

Example 1 with LdapPool

use of com.tremolosecurity.provisioning.util.ldap.pool.LdapPool in project OpenUnison by TremoloSecurity.

the class LDAPProvider method init.

@Override
public void init(Map<String, Attribute> cfg, ConfigManager cfgMgr, String name) throws ProvisioningException {
    this.cfgMgr = cfgMgr;
    this.name = name;
    try {
        String host = cfg.get("host").getValues().get(0);
        int port = Integer.parseInt(cfg.get("port").getValues().get(0));
        this.userDN = cfg.get("adminDN").getValues().get(0);
        this.passwd = cfg.get("adminPasswd").getValues().get(0);
        this.dnPattern = cfg.get("dnPattern").getValues().get(0);
        this.searchBase = cfg.get("searchBase").getValues().get(0);
        this.objectClass = cfg.get("objectClass").getValues().get(0);
        this.userIDAttribute = cfg.get("userIDAttribute").getValues().get(0);
        if (cfg.get("useSSL") != null) {
            this.isSSL = Boolean.parseBoolean(cfg.get("useSSL").getValues().get(0));
        } else {
            this.isSSL = false;
        }
        int maxCons = Integer.parseInt(cfg.get("maxCons").getValues().get(0));
        int threadsPerCon = Integer.parseInt(cfg.get("threadsPerCons").getValues().get(0));
        Attribute timeout = cfg.get("idleTimeout");
        if (timeout == null) {
            this.idleTimeout = 10000;
        } else {
            this.idleTimeout = Long.parseLong(timeout.getValues().get(0));
        }
        this.ldapPool = new LdapPool(cfgMgr, host, port, this.userDN, this.passwd, this.isSSL, 0, maxCons, this.idleTimeout);
        if (cfg.get("allowExternalUsers") != null) {
            this.allowExternalUsers = cfg.get("allowExternalUsers").getValues().get(0).equalsIgnoreCase("true");
        } else {
            this.allowExternalUsers = false;
        }
        logger.info("Allow External User : '" + this.allowExternalUsers + "'");
        if (this.allowExternalUsers) {
            this.unison2ldap = new HashMap<String, String>();
            if (cfg.get("externalUserMapInUnison") != null && !cfg.get("externalUserMapInUnison").getValues().get(0).isEmpty()) {
                this.unisonBase = cfg.get("externalUserMapInUnison").getValues().get(0);
                this.lcUnisonBase = unisonBase.toLowerCase();
                this.ldapBase = cfg.get("externalUserMapInDir").getValues().get(0);
                this.lcLDAPBase = ldapBase.toLowerCase();
            }
        }
    } catch (Exception e) {
        throw new ProvisioningException("Could not initialize", e);
    }
}
Also used : LDAPAttribute(com.novell.ldap.LDAPAttribute) Attribute(com.tremolosecurity.saml.Attribute) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) LdapPool(com.tremolosecurity.provisioning.util.ldap.pool.LdapPool) LDAPException(com.novell.ldap.LDAPException) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) LDAPReferralException(com.novell.ldap.LDAPReferralException)

Example 2 with LdapPool

use of com.tremolosecurity.provisioning.util.ldap.pool.LdapPool in project OpenUnison by TremoloSecurity.

the class ADProvider method init.

@Override
public void init(Map<String, Attribute> cfg, ConfigManager cfgMgr, String name) throws ProvisioningException {
    this.cfgMgr = cfgMgr;
    this.name = name;
    try {
        String host = cfg.get("host").getValues().get(0);
        int port = Integer.parseInt(cfg.get("port").getValues().get(0));
        this.userDN = cfg.get("adminDN").getValues().get(0);
        this.passwd = cfg.get("adminPasswd").getValues().get(0);
        this.dnPattern = cfg.get("dnPattern").getValues().get(0);
        this.searchBase = cfg.get("searchBase").getValues().get(0);
        this.supportExternalUsers = cfg.get("supportExternalUsers") != null && cfg.get("supportExternalUsers").getValues().get(0).equalsIgnoreCase("true");
        if (this.supportExternalUsers) {
            this.externalGroupAttr = cfg.get("externalGroupAttr").getValues().get(0);
        }
        this.userIDAttribute = cfg.get("userIDAttribute").getValues().get(0);
        this.objectClass = "user";
        if (cfg.get("useSSL") != null) {
            this.isSSL = Boolean.parseBoolean(cfg.get("useSSL").getValues().get(0));
        } else {
            this.isSSL = false;
        }
        if (cfg.get("createShadowAccount") != null) {
            this.createShadowAccounts = Boolean.parseBoolean(cfg.get("createShadowAccount").getValues().get(0));
        } else {
            this.createShadowAccounts = false;
        }
        int maxCons = Integer.parseInt(cfg.get("maxCons").getValues().get(0));
        int threadsPerCon = Integer.parseInt(cfg.get("threadsPerCons").getValues().get(0));
        Attribute timeout = cfg.get("idleTimeout");
        if (timeout == null) {
            this.idleTimeout = 10000;
        } else {
            this.idleTimeout = Long.parseLong(timeout.getValues().get(0));
        }
        this.ldapPool = new LdapPool(cfgMgr, host, port, this.userDN, this.passwd, this.isSSL, 0, maxCons, this.idleTimeout);
    } catch (Exception e) {
        throw new ProvisioningException("Could not initialize", e);
    }
}
Also used : LDAPAttribute(com.novell.ldap.LDAPAttribute) Attribute(com.tremolosecurity.saml.Attribute) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) LdapPool(com.tremolosecurity.provisioning.util.ldap.pool.LdapPool) LDAPException(com.novell.ldap.LDAPException) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) LDAPReferralException(com.novell.ldap.LDAPReferralException)

Aggregations

LDAPAttribute (com.novell.ldap.LDAPAttribute)2 LDAPException (com.novell.ldap.LDAPException)2 LDAPReferralException (com.novell.ldap.LDAPReferralException)2 ProvisioningException (com.tremolosecurity.provisioning.core.ProvisioningException)2 LdapPool (com.tremolosecurity.provisioning.util.ldap.pool.LdapPool)2 Attribute (com.tremolosecurity.saml.Attribute)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1