com.sun.jndi.ldap.LdapURL Java Examples

The following examples show how to use com.sun.jndi.ldap.LdapURL. 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: ldapURLContextFactory.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static ResolveResult getUsingURLIgnoreRootDN(String url, Hashtable<?,?> env)
        throws NamingException {
    LdapURL ldapUrl = new LdapURL(url);
    DirContext ctx = new LdapCtx("", ldapUrl.getHost(), ldapUrl.getPort(),
        env, ldapUrl.useSsl());
    String dn = (ldapUrl.getDN() != null ? ldapUrl.getDN() : "");

    // Represent DN as empty or single-component composite name.
    CompositeName remaining = new CompositeName();
    if (!"".equals(dn)) {
        // if nonempty, add component
        remaining.add(dn);
    }

    return new ResolveResult(ctx, remaining);
}
 
Example #2
Source File: ldapURLContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public NamingEnumeration<NameClassPair> list(String name)
        throws NamingException {
    if (LdapURL.hasQueryComponents(name)) {
        throw new InvalidNameException(name);
    } else {
        return super.list(name);
    }
}
 
Example #3
Source File: ldapURLContext.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void rename(Name oldName, Name newName) throws NamingException {
    if (LdapURL.hasQueryComponents(oldName.get(0))) {
        throw new InvalidNameException(oldName.toString());
    } else if (LdapURL.hasQueryComponents(newName.get(0))) {
        throw new InvalidNameException(newName.toString());
    } else {
        super.rename(oldName, newName);
    }
}
 
Example #4
Source File: ldapURLContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void destroySubcontext(String name) throws NamingException {
    if (LdapURL.hasQueryComponents(name)) {
        throw new InvalidNameException(name);
    } else {
        super.destroySubcontext(name);
    }
}
 
Example #5
Source File: ldapURLContext.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public NamingEnumeration<SearchResult> search(Name name,
    Attributes matchingAttributes,
    String[] attributesToReturn)
    throws NamingException {

    if (name.size() == 1) {
        return search(name.get(0), matchingAttributes, attributesToReturn);
    } else if (LdapURL.hasQueryComponents(name.get(0))) {
        throw new InvalidNameException(name.toString());
    } else {
        return super.search(name, matchingAttributes, attributesToReturn);
    }
}
 
Example #6
Source File: LdapUnicodeURL.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    // First 3 characters of the CJK Unified Ideographs
    String uid = "uid=\u4e00\u4e01\u4e02";
    LdapURL ldURL = new LdapURL("ldap://www.example.com/" + uid);
    if (!ldURL.getDN().equals(uid)) {
        throw new Exception("uid changed to " + ldURL.getDN());
    }
}
 
Example #7
Source File: ldapURLContext.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Context createSubcontext(String name) throws NamingException {
    if (LdapURL.hasQueryComponents(name)) {
        throw new InvalidNameException(name);
    } else {
        return super.createSubcontext(name);
    }
}
 
Example #8
Source File: ldapURLContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public NamingEnumeration<SearchResult> search(String name,
    String filter,
    SearchControls cons)
    throws NamingException {

    if (LdapURL.hasQueryComponents(name)) {
        return searchUsingURL(name);
    } else {
        return super.search(name, filter, cons);
    }
}
 
Example #9
Source File: ldapURLContext.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void bind(String name, Object obj) throws NamingException {
    if (LdapURL.hasQueryComponents(name)) {
        throw new InvalidNameException(name);
    } else {
        super.bind(name, obj);
    }
}
 
Example #10
Source File: ldapURLContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Object lookup(Name name) throws NamingException {
    if (LdapURL.hasQueryComponents(name.get(0))) {
        throw new InvalidNameException(name.toString());
    } else {
        return super.lookup(name);
    }
}
 
Example #11
Source File: ldapURLContext.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static String setFilterUsingURL(LdapURL url) {

        String filter = url.getFilter();

        if (filter == null) {
            filter = "(objectClass=*)"; //default value
        }
        return filter;
    }
 
Example #12
Source File: ldapURLContext.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Attributes getAttributes(Name name, String[] attrIds)
    throws NamingException {
    if (LdapURL.hasQueryComponents(name.get(0))) {
        throw new InvalidNameException(name.toString());
    } else {
        return super.getAttributes(name, attrIds);
    }
}
 
Example #13
Source File: ldapURLContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Object lookup(Name name) throws NamingException {
    if (LdapURL.hasQueryComponents(name.get(0))) {
        throw new InvalidNameException(name.toString());
    } else {
        return super.lookup(name);
    }
}
 
Example #14
Source File: ldapURLContext.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public NamingEnumeration<NameClassPair> list(String name)
        throws NamingException {
    if (LdapURL.hasQueryComponents(name)) {
        throw new InvalidNameException(name);
    } else {
        return super.list(name);
    }
}
 
Example #15
Source File: ldapURLContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void unbind(String name) throws NamingException {
    if (LdapURL.hasQueryComponents(name)) {
        throw new InvalidNameException(name);
    } else {
        super.unbind(name);
    }
}
 
