Search in sources :

Example 51 with AttrSet

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

the class DCTreeServicesImpl method getDomainAttributes.

protected AttrSet getDomainAttributes(SSOToken token, String orgDN, String[] attrNames) throws AMException, SSOException {
    String domainName = null;
    try {
        AttrSet domAttrSet;
        domainName = getCanonicalDomain(token, orgDN);
        if (domainName == null) {
            debug.error("DCTree.getDomainAttributes-> " + "Domain not found for:  " + orgDN);
            return null;
        }
        DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
        DomainComponent dcNode = dcTree.getDomainComponent(domainName);
        if (attrNames != null) {
            domAttrSet = dcNode.getAttributes(attrNames);
        } else {
            domAttrSet = dcNode.getAttributes(dcNode.getAttributeNames());
        }
        AttrSet[] attrArray = splitAttrSet(null, domAttrSet);
        return attrArray[1];
    } catch (UMSException umse) {
        debug.error("DCTree.getDomainAttributes: " + " error getting attributes for domain " + domainName);
    }
    return null;
}
Also used : DomainComponent(com.iplanet.ums.dctree.DomainComponent) UMSException(com.iplanet.ums.UMSException) DomainComponentTree(com.iplanet.ums.dctree.DomainComponentTree) Guid(com.iplanet.ums.Guid) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 52 with AttrSet

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

the class SearchResults method next.

/**
     * Returns the next entry in the search results.
     * 
     * @throws UMSException
     *             No more entries in the search results.
     * @supported.api
     */
public PersistentObject next() throws UMSException {
    // TODO: define detailed exception list (eg. referral, ...)
    //
    SearchResultEntry ldapEntry;
    if (m_attrVals != null) {
        if (m_attrIndex < m_attrVals.length) {
            String dn = m_attrVals[m_attrIndex++];
            PersistentObject pO = new PersistentObject();
            pO.setGuid(new Guid(dn));
            pO.setPrincipal(m_principal);
            return pO;
        } else {
            throw new NoSuchElementException();
        }
    }
    if ((ldapEntry = currentEntry) != null) {
        String id = ldapEntry.getName().toString();
        Collection<Attribute> attributes = new ArrayList<>();
        for (Attribute attribute : ldapEntry.getAllAttributes()) {
            attributes.add(attribute);
        }
        AttrSet attrSet = new AttrSet(attributes);
        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);
        }
        // Make it a live object
        pO.setAttrSet(attrSet);
        pO.setGuid(new Guid(ldapEntry.getName().toString()));
        pO.setPrincipal(m_principal);
        return pO;
    }
    return null;
}
Also used : Attribute(org.forgerock.opendj.ldap.Attribute) ArrayList(java.util.ArrayList) NoSuchElementException(java.util.NoSuchElementException) LdapException(org.forgerock.opendj.ldap.LdapException) NoSuchElementException(java.util.NoSuchElementException) SearchResultReferenceIOException(org.forgerock.opendj.ldap.SearchResultReferenceIOException) SearchResultEntry(org.forgerock.opendj.ldap.responses.SearchResultEntry) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 53 with AttrSet

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

the class Resource 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 54 with AttrSet

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

the class TemplateManager method toAttrSet.

private AttrSet toAttrSet(CreationTemplate t) {
    AttrSet attrSet = new AttrSet();
    attrSet.add(new Attr(TemplateManager.TEMPLATE_NAME, t.getName()));
    attrSet.add(new Attr(TemplateManager.TEMPLATE_NAMINGATTRIBUTE, t.getNamingAttribute()));
    ArrayList classes = t.getCreationClasses();
    String[] classNames = new String[classes.size()];
    for (int i = 0; i < classes.size(); i++) {
        Class cls = (Class) classes.get(i);
        classNames[i] = cls.getName();
    }
    attrSet.add(new Attr(TemplateManager.TEMPLATE_JAVACLASS, classNames));
    Attr required = encodeAttrSet(TemplateManager.TEMPLATE_REQUIRED, t.getRequiredAttributeSet(), "=");
    if (required != null) {
        attrSet.add(required);
    }
    Attr optional = encodeAttrSet(TemplateManager.TEMPLATE_OPTIONAL, t.getOptionalAttributeSet(), "=");
    if (optional != null) {
        attrSet.add(optional);
    }
    Attr validated = encodeAttrSet(TemplateManager.TEMPLATE_VALIDATED, t.getValidation(), "=");
    if (validated != null) {
        attrSet.add(validated);
    }
    return attrSet;
}
Also used : ArrayList(java.util.ArrayList) Attr(com.iplanet.services.ldap.Attr) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 55 with AttrSet

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

the class PersistentObject method readAttributesFromDataStore.

/**
     * Read the attributes from data store
     * 
     * @param attrNames
     *            names of attributes to get
     * @return collection of Attr read from data store
     */
private Collection readAttributesFromDataStore(Collection attrNames) throws UMSException {
    Collection attributes = DataLayer.getInstance().getAttributes(getPrincipal(), getGuid(), attrNames);
    if (attributes == null) {
        String[] args = { getDN() };
        throw new UMSException(i18n.getString(IUMSConstants.READ_ATTRIBUTES_ERROR, args));
    }
    Collection foundAttributes = new ArrayList();
    if (m_attrSet == null) {
        m_attrSet = new AttrSet();
    }
    if (m_nullAttributes == null) {
        m_nullAttributes = new ArrayList();
    }
    Iterator iter = attributes.iterator();
    while (iter.hasNext()) {
        Attr attr = (Attr) iter.next();
        foundAttributes.add(attr.getName());
        m_attrSet.replace(attr);
    }
    iter = attrNames.iterator();
    while (iter.hasNext()) {
        String attrName = (String) iter.next();
        if (!foundAttributes.contains(attrName) && !m_nullAttributes.contains(attrName)) {
            m_nullAttributes.add(attrName);
        }
    }
    return attributes;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Collection(java.util.Collection) ByteString(org.forgerock.opendj.ldap.ByteString) 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