Search in sources :

Example 36 with Attribute

use of com.tremolosecurity.saml.Attribute in project OpenUnison by TremoloSecurity.

the class JITBasicDBCreateGroups method init.

@Override
public void init(WorkflowTask task, Map<String, Attribute> params) throws ProvisioningException {
    this.task = task;
    Attribute attr = params.get("targetName");
    if (attr == null) {
        throw new ProvisioningException("targetName not set");
    }
    this.targetName = attr.getValues().get(0);
    this.loadGroupData();
}
Also used : Attribute(com.tremolosecurity.saml.Attribute) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException)

Example 37 with Attribute

use of com.tremolosecurity.saml.Attribute in project OpenUnison by TremoloSecurity.

the class LoadAttributes method doTask.

@Override
public boolean doTask(User user, Map<String, Object> request) throws ProvisioningException {
    StringBuffer filter = new StringBuffer();
    ArrayList<String> params = new ArrayList<String>();
    params.addAll(this.attrs);
    try {
        if (this.base == null) {
            this.base = this.cfg.getCfg().getLdapRoot();
        }
        LDAPSearchResults res = this.cfg.getMyVD().search(this.base, 2, equal(this.nameAttr, user.getUserID()).toString(), params);
        if (res.hasMore()) {
            LDAPEntry entry = res.next();
            LDAPAttributeSet attrs = entry.getAttributeSet();
            for (Object obj : attrs) {
                LDAPAttribute attr = (LDAPAttribute) obj;
                Attribute userAttr = new Attribute(attr.getName());
                for (String val : attr.getStringValueArray()) {
                    userAttr.getValues().add(val);
                }
                user.getAttribs().put(attr.getName(), userAttr);
            }
        }
    } catch (LDAPException e) {
        throw new ProvisioningException("Could not load user : " + user.getUserID(), e);
    }
    return true;
}
Also used : LDAPAttribute(com.novell.ldap.LDAPAttribute) LDAPEntry(com.novell.ldap.LDAPEntry) LDAPSearchResults(com.novell.ldap.LDAPSearchResults) LDAPException(com.novell.ldap.LDAPException) Attribute(com.tremolosecurity.saml.Attribute) LDAPAttribute(com.novell.ldap.LDAPAttribute) LDAPAttributeSet(com.novell.ldap.LDAPAttributeSet) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) ArrayList(java.util.ArrayList)

Example 38 with Attribute

use of com.tremolosecurity.saml.Attribute in project OpenUnison by TremoloSecurity.

the class LoadAuditDBAttributes method init.

@Override
public void init(WorkflowTask task, Map<String, Attribute> params) throws ProvisioningException {
    this.attrs = new HashSet<String>();
    Attribute cfgAttrs = params.get("name");
    for (String name : cfgAttrs.getValues()) {
        attrs.add(name);
    }
    this.nameAttr = params.get("nameAttr").getValues().get(0);
    this.cfg = task.getConfigManager();
    this.task = task;
}
Also used : Attribute(com.tremolosecurity.saml.Attribute)

Example 39 with Attribute

use of com.tremolosecurity.saml.Attribute in project OpenUnison by TremoloSecurity.

the class MapJitGroups method doTask.

@Override
public boolean doTask(User user, Map<String, Object> request) throws ProvisioningException {
    Attribute groupAttr = user.getAttribs().get(this.attributeName);
    Set<String> groupDNs = new HashSet<String>();
    if (groupAttr != null) {
        for (String dnFromAttr : groupAttr.getValues()) {
            groupDNs.add(new DN(dnFromAttr).toString().toLowerCase());
        }
    }
    for (DN groupDN : groupMap.keySet()) {
        if (groupDNs.contains(groupDN.toString().toLowerCase())) {
            user.getGroups().addAll(groupMap.get(groupDN));
        } else {
            user.getGroups().removeAll(groupMap.get(groupDN));
        }
    }
    return true;
}
Also used : Attribute(com.tremolosecurity.saml.Attribute) DN(com.novell.ldap.util.DN) HashSet(java.util.HashSet)

Example 40 with Attribute

use of com.tremolosecurity.saml.Attribute in project OpenUnison by TremoloSecurity.

the class WorkflowImpl method executeWorkflow.

/* (non-Javadoc)
	 * @see com.tremolosecurity.provisioning.core.Workflow#executeWorkflow(com.tremolosecurity.provisioning.service.util.WFCall)
	 */
@Override
public Map<String, Object> executeWorkflow(WFCall call) throws ProvisioningException {
    TremoloUser userFromCall = call.getUser();
    String uidAttr = call.getUidAttributeName();
    HashMap<String, Attribute> attrs = new HashMap<String, Attribute>();
    for (Attribute attr : userFromCall.getAttributes()) {
        attrs.put(attr.getName(), attr);
    }
    Attribute uid = attrs.get(uidAttr);
    if (uid == null) {
        throw new ProvisioningException("No uid attribute " + uidAttr);
    }
    User user = new User(uid.getValues().get(0));
    user.getGroups().addAll(userFromCall.getGroups());
    user.getAttribs().putAll(attrs);
    if (userFromCall.getUserPassword() != null) {
        user.setPassword(userFromCall.getUserPassword());
    }
    if (call.getReason() != null) {
        user.setRequestReason(call.getReason());
    }
    return this.executeWorkflow(user, call.getRequestParams(), call.getRequestor());
}
Also used : TremoloUser(com.tremolosecurity.provisioning.service.util.TremoloUser) TremoloUser(com.tremolosecurity.provisioning.service.util.TremoloUser) LDAPAttribute(com.novell.ldap.LDAPAttribute) Attribute(com.tremolosecurity.saml.Attribute) HashMap(java.util.HashMap)

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