Example #16
Source File: ldapURLContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public NameParser getNameParser(Name name) throws NamingException {
    if (LdapURL.hasQueryComponents(name.get(0))) {
        throw new InvalidNameException(name.toString());
    } else {
        return super.getNameParser(name);
    }
}
 
Example #17
Source File: ldapURLContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Attributes getAttributes(String name) throws NamingException {
    if (LdapURL.hasQueryComponents(name)) {
        throw new InvalidNameException(name);
    } else {
        return super.getAttributes(name);
    }
}
 
Example #18
Source File: ldapURLContext.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static SearchControls setSearchControlsUsingURL(LdapURL url) {

        SearchControls cons = new SearchControls();
        String scope = url.getScope();
        String attributes = url.getAttributes();

        if (scope == null) {
            cons.setSearchScope(SearchControls.OBJECT_SCOPE); //default value
        } else {
            if (scope.equals("sub")) {
                cons.setSearchScope(SearchControls.SUBTREE_SCOPE);
            } else if (scope.equals("one")) {
                cons.setSearchScope(SearchControls.ONELEVEL_SCOPE);
            } else if (scope.equals("base")) {
                cons.setSearchScope(SearchControls.OBJECT_SCOPE);
            }
        }

        if (attributes == null) {
            cons.setReturningAttributes(null); //default value
        } else {
            StringTokenizer tokens = new StringTokenizer(attributes, ",");
            int count = tokens.countTokens();
            String[] attrs = new String[count];
            for (int i = 0; i < count; i ++) {
                attrs[i] = tokens.nextToken();
            }
            cons.setReturningAttributes(attrs);
        }
        return cons;
    }
 
Example #19
Source File: ldapURLContext.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Attributes getAttributes(String name) throws NamingException {
    if (LdapURL.hasQueryComponents(name)) {
        throw new InvalidNameException(name);
    } else {
        return super.getAttributes(name);
    }
}
 
Example #20
Source File: ldapURLContext.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Attributes getAttributes(Name name, String[] attrIds)
    throws NamingException {
    if (LdapURL.hasQueryComponents(name.get(0))) {
        throw new InvalidNameException(name.toString());
    } else {
        return super.getAttributes(name, attrIds);
    }
}
 
Example #21
Source File: ldapURLContext.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public DirContext getSchema(Name name) throws NamingException {
    if (LdapURL.hasQueryComponents(name.get(0))) {
        throw new InvalidNameException(name.toString());
    } else {
        return super.getSchema(name);
    }
}
 
Example #22
Source File: ldapURLContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Object lookup(Name name) throws NamingException {
    if (LdapURL.hasQueryComponents(name.get(0))) {
        throw new InvalidNameException(name.toString());
    } else {
        return super.lookup(name);
    }
}
 
Example #23
Source File: ldapURLContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private NamingEnumeration<SearchResult> searchUsingURL(String name)
    throws NamingException {

    LdapURL url = new LdapURL(name);

    ResolveResult res = getRootURLContext(name, myEnv);
    DirContext ctx = (DirContext)res.getResolvedObj();
    try {
        return ctx.search(res.getRemainingName(),
                          setFilterUsingURL(url),
                          setSearchControlsUsingURL(url));
    } finally {
        ctx.close();
    }
}
 
Example #24
Source File: ldapURLContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Context createSubcontext(Name name) throws NamingException {
    if (LdapURL.hasQueryComponents(name.get(0))) {
        throw new InvalidNameException(name.toString());
    } else {
        return super.createSubcontext(name);
    }
}
 
Example #25
Source File: ldapURLContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void modifyAttributes(Name name, int mod_op, Attributes attrs)
    throws NamingException {
    if (LdapURL.hasQueryComponents(name.get(0))) {
        throw new InvalidNameException(name.toString());
    } else {
        super.modifyAttributes(name, mod_op, attrs);
    }
}
 
Example #26
Source File: ldapURLContext.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public NamingEnumeration<SearchResult> search(String name,
    Attributes matchingAttributes,
    String[] attributesToReturn)
    throws NamingException {

    if (LdapURL.hasQueryComponents(name)) {
        return searchUsingURL(name);
    } else {
        return super.search(name, matchingAttributes, attributesToReturn);
    }
}
 
Example #27
Source File: ldapURLContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Object lookupLink(Name name) throws NamingException {
    if (LdapURL.hasQueryComponents(name.get(0))) {
        throw new InvalidNameException(name.toString());
    } else {
        return super.lookupLink(name);
    }
}
 
Example #28
Source File: ldapURLContext.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Context createSubcontext(String name) throws NamingException {
    if (LdapURL.hasQueryComponents(name)) {
        throw new InvalidNameException(name);
    } else {
        return super.createSubcontext(name);
    }
}
 
Example #29
Source File: ldapURLContext.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void bind(Name name, Object obj, Attributes attrs)
    throws NamingException {
    if (LdapURL.hasQueryComponents(name.get(0))) {
        throw new InvalidNameException(name.toString());
    } else {
        super.bind(name, obj, attrs);
    }
}
 
Example #30
Source File: ldapURLContext.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void bind(Name name, Object obj) throws NamingException {
    if (LdapURL.hasQueryComponents(name.get(0))) {
        throw new InvalidNameException(name.toString());
    } else {
        super.bind(name, obj);
    }
}