Java Code Examples for javax.naming.directory.SearchControls#OBJECT_SCOPE

The following examples show how to use javax.naming.directory.SearchControls#OBJECT_SCOPE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContextEnumerator.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected ContextEnumerator(Context context, int scope, String contextName,
                         boolean returnSelf)
    throws NamingException {
    if(context == null) {
        throw new IllegalArgumentException("null context passed");
    }

    root = context;

    // No need to list children if we're only searching object
    if (scope != SearchControls.OBJECT_SCOPE) {
        children = getImmediateChildren(context);
    }
    this.scope = scope;
    this.contextName = contextName;
    // pretend root is processed, if we're not supposed to return ourself
    rootProcessed = !returnSelf;
    prepNextChild();
}
 
Example 2
Source File: ContextEnumerator.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
protected ContextEnumerator(Context context, int scope, String contextName,
                         boolean returnSelf)
    throws NamingException {
    if(context == null) {
        throw new IllegalArgumentException("null context passed");
    }

    root = context;

    // No need to list children if we're only searching object
    if (scope != SearchControls.OBJECT_SCOPE) {
        children = getImmediateChildren(context);
    }
    this.scope = scope;
    this.contextName = contextName;
    // pretend root is processed, if we're not supposed to return ourself
    rootProcessed = !returnSelf;
    prepNextChild();
}
 
Example 3
Source File: ContextEnumerator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected ContextEnumerator(Context context, int scope, String contextName,
                         boolean returnSelf)
    throws NamingException {
    if(context == null) {
        throw new IllegalArgumentException("null context passed");
    }

    root = context;

    // No need to list children if we're only searching object
    if (scope != SearchControls.OBJECT_SCOPE) {
        children = getImmediateChildren(context);
    }
    this.scope = scope;
    this.contextName = contextName;
    // pretend root is processed, if we're not supposed to return ourself
    rootProcessed = !returnSelf;
    prepNextChild();
}
 
Example 4
Source File: ContextEnumerator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected ContextEnumerator(Context context, int scope, String contextName,
                         boolean returnSelf)
    throws NamingException {
    if(context == null) {
        throw new IllegalArgumentException("null context passed");
    }

    root = context;

    // No need to list children if we're only searching object
    if (scope != SearchControls.OBJECT_SCOPE) {
        children = getImmediateChildren(context);
    }
    this.scope = scope;
    this.contextName = contextName;
    // pretend root is processed, if we're not supposed to return ourself
    rootProcessed = !returnSelf;
    prepNextChild();
}
 
Example 5
Source File: ContextEnumerator.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
protected ContextEnumerator(Context context, int scope, String contextName,
                         boolean returnSelf)
    throws NamingException {
    if(context == null) {
        throw new IllegalArgumentException("null context passed");
    }

    root = context;

    // No need to list children if we're only searching object
    if (scope != SearchControls.OBJECT_SCOPE) {
        children = getImmediateChildren(context);
    }
    this.scope = scope;
    this.contextName = contextName;
    // pretend root is processed, if we're not supposed to return ourself
    rootProcessed = !returnSelf;
    prepNextChild();
}
 
Example 6
Source File: ContextEnumerator.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Binding next() throws NamingException {
    if (!rootProcessed) {
        rootProcessed = true;
        return new Binding("", root.getClass().getName(),
                           root, true);
    }

    if (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants()) {
        return getNextDescendant();
    }

    throw new NoSuchElementException();
}
 
Example 7
Source File: ContextEnumerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Binding next() throws NamingException {
    if (!rootProcessed) {
        rootProcessed = true;
        return new Binding("", root.getClass().getName(),
                           root, true);
    }

    if (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants()) {
        return getNextDescendant();
    }

    throw new NoSuchElementException();
}
 
Example 8
Source File: ContextEnumerator.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Binding next() throws NamingException {
    if (!rootProcessed) {
        rootProcessed = true;
        return new Binding("", root.getClass().getName(),
                           root, true);
    }

    if (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants()) {
        return getNextDescendant();
    }

    throw new NoSuchElementException();
}
 
Example 9
Source File: ContextEnumerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Binding next() throws NamingException {
    if (!rootProcessed) {
        rootProcessed = true;
        return new Binding("", root.getClass().getName(),
                           root, true);
    }

    if (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants()) {
        return getNextDescendant();
    }

    throw new NoSuchElementException();
}
 
Example 10
Source File: ContextEnumerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Binding next() throws NamingException {
    if (!rootProcessed) {
        rootProcessed = true;
        return new Binding("", root.getClass().getName(),
                           root, true);
    }

    if (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants()) {
        return getNextDescendant();
    }

    throw new NoSuchElementException();
}
 
Example 11
Source File: ContextEnumerator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Binding next() throws NamingException {
    if (!rootProcessed) {
        rootProcessed = true;
        return new Binding("", root.getClass().getName(),
                           root, true);
    }

    if (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants()) {
        return getNextDescendant();
    }

    throw new NoSuchElementException();
}
 
Example 12
Source File: ContextEnumerator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public boolean hasMore() throws NamingException {
    return !rootProcessed ||
        (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants());
}
 
