Search in sources :

Example 21 with AttrSet

use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.

the class UMSObject method getObject.

public static PersistentObject getObject(Principal principal, Guid guid, String[] attrNames) throws UMSException {
    AttrSet attrSet = null;
    if (attrNames == null) {
        attrSet = DataLayer.getInstance().read(principal, guid);
    } else {
        int length = attrNames.length;
        String[] attrNames1 = new String[length + 1];
        System.arraycopy(attrNames, 0, attrNames1, 0, length);
        attrNames1[length] = "objectclass";
        attrSet = DataLayer.getInstance().read(principal, guid, attrNames1);
    }
    String id = guid.getDn();
    if (id == null) {
        String msg = i18n.getString(IUMSConstants.BAD_ID);
        throw new IllegalArgumentException(msg);
    }
    Class javaClass = TemplateManager.getTemplateManager().getJavaClassForEntry(id, attrSet);
    PersistentObject po = null;
    try {
        po = (PersistentObject) javaClass.newInstance();
    } catch (Exception e) {
        String[] args = new String[1];
        args[0] = e.toString();
        String msg = i18n.getString(IUMSConstants.NEW_INSTANCE_FAILED, args);
        throw new UMSException(msg);
    }
    po.setAttrSet(attrSet);
    po.setGuid(guid);
    po.setPrincipal(principal);
    return po;
}
Also used : SSOException(com.iplanet.sso.SSOException) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 22 with AttrSet

use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.

the class User method getAttributes.

/**
     * Return attribute set according to a supplied search template. The search
     * template is used as attribute retrieval guidelines.
     * 
     * @param template
     *            Search template
     * @return attribute set with attribute names defined in the template
     * 
     * @supported.api
     */
public AttrSet getAttributes(SearchTemplate template) throws UMSException {
    AttrSet attrSet = new AttrSet();
    String[] attrNames = template.getAttributeNames();
    for (int i = 0; i < attrNames.length; i++) {
        attrSet.add(getAttribute(attrNames[i]));
    }
    return attrSet;
}
Also used : AttrSet(com.iplanet.services.ldap.AttrSet)

Example 23 with AttrSet

use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.

the class SearchTemplate method setAttributeNames.

/**
     * Sets the attributes to be returned on a search.
     * 
     * @param attributeNames
     *            The attribute names to be returned
     * 
     * @supported.api
     */
public void setAttributeNames(String[] attributeNames) {
    if (attributeNames != null) {
        m_attrSet = new AttrSet();
        addAttributeNames(attributeNames);
    }
}
Also used : AttrSet(com.iplanet.services.ldap.AttrSet)

Example 24 with AttrSet

use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.

the class PersistentObject method findAttributesNotRead.

/**
     * Find the names of attributes not read from data store so far
     * 
     * @param attrNames
     *            names of attributes to get
     * @return collection of names of attributes not read from data store so far
     */
private Collection findAttributesNotRead(String[] attrNames) {
    ArrayList attributesNotInCache = new ArrayList();
    if (m_attrSet == null) {
        m_attrSet = new AttrSet();
    }
    if (m_nullAttributes == null) {
        m_nullAttributes = new ArrayList();
    }
    int length = attrNames.length;
    for (int i = 0; i < length; i++) {
        if ((m_attrSet.getAttribute(attrNames[i]) == null) && !m_nullAttributes.contains(attrNames[i])) {
            attributesNotInCache.add(attrNames[i]);
        }
    }
    return attributesNotInCache;
}
Also used : ArrayList(java.util.ArrayList) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 25 with AttrSet

use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.

the class AMDCTree method splitAttrSet.

protected static AttrSet[] splitAttrSet(String orgDN, AttrSet attrSet) throws AMException {
    AttrSet[] attrArray = new AttrSet[2];
    attrArray[0] = new AttrSet();
    attrArray[1] = new AttrSet();
    if (attrSet == null) {
        return (attrArray);
    }
    Set dcNodeAttrs = dcNodeAttributes();
    Iterator it = dcNodeAttrs.iterator();
    while (it.hasNext()) {
        String aName = (String) it.next();
        if (aName.indexOf("objectclass=") > -1) {
            Attr attr = attrSet.getAttribute("objectclass");
            String oc = aName.substring("objectclass=".length());
            Attr dcAttr = new Attr("objectclass");
            if (attr != null && attr.contains(oc)) {
                attr.removeValue(oc);
                dcAttr.addValue(oc);
                attrSet.replace(attr);
                attrArray[1].add(dcAttr);
            }
        } else {
            Attr attr = attrSet.getAttribute(aName);
            if (attr != null) {
                attrArray[1].add(attr);
                attrSet.remove(aName);
            }
        }
    }
    attrArray[0] = attrSet;
    if (debug.messageEnabled()) {
        debug.message("AMCompliance.splitAttrSet: " + "domain attrset = " + attrArray[1].toString());
        debug.message("AMCompliance.splitAttrSet: " + "non-domain attrset = " + attrArray[0].toString());
    }
    return attrArray;
}
Also used : AttrSet(com.iplanet.services.ldap.AttrSet) Set(java.util.Set) Iterator(java.util.Iterator) Attr(com.iplanet.services.ldap.Attr) AttrSet(com.iplanet.services.ldap.AttrSet)

Aggregations

AttrSet (com.iplanet.services.ldap.AttrSet)61 Attr (com.iplanet.services.ldap.Attr)33 Guid (com.iplanet.ums.Guid)19 Iterator (java.util.Iterator)16 Set (java.util.Set)14 UMSException (com.iplanet.ums.UMSException)13 AMException (com.iplanet.am.sdk.AMException)12 CreationTemplate (com.iplanet.ums.CreationTemplate)12 TemplateManager (com.iplanet.ums.TemplateManager)12 HashMap (java.util.HashMap)9 HashSet (java.util.HashSet)9 Map (java.util.Map)9 ArrayList (java.util.ArrayList)8 PersistentObject (com.iplanet.ums.PersistentObject)6 SSOException (com.iplanet.sso.SSOException)5 AMHashMap (com.iplanet.am.sdk.AMHashMap)4 AssignableDynamicGroup (com.iplanet.ums.AssignableDynamicGroup)4 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)3 AccessRightsException (com.iplanet.ums.AccessRightsException)3 EntryAlreadyExistsException (com.iplanet.ums.EntryAlreadyExistsException)3