Examples of LdapUrlParser


Examples of org.apache.harmony.jndi.provider.ldap.parser.LdapUrlParser

        if (url == null) {
            // ldap.2B=LDAP URL should not be null
            throw new NullPointerException(Messages.getString("ldap.2B")); //$NON-NLS-1$
        }

        LdapUrlParser parser = new LdapUrlParser(url);
        try {
            parser.parseURL();
        } catch (ParseException e) {
            // ldap.2C=Invalid LDAP URL
            IllegalArgumentException ex = new IllegalArgumentException(Messages
                    .getString("ldap.2C")); //$NON-NLS-1$
            ex.initCause(e);
            throw ex;
        }

        if (!isAllowedQuery
                && (parser.getFilter() != null || parser.getControls() != null)) {
            // ldap.2D=LDAP URL may only contain host, port and dn components
            throw new InvalidNameException(Messages.getString("ldap.2D")); //$NON-NLS-1$
        }

        return parser;
View Full Code Here

Examples of org.apache.harmony.jndi.provider.ldap.parser.LdapUrlParser

            myEnv = environment;
      } else {
        myEnv = (Hashtable<?, ?>) env.clone();
        }
       
        LdapUrlParser parser = LdapUtils.parserURL(url, false);

        String host = parser.getHost();
        int port = parser.getPort();
        String dn = parser.getBaseObject();

        LdapClient client = LdapClient.newInstance(host, port, myEnv);

        LdapContextImpl context = new LdapContextImpl(client,
                (Hashtable<Object, Object>) myEnv, dn);
View Full Code Here