Example 13
Source File: LdapReader.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static Node fromXML(TransformationGraph graph, Element nodeXML) throws XMLConfigurationException, AttributeNotFoundException {
	ComponentXMLAttributes xattribs = new ComponentXMLAttributes(nodeXML, graph);
	LdapReader aLdapReader = null;
	int i_scope = SearchControls.OBJECT_SCOPE;
	
	String scope = xattribs.getString(XML_SCOPE_ATTRIBUTE, null);
	String sMsg = null;
	if (scope == null) {
		sMsg = "Missing scope specification";
	} else if(scope.equalsIgnoreCase("OBJECT")) {
		// i_scope = SearchControls.OBJECT_SCOPE;	// default value
	} else if(scope.equalsIgnoreCase("ONELEVEL")) {
		i_scope = SearchControls.ONELEVEL_SCOPE;
	} else if(scope.equalsIgnoreCase("SUBTREE")) {
		i_scope = SearchControls.SUBTREE_SCOPE;
	} else {
		sMsg = "Invalid scope specification \"" + scope + "\"";
	}
	if (sMsg != null) {
		StringBuffer msg = new StringBuffer();
		
		msg.append(sMsg);
		msg.append(" in component ").append(xattribs.getString(Node.XML_ID_ATTRIBUTE, "unknown ID"));
		msg.append("; defaulting to scope \"OBJECT\"");
		logger.warn(msg.toString());
	}

	if(xattribs.exists(XML_USER_ATTRIBUTE) && xattribs.exists(XML_PASSWORD_ATTRIBUTE) ) {
		aLdapReader = new LdapReader(
				xattribs.getString(Node.XML_ID_ATTRIBUTE),
				xattribs.getStringEx(XML_LDAPURL_ATTRIBUTE, null, RefResFlag.URL),
				xattribs.getString(XML_BASE_ATTRIBUTE, null),
				xattribs.getString(XML_FILTER_ATTRIBUTE, null),
				i_scope,
				xattribs.getString(XML_USER_ATTRIBUTE),
				xattribs.getStringEx(XML_PASSWORD_ATTRIBUTE, RefResFlag.PASSWORD));
	} else {
		aLdapReader = new LdapReader(
				xattribs.getString(Node.XML_ID_ATTRIBUTE),
				xattribs.getStringEx(XML_LDAPURL_ATTRIBUTE, null, RefResFlag.URL),
				xattribs.getString(XML_BASE_ATTRIBUTE, null),
				xattribs.getString(XML_FILTER_ATTRIBUTE, null),
				i_scope);
	}
	if (xattribs.exists(XML_MULTI_VALUE_SEPARATOR_ATTRIBUTE)) {
		aLdapReader.setMultiValueSeparator(xattribs.getString(XML_MULTI_VALUE_SEPARATOR_ATTRIBUTE));
	}
	if (xattribs.exists(XML_ALIAS_HANDLING_ATTRIBUTE)) {
		aLdapReader.setAliasHandling(Enum.valueOf(AliasHandling.class, xattribs.getString(XML_ALIAS_HANDLING_ATTRIBUTE)));
	}
	if (xattribs.exists(XML_REFERRAL_HANDLING_ATTRIBUTE)) {
		aLdapReader.setReferralHandling(Enum.valueOf(ReferralHandling.class, xattribs.getString(XML_REFERRAL_HANDLING_ATTRIBUTE)));
	}
	if (xattribs.exists(XML_DEFAULT_MAPPING_FIELD)){
		aLdapReader.setDefaultMappingField(xattribs.getString(XML_DEFAULT_MAPPING_FIELD));
	}
	if (xattribs.exists(XML_PAGE_SIZE)){
		aLdapReader.setPageSize(xattribs.getInteger(XML_PAGE_SIZE));
	}
	if (xattribs.exists(XML_ALL_LDAP_ATTRIBUTES)){
		aLdapReader.setAllAttributes(xattribs.getBoolean(XML_ALL_LDAP_ATTRIBUTES));
	}
	if (xattribs.exists(XML_ADDITIONAL_BINARY_ATTRIBUTES)){
		aLdapReader.setAdditionalBinaryAttributes(xattribs.getString(XML_ADDITIONAL_BINARY_ATTRIBUTES));
	}
	if (xattribs.exists(XML_ADDITIONAL_LDAP_ENV)){
		aLdapReader.setLdapExtraPropertiesDef(xattribs.getString(XML_ADDITIONAL_LDAP_ENV));
	}
	
	return aLdapReader;
}
 
Example 14
Source File: ContextEnumerator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public boolean hasMore() throws NamingException {
    return !rootProcessed ||
        (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants());
}
 
Example 15
Source File: ContextEnumerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public boolean hasMore() throws NamingException {
    return !rootProcessed ||
        (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants());
}
 
Example 16
Source File: DefaultDirContextValidatorTest.java    From spring-ldap with Apache License 2.0 4 votes vote down vote up
@Test
   public void testSearchScopeObjectScopeSetInConstructorIsUsed() throws Exception {
       DefaultDirContextValidator tested = new DefaultDirContextValidator(SearchControls.OBJECT_SCOPE);
       assertThat(tested.getSearchControls().getSearchScope()).as("OBJECT_SCOPE, ").isEqualTo(SearchControls.OBJECT_SCOPE);
}
 
Example 17
Source File: ContextEnumerator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public boolean hasMore() throws NamingException {
    return !rootProcessed ||
        (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants());
}
 
Example 18
Source File: ContextEnumerator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public boolean hasMore() throws NamingException {
    return !rootProcessed ||
        (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants());
}
 
Example 19
Source File: ContextEnumerator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public boolean hasMore() throws NamingException {
    return !rootProcessed ||
        (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants());
}
 
Example 20
Source File: DefaultDirContextValidator.java    From spring-ldap with Apache License 2.0 2 votes vote down vote up
/**
 * Create the default validator, creates {@link SearchControls} with search scope <code>OBJECT_SCOPE</code>,
 * a countLimit of 1, returningAttributes of objectclass and timeLimit of 500.
 * The default base is an empty string and the default filter is objectclass=*
 */
public DefaultDirContextValidator() {
    this(SearchControls.OBJECT_SCOPE);        
}