Search in sources :

Example 1 with LDAPAttribute

use of org.opends.server.protocols.ldap.LDAPAttribute in project OpenAM by OpenRock.

the class SMSEmbeddedLdapObject method copyModItemsToLDAPModList.

// Method to covert JNDI ModificationItems to LDAPModificationSet
private static List copyModItemsToLDAPModList(ModificationItem[] mods) throws SMSException {
    if ((mods == null) || (mods.length == 0)) {
        return null;
    }
    List<LDAPModification> modList = new ArrayList<>(mods.length);
    try {
        for (ModificationItem mod : mods) {
            Attribute dAttr = mod.getAttribute();
            String attrName = dAttr.getID();
            List<String> values = new ArrayList<>();
            for (NamingEnumeration ne = dAttr.getAll(); ne.hasMore(); ) {
                values.add((String) ne.next());
            }
            ModificationType modType = null;
            switch(mod.getModificationOp()) {
                case DirContext.ADD_ATTRIBUTE:
                    modType = ModificationType.ADD;
                    break;
                case DirContext.REPLACE_ATTRIBUTE:
                    modType = ModificationType.REPLACE;
                    break;
                case DirContext.REMOVE_ATTRIBUTE:
                    modType = ModificationType.DELETE;
                    break;
            }
            if (modType != null) {
                modList.add(new LDAPModification(modType, new LDAPAttribute(attrName, values)));
            }
        }
    } catch (NamingException nne) {
        throw (new SMSException(nne, "sms-cannot-copy-fromModItemToModSet"));
    }
    return (modList);
}
Also used : ModificationItem(javax.naming.directory.ModificationItem) LDAPAttribute(org.opends.server.protocols.ldap.LDAPAttribute) Attribute(javax.naming.directory.Attribute) LDAPAttribute(org.opends.server.protocols.ldap.LDAPAttribute) ModificationType(org.forgerock.opendj.ldap.ModificationType) SMSException(com.sun.identity.sm.SMSException) LDAPModification(org.opends.server.protocols.ldap.LDAPModification) ArrayList(java.util.ArrayList) NamingEnumeration(javax.naming.NamingEnumeration) NamingException(javax.naming.NamingException)

Example 2 with LDAPAttribute

use of org.opends.server.protocols.ldap.LDAPAttribute in project OpenAM by OpenRock.

the class TokenDataEntry method getObjectClasses.

public List<LDAPAttribute> getObjectClasses() {
    List<String> valueList = new ArrayList<String>();
    valueList.add(Constants.TOP);
    valueList.add(FR_OAUTH2TOKEN);
    LDAPAttribute ldapAttr = new LDAPAttribute(Constants.OBJECTCLASS, valueList);
    List<LDAPAttribute> objectClasses = new ArrayList<LDAPAttribute>();
    objectClasses.add(ldapAttr);
    return objectClasses;
}
Also used : LDAPAttribute(org.opends.server.protocols.ldap.LDAPAttribute) ArrayList(java.util.ArrayList)

Example 3 with LDAPAttribute

use of org.opends.server.protocols.ldap.LDAPAttribute in project OpenAM by OpenRock.

the class SMSEmbeddedLdapObject method copyMapToAttrList.

// Method to convert Map to LDAPAttributeSet
private static List copyMapToAttrList(Map attrs) {
    if ((attrs == null) || (attrs.isEmpty())) {
        return null;
    }
    List<LDAPAttribute> attrList = new ArrayList<>(attrs.size());
    for (Iterator iter = attrs.keySet().iterator(); iter.hasNext(); ) {
        String attrName = (String) iter.next();
        Set values = (Set) attrs.get(attrName);
        if ((values != null) && (!values.isEmpty())) {
            List valueList = new ArrayList();
            valueList.addAll(values);
            attrList.add(new LDAPAttribute(attrName, valueList));
        }
    }
    return attrList;
}
Also used : LDAPAttribute(org.opends.server.protocols.ldap.LDAPAttribute) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList)

Example 4 with LDAPAttribute

use of org.opends.server.protocols.ldap.LDAPAttribute in project OpenAM by OpenRock.

the class TokenDataEntry method getAttrList.

public List<RawAttribute> getAttrList() {
    List<RawAttribute> attrList = new ArrayList<RawAttribute>(attributeValues.size());
    Map<String, Object> map = attributeValues.asMap();
    for (String key : map.keySet()) {
        List<String> valueList = new ArrayList<String>();
        Object o = map.get(key);
        if (o instanceof Collection) {
            for (Object o2 : (Collection) o) {
                if (o2 != null) {
                    valueList.add(o2.toString());
                }
            }
        } else {
            if (o != null) {
                valueList.add(o.toString());
            }
        }
        if (!valueList.isEmpty()) {
            attrList.add(new LDAPAttribute(key, valueList));
        }
    }
    return attrList;
}
Also used : LDAPAttribute(org.opends.server.protocols.ldap.LDAPAttribute) ArrayList(java.util.ArrayList) RawAttribute(org.opends.server.types.RawAttribute) Collection(java.util.Collection)

Aggregations

ArrayList (java.util.ArrayList)4 LDAPAttribute (org.opends.server.protocols.ldap.LDAPAttribute)4 SMSException (com.sun.identity.sm.SMSException)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Set (java.util.Set)1 NamingEnumeration (javax.naming.NamingEnumeration)1 NamingException (javax.naming.NamingException)1 Attribute (javax.naming.directory.Attribute)1 ModificationItem (javax.naming.directory.ModificationItem)1 ModificationType (org.forgerock.opendj.ldap.ModificationType)1 LDAPModification (org.opends.server.protocols.ldap.LDAPModification)1 RawAttribute (org.opends.server.types.RawAttribute)1