Search in sources :

Example 6 with SearchResults

use of com.iplanet.ums.SearchResults in project OpenAM by OpenRock.

the class DomainComponentTree method addDomain.

/**
     * Add a virtual domain into the domain component
     * tree.
     * 
     * @param domain
     *            Fully qualified domain name
     * @return Domain Componet entry just added to the dctree
     * @throws InvalidDCRootException
     *             if dcroot is not defined
     * @throws UMSException
     *             for write problem in adding domain to dctree
     * @supported.api
     */
public DomainComponent addDomain(String domain) throws UMSException {
    if (domain == null || domain.length() == 0) {
        throw new IllegalArgumentException();
    }
    if (m_dcRoot == null) {
        throw new InvalidDCRootException();
    }
    StringTokenizer st = new StringTokenizer(domain, ".");
    int nDoms = st.countTokens();
    String[] doms = new String[nDoms];
    int i = 0;
    while (st.hasMoreElements()) {
        doms[i++] = st.nextToken();
    }
    PersistentObject parent = UMSObject.getObject(getSSOToken(), m_dcRoot.getGuid());
    // Going from right to left on the virtual domain name
    // to go through all the domain components (dc). Make sure that
    // all dc entries are created in the dctree
    // e.g. adding a domain for eng.sun.com with dcRoot being o=internet
    // will yield
    // <pre>
    // o=internet (assmumed to exist)
    // dc=com,o=internet (created)
    // dc=sun,dc=com,o=ineternet (created)
    // dc=eng,dc=sun,dc=com,o=internet (created)
    // </pre>
    // in the domain component tree
    //
    DomainComponent dc = null;
    for (i = 0; i < nDoms; i++) {
        SearchResults results = parent.getChildren("dc=" + doms[nDoms - i - 1], null);
        try {
            dc = (DomainComponent) results.assertOneEntry();
        } catch (EntryNotFoundException e) {
            dc = new DomainComponent(getSSOToken(), doms[nDoms - i - 1]);
            parent.addChild(dc);
        }
        parent = UMSObject.getObject(getSSOToken(), dc.getGuid());
    }
    return dc;
}
Also used : StringTokenizer(java.util.StringTokenizer) EntryNotFoundException(com.iplanet.ums.EntryNotFoundException) PersistentObject(com.iplanet.ums.PersistentObject) SearchResults(com.iplanet.ums.SearchResults)

Example 7 with SearchResults

use of com.iplanet.ums.SearchResults in project OpenAM by OpenRock.

the class DomainComponentTree method getUser.

/**
     * Given identification of a user with a naming
     * attribute and value, lookup the user under a virtual domain specified.
     * For example,
     * 
     * <pre>
     * DomainComponentTree dctree = new DomainComponentTree(ctx,
     *                                           &quot;red.iplanet.com&quot;);
     * 
     * User user = dctree.getUser(&quot;cn&quot;, &quot;Hin Man&quot;, 
     *                                             &quot;red.iplanet.com&quot;);
     * </pre>
     * 
     * @param namingAttribute
     *            Naming attribute for the user object such as "uid" or "mail".
     *            The naming attribute has to provide a unique identifier for
     *            the user.
     * @param value
     *            attribute value for the naming attribute
     * @param domain
     *            Fully qualified domain name such as "red.iplanet.com"
     * @return User object if found
     * @throws DomainNotFoundException
     *             if domain is not found
     * @throws UMSException
     *             upon failure in instantiating the user object
     * @supported.api
     */
public User getUser(String namingAttribute, String value, String domain) throws DomainNotFoundException, UMSException {
    PersistentObject orgEntry = getOrganization(domain);
    SearchResults result = orgEntry.search(namingAttribute + "=" + value, null);
    return (User) result.assertOneEntry();
}
Also used : User(com.iplanet.ums.User) PersistentObject(com.iplanet.ums.PersistentObject) SearchResults(com.iplanet.ums.SearchResults)

Example 8 with SearchResults

use of com.iplanet.ums.SearchResults in project OpenAM by OpenRock.

the class DomainComponentTree method getChildDomainIDs.

/**
     * Get all virtual domains present in the dctree.
     * Construct a hashtable of the found domain names and their associated
     * organization in the customer organizational DIT (the convergence tree)
     * <p>
     * 
     * This function can be used as a cache function for the complete DCTree.
     * The returning hastable provides all the virtual domain name as keys that
     * maps to organization mapping linked in the domain component dc nodes
     * <p>
     * 
     * @return Hashtable of domain names and associated organizations. Each
     *         domain name is associated with one organization but muliple
     *         domain names can map to the same organization in the customer
     *         DIT.
     * @throws UMSException
     *             upon failure in searching all mapped domains
     * @supported.api
     */
public Hashtable getChildDomainIDs() throws UMSException {
    if (m_dcRoot == null) {
        return null;
    }
    // Search in DCTree that have a link to a mapped organization
    //
    SearchResults results = m_dcRoot.search("(&(objectclass=inetDomain)(inetDomainBaseDN=*))", null);
    Hashtable domains = new Hashtable();
    //
    while (results.hasMoreElements()) {
        DomainComponent dc = (DomainComponent) results.next();
        String domainName = mapDCToDomainName(dc);
        domains.put(domainName, dc.getAssociatedOrganizationGuid().getDn());
    }
    return domains;
}
Also used : Hashtable(java.util.Hashtable) SearchResults(com.iplanet.ums.SearchResults)

Example 9 with SearchResults

use of com.iplanet.ums.SearchResults in project OpenAM by OpenRock.

the class DirectCOSDefinition method getCOSTemplate.

/**
     * Returns a template from this definition given the name of the template.
     * 
     * @param name
     *            The name of the template to be returned.
     * 
     * @return The COS template.
     * 
     * @throws COSNotFoundException
     *             The exception thrown if the COS template is not found.
     * @throws UMSException
     *             The exception thrown from the data layer.
     * @supported.api
     */
public COSTemplate getCOSTemplate(String name) throws COSNotFoundException, UMSException {
    COSTemplate cosTemplate = null;
    String[] resultAttributes = { "*" };
    SearchResults sr = this.search("(" + COSTemplate.DEFAULT_NAMING_ATTR + "=" + name + ")", resultAttributes, null);
    while (sr.hasMoreElements()) {
        cosTemplate = (COSTemplate) sr.next();
        sr.abandon();
    }
    if (cosTemplate == null) {
        String msg = i18n.getString(IUMSConstants.COS_TEMPLATE_NOT_FOUND);
        throw new COSNotFoundException(msg);
    }
    return cosTemplate;
}
Also used : SearchResults(com.iplanet.ums.SearchResults)

Example 10 with SearchResults

use of com.iplanet.ums.SearchResults in project OpenAM by OpenRock.

the class COSManager method getDefinitions.

/**
     * Retrieves all COS definitions for the current organization. This
     * COSManager instance applies to an organization.
     * 
     * @return A collection of COS definition objects.
     * 
     * @throws UMSException
     *             The exception thrown from the data layer.
     * @supported.api
     */
public Collection getDefinitions() throws UMSException {
    Collection cosDefinitions = new ArrayList();
    SearchResults sr = _parentObject.search(ICOSDefinition.COSSUPERDEF_SEARCH, DEF_ATTRIBUTE_NAMES, null);
    while (sr.hasMoreElements()) {
        cosDefinitions.add(sr.next());
    }
    return cosDefinitions;
}
Also used : ArrayList(java.util.ArrayList) AbstractCollection(java.util.AbstractCollection) Collection(java.util.Collection) SearchResults(com.iplanet.ums.SearchResults)

Aggregations

SearchResults (com.iplanet.ums.SearchResults)13 PersistentObject (com.iplanet.ums.PersistentObject)7 Guid (com.iplanet.ums.Guid)6 UMSException (com.iplanet.ums.UMSException)6 AMSearchResults (com.iplanet.am.sdk.AMSearchResults)5 AMException (com.iplanet.am.sdk.AMException)4 SearchControl (com.iplanet.ums.SearchControl)4 EntryNotFoundException (com.iplanet.ums.EntryNotFoundException)3 ArrayList (java.util.ArrayList)3 LdapException (org.forgerock.opendj.ldap.LdapException)3 ResultCode (org.forgerock.opendj.ldap.ResultCode)3 Collection (java.util.Collection)2 AMPreCallBackException (com.iplanet.am.sdk.AMPreCallBackException)1 Attr (com.iplanet.services.ldap.Attr)1 AttrSet (com.iplanet.services.ldap.AttrSet)1 AccessRightsException (com.iplanet.ums.AccessRightsException)1 AssignableDynamicGroup (com.iplanet.ums.AssignableDynamicGroup)1 DynamicGroup (com.iplanet.ums.DynamicGroup)1 FilteredRole (com.iplanet.ums.FilteredRole)1 InvalidSearchFilterException (com.iplanet.ums.InvalidSearchFilterException)1