Search in sources :

Example 31 with Attribute

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);
    }
}
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 32 with Attribute

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;
}
Also used : Attribute(com.tremolosecurity.saml.Attribute) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException)

Example 33 with Attribute

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;
}
Also used : GoogleAuthenticatorKey(com.warrenstrange.googleauth.GoogleAuthenticatorKey) GoogleAuthenticator(com.warrenstrange.googleauth.GoogleAuthenticator) Attribute(com.tremolosecurity.saml.Attribute)

Example 34 with Attribute

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;
}
Also used : LDAPEntry(com.novell.ldap.LDAPEntry) WFCall(com.tremolosecurity.provisioning.service.util.WFCall) LDAPSearchResults(com.novell.ldap.LDAPSearchResults) LDAPException(com.novell.ldap.LDAPException) TremoloUser(com.tremolosecurity.provisioning.service.util.TremoloUser) Attribute(com.tremolosecurity.saml.Attribute) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) Workflow(com.tremolosecurity.provisioning.core.Workflow)

Example 35 with Attribute

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;
}
Also used : Attribute(com.tremolosecurity.saml.Attribute) UserStoreProviderWithAddGroup(com.tremolosecurity.provisioning.core.UserStoreProviderWithAddGroup)

Aggregations

Attribute (com.tremolosecurity.saml.Attribute)268 LDAPAttribute (com.novell.ldap.LDAPAttribute)90 HashMap (java.util.HashMap)89 ProvisioningException (com.tremolosecurity.provisioning.core.ProvisioningException)87 IOException (java.io.IOException)69 ArrayList (java.util.ArrayList)53 LDAPException (com.novell.ldap.LDAPException)51 ServletException (javax.servlet.ServletException)48 AuthInfo (com.tremolosecurity.proxy.auth.AuthInfo)46 AuthController (com.tremolosecurity.proxy.auth.AuthController)45 LDAPEntry (com.novell.ldap.LDAPEntry)43 LDAPSearchResults (com.novell.ldap.LDAPSearchResults)43 HttpSession (javax.servlet.http.HttpSession)40 Gson (com.google.gson.Gson)35 User (com.tremolosecurity.provisioning.core.User)33 HttpServletRequest (javax.servlet.http.HttpServletRequest)33 UrlHolder (com.tremolosecurity.config.util.UrlHolder)31 UnsupportedEncodingException (java.io.UnsupportedEncodingException)30 AuthChainType (com.tremolosecurity.config.xml.AuthChainType)28 HashSet (java.util.HashSet)26