use of com.tremolosecurity.saml.Attribute 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.saml.Attribute in project OpenUnison by TremoloSecurity.
the class CreateOTPKey method init.
public void init(WorkflowTask task, Map<String, Attribute> params) throws ProvisioningException {
Attribute attr = params.get("attributeName");
if (attr == null) {
throw new ProvisioningException("attributeName not found");
}
this.attributeName = attr.getValues().get(0);
attr = params.get("encryptionKey");
if (attr == null) {
throw new ProvisioningException("encryptionKey not found");
}
this.encryptionKey = attr.getValues().get(0);
attr = params.get("hostName");
if (attr == null) {
throw new ProvisioningException("hostName not found");
}
this.hostName = attr.getValues().get(0);
this.task = task;
}
use of com.tremolosecurity.saml.Attribute in project OpenUnison by TremoloSecurity.
the class CreateOTPKey method doTask.
public boolean doTask(User user, Map<String, Object> request) throws ProvisioningException {
GoogleAuthenticator ga = new GoogleAuthenticator();
GoogleAuthenticatorKey key = ga.createCredentials();
String attrVal = null;
attrVal = generateEncryptedToken(user.getUserID(), key, this.hostName, this.task.getConfigManager(), this.encryptionKey);
Attribute keyattr = new Attribute(this.attributeName);
keyattr.getValues().add(attrVal);
user.getAttribs().put(this.attributeName, keyattr);
return true;
}
use of com.tremolosecurity.saml.Attribute in project OpenUnison by TremoloSecurity.
the class DeleteGroupMembers method doTask.
@Override
public boolean doTask(User user, Map<String, Object> request) throws ProvisioningException {
String localWorkflowName = task.renderTemplate(this.workflowName, request);
String localGroupToDelete = task.renderTemplate(this.groupToDelete, request);
String localGroupNameAttribute = task.renderTemplate(this.groupNameAttribute, request);
String memberAttr = task.getConfigManager().getCfg().getGroupMemberAttribute();
String[] members = null;
String groupName = null;
try {
LDAPSearchResults rs = task.getConfigManager().getMyVD().search(localGroupToDelete, 0, "(objectClass=*)", new ArrayList<String>());
rs.hasMore();
LDAPEntry group = rs.next();
while (rs.hasMore()) rs.next();
if (group.getAttribute(memberAttr) != null) {
members = group.getAttribute(memberAttr).getStringValueArray();
} else {
members = new String[] {};
}
if (group.getAttribute(localGroupNameAttribute) != null) {
groupName = group.getAttribute(localGroupNameAttribute).getStringValue();
} else {
throw new ProvisioningException("Group '" + localGroupToDelete + "' has no '" + localGroupNameAttribute + "' attribute");
}
} catch (LDAPException e) {
throw new ProvisioningException("Could not load from group", e);
}
for (String member : members) {
try {
LDAPSearchResults rs = task.getConfigManager().getMyVD().search(member, 0, "(objectClass=*)", new ArrayList<String>());
rs.hasMore();
LDAPEntry ldapMember = rs.next();
TremoloUser userToUpdate = new TremoloUser();
userToUpdate.setUid(ldapMember.getAttribute(this.uidAttribute).getStringValue());
userToUpdate.getAttributes().add(new Attribute(this.uidAttribute, userToUpdate.getUid()));
Workflow wf = task.getConfigManager().getProvisioningEngine().getWorkFlow(localWorkflowName);
WFCall call = new WFCall();
call.setReason("removing from to be deleted group " + localGroupToDelete);
call.setUidAttributeName(this.uidAttribute);
call.setUser(userToUpdate);
call.setRequestor(this.requestor);
call.getRequestParams().put(ProvisioningParams.UNISON_EXEC_TYPE, ProvisioningParams.UNISON_EXEC_SYNC);
call.getRequestParams().put("openunison_grouptoremove", groupName);
wf.executeWorkflow(call);
} catch (LDAPException e) {
logger.warn("Could not remove user '" + member + "'", e);
}
}
return true;
}
use of com.tremolosecurity.saml.Attribute in project OpenUnison by TremoloSecurity.
the class DoesGroupExist method doTask.
@Override
public boolean doTask(User user, Map<String, Object> request) throws ProvisioningException {
String localGroupName = task.renderTemplate(groupName, request);
UserStoreProviderWithAddGroup provTarget = (UserStoreProviderWithAddGroup) GlobalEntries.getGlobalEntries().getConfigManager().getProvisioningEngine().getTarget(this.target).getProvider();
if (provTarget.isGroupExists(localGroupName, user, request)) {
user.getAttribs().put(this.attributeName, new Attribute(this.attributeName, "true"));
} else {
user.getAttribs().put(this.attributeName, new Attribute(this.attributeName, "false"));
}
return true;
}
Aggregations