Examples of org.apache.harmony.jndi.provider.ldap.parser.LdapUrlParser

     * use filter from url.
     *
     */
    public NamingEnumeration<SearchResult> search(String url,
            Attributes attributes, String[] as) throws NamingException {
        LdapUrlParser parser = LdapUtils.parserURL(url, true);
        String dn = parser.getBaseObject();
        String host = parser.getHost();
        int port = parser.getPort();

        LdapClient client = LdapClient.newInstance(host, port, environment);
        LdapContextImpl context = null;
        try {
            context = new LdapContextImpl(client,
                    (Hashtable<Object, Object>) environment, dn);

            SearchControls controls = parser.getControls();
            if (controls == null) {
                controls = new SearchControls();
                controls.setReturningAttributes(as);
            } else if (!parser.hasAttributes()) {
                controls.setReturningAttributes(as);
            }

            // construct filter
            Filter filter = null;
            if (parser.hasFilter()) {
                // use filter in url
                filter = parser.getFilter();
            } else {
                // construct filter from attributes
                if (attributes == null || attributes.size() == 0) {
                    // no attributes, use default filter "(objectClass=*)"
                    filter = new Filter(Filter.PRESENT_FILTER);
View Full Code Here

Examples of org.apache.harmony.jndi.provider.ldap.parser.LdapUrlParser

    }

    public NamingEnumeration<SearchResult> search(String url, String filter,
            Object[] objs, SearchControls searchControls)
            throws NamingException {
        LdapUrlParser parser = LdapUtils.parserURL(url, true);
        String dn = parser.getBaseObject();
        String host = parser.getHost();
        int port = parser.getPort();

        LdapClient client = LdapClient.newInstance(host, port, environment);
        LdapContextImpl context = null;

        try {
            context = new LdapContextImpl(client,
                    (Hashtable<Object, Object>) environment, dn);

            Filter f = parser.getFilter();
            if (f == null) {
                f = LdapUtils.parseFilter(filter, objs);
            }

            if (searchControls == null) {
                searchControls = new SearchControls();
            }
            if (parser.getControls() != null) {
                SearchControls controls = parser.getControls();
                if (parser.hasAttributes()) {
                    searchControls.setReturningAttributes(controls
                            .getReturningAttributes());
                }
                if (parser.hasScope()) {
                    searchControls.setSearchScope(controls.getSearchScope());
                }
            }

            LdapSearchResult result = context.doSearch(dn, f,
View Full Code Here

Examples of org.apache.harmony.jndi.provider.ldap.parser.LdapUrlParser

        result.setRefURLs(null);

        try {
            for (String url : urls) {

                LdapUrlParser urlParser = LdapUtils.parserURL(url, true);
                // if url has dn part overwrite baseObject of last search
                // operation
                if (!urlParser.getBaseObject().equals("")) {
                    op.setBaseObject(urlParser.getBaseObject());
                }
                // if url has filter part overwrite filter of last search
                // operation
                if (urlParser.hasFilter()) {
                    op.setFilter(urlParser.getFilter());
                }
                LdapContextImpl ctx = (LdapContextImpl) getReferralContext(ex);
                result.setAddress("ldap://" + urlParser.getHost() + ":"
                        + urlParser.getPort() + "/");
                ctx.doSearch(op);
                result.setAddress(null);
            }
        } catch (NamingException e) {
            /*
 
View Full Code Here

Examples of org.apache.harmony.jndi.provider.ldap.parser.LdapUrlParser

    public Context getReferralContext() throws NamingException {
        if (index >= referrals.length) {
            return null;
        }

        LdapUrlParser parser = LdapUtils.parserURL(referrals[index], false);

        String host = parser.getHost();
        int port = parser.getPort();

        LdapClient client = LdapClient.newInstance(host, port, env);

        LdapContextImpl context = new LdapContextImpl(client,
                (Hashtable<Object, Object>) env, targetDN);
View Full Code Here

Examples of org.apache.harmony.jndi.provider.ldap.parser.LdapUrlParser

        if (h == null) {
            return getReferralContext();
        }

        Hashtable<Object, Object> myEnv = (Hashtable<Object, Object>) h.clone();
        LdapUrlParser parser = LdapUtils.parserURL(referrals[index], true);

        String host = parser.getHost();
        int port = parser.getPort();

        LdapClient client = LdapClient.newInstance(host, port, myEnv);

        LdapContextImpl context = new LdapContextImpl(client, myEnv, targetDN);
View Full Code Here

Examples of org.apache.harmony.jndi.provider.ldap.parser.LdapUrlParser

            myEnv = new Hashtable<Object, Object>();
        } else {
            myEnv = (Hashtable<Object, Object>) envmt.clone();
        }
        String url = (String) myEnv.get(Context.PROVIDER_URL);
        LdapUrlParser parser = null;
        try {
            parser = LdapUtils.parserURL(url, false);
        } catch (InvalidNameException e) {
            throw new ConfigurationException(e.getMessage());
        }

        String host = parser.getHost();
        int port = parser.getPort();
        String dn = parser.getBaseObject();

        LdapClient client = LdapClient.newInstance(host, port, myEnv);

        LdapContextImpl context = new LdapContextImpl(client, myEnv, dn);
View Full Code Here

Examples of org.apache.harmony.jndi.provider.ldap.parser.LdapUrlParser

            myEnv = new Hashtable<Object, Object>();
        } else {
            myEnv = (Hashtable<Object, Object>) envmt.clone();
        }
        String url = (String) myEnv.get(Context.PROVIDER_URL);
        LdapUrlParser parser = null;
        try {
            parser = LdapUtils.parserURL(url, false);
        } catch (InvalidNameException e) {
            throw new ConfigurationException(e.getMessage());
        }

        String host = parser.getHost();
        int port = parser.getPort();
        String dn = parser.getBaseObject();

        LdapClient client = LdapClient.newInstance(host, port, myEnv, LdapUtils
                .isLdapsURL(url));

        LdapContextImpl context = new LdapContextImpl(client, myEnv, dn);
View Full Code Here

Examples of org.apache.harmony.jndi.provider.ldap.parser.LdapUrlParser

        result.setRefURLs(null);

        try {
            for (String url : urls) {

                LdapUrlParser urlParser = LdapUtils.parserURL(url, true);
                // if url has dn part overwrite baseObject of last search
                // operation
                if (!urlParser.getBaseObject().equals("")) {
                    op.setBaseObject(urlParser.getBaseObject());
                }
                // if url has filter part overwrite filter of last search
                // operation
                if (urlParser.hasFilter()) {
                    op.setFilter(urlParser.getFilter());
                }
                LdapContextImpl ctx = (LdapContextImpl) getReferralContext(ex);
                result.setAddress("ldap://" + urlParser.getHost() + ":"
                        + urlParser.getPort() + "/");
                ctx.doSearch(op);
                result.setAddress(null);
            }
        } catch (NamingException e) {
            /*
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.