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