Search in sources :

Example 1 with ActiveDirectoryLdapEntryHandler

use of org.apereo.services.persondir.support.ldap.ActiveDirectoryLdapEntryHandler in project cas by apereo.

the class LdapUtils method newLdaptiveEntryHandlers.

/**
 * New list of ldap entry handlers derived from the supplied properties.
 *
 * @param properties to inspect
 * @return the list of entry handlers
 */
public static List<LdapEntryHandler> newLdaptiveEntryHandlers(final List<LdapSearchEntryHandlersProperties> properties) {
    val entryHandlers = new ArrayList<LdapEntryHandler>();
    properties.forEach(h -> {
        switch(h.getType()) {
            case ACTIVE_DIRECTORY:
                entryHandlers.add(new ActiveDirectoryLdapEntryHandler());
                break;
            case CASE_CHANGE:
                val eh = new CaseChangeEntryHandler();
                val caseChange = h.getCaseChange();
                eh.setAttributeNameCaseChange(CaseChangeEntryHandler.CaseChange.valueOf(caseChange.getAttributeNameCaseChange()));
                eh.setAttributeNames(caseChange.getAttributeNames().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
                eh.setAttributeValueCaseChange(CaseChangeEntryHandler.CaseChange.valueOf(caseChange.getAttributeValueCaseChange()));
                eh.setDnCaseChange(CaseChangeEntryHandler.CaseChange.valueOf(caseChange.getDnCaseChange()));
                entryHandlers.add(eh);
                break;
            case DN_ATTRIBUTE_ENTRY:
                val ehd = new DnAttributeEntryHandler();
                val dnAttribute = h.getDnAttribute();
                ehd.setAddIfExists(dnAttribute.isAddIfExists());
                ehd.setDnAttributeName(dnAttribute.getDnAttributeName());
                entryHandlers.add(ehd);
                break;
            case MERGE:
                val ehm = new MergeAttributeEntryHandler();
                val mergeAttribute = h.getMergeAttribute();
                ehm.setAttributeNames(mergeAttribute.getAttributeNames().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
                ehm.setMergeAttributeName(mergeAttribute.getMergeAttributeName());
                entryHandlers.add(ehm);
                break;
            case OBJECT_GUID:
                entryHandlers.add(new ObjectGuidHandler());
                break;
            case OBJECT_SID:
                entryHandlers.add(new ObjectSidHandler());
                break;
            default:
                break;
        }
    });
    return entryHandlers;
}
Also used : lombok.val(lombok.val) ObjectGuidHandler(org.ldaptive.ad.handler.ObjectGuidHandler) DnAttributeEntryHandler(org.ldaptive.handler.DnAttributeEntryHandler) ActiveDirectoryLdapEntryHandler(org.apereo.services.persondir.support.ldap.ActiveDirectoryLdapEntryHandler) ArrayList(java.util.ArrayList) CaseChangeEntryHandler(org.ldaptive.handler.CaseChangeEntryHandler) MergeAttributeEntryHandler(org.ldaptive.handler.MergeAttributeEntryHandler) ObjectSidHandler(org.ldaptive.ad.handler.ObjectSidHandler)

Aggregations

ArrayList (java.util.ArrayList)1 lombok.val (lombok.val)1 ActiveDirectoryLdapEntryHandler (org.apereo.services.persondir.support.ldap.ActiveDirectoryLdapEntryHandler)1 ObjectGuidHandler (org.ldaptive.ad.handler.ObjectGuidHandler)1 ObjectSidHandler (org.ldaptive.ad.handler.ObjectSidHandler)1 CaseChangeEntryHandler (org.ldaptive.handler.CaseChangeEntryHandler)1 DnAttributeEntryHandler (org.ldaptive.handler.DnAttributeEntryHandler)1 MergeAttributeEntryHandler (org.ldaptive.handler.MergeAttributeEntryHandler)1