Package org.apache.directory.shared.ldap.codec.util

Examples of org.apache.directory.shared.ldap.codec.util.LdapURL


                }
                else if ( referralsHandlingMethod == ReferralHandlingMethod.FOLLOW )
                {
                    if ( urlAndDn != null )
                    {
                        LdapURL url = urlAndDn.getUrl();
                        Connection referralConnection = JNDIConnectionWrapper
                            .getReferralConnection( url, monitor, this );
                        if ( referralConnection != null )
                        {
                            logResultDone = false;
                            logResultDoneException = null;
                           
                            String referralSearchBase = url.getDn() != null && !url.getDn().isEmpty() ? url.getDn()
                                .getUpName() : searchBase;
                            String referralFilter = url.getFilter() != null && url.getFilter().length() == 0 ? url
                                .getFilter() : filter;
                            SearchControls referralSearchControls = new SearchControls();
                            referralSearchControls.setSearchScope( url.getScope() > -1 ? url.getScope()
                                : searchControls.getSearchScope() );
                            referralSearchControls.setReturningAttributes( url.getAttributes() != null
                                && url.getAttributes().size() > 0 ? url.getAttributes().toArray(
                                new String[url.getAttributes().size()] ) : searchControls.getReturningAttributes() );
                            referralSearchControls.setCountLimit( searchControls.getCountLimit() );
                            referralSearchControls.setTimeLimit( searchControls.getTimeLimit() );
                            referralSearchControls.setDerefLinkFlag( searchControls.getDerefLinkFlag() );
                            referralSearchControls.setReturningObjFlag( searchControls.getReturningObjFlag() );
View Full Code Here


                        {
                            ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
                            UrlAndDn urlAndDn = newReferralsInfo.getNext();
                            if ( urlAndDn != null )
                            {
                                LdapURL url = urlAndDn.getUrl();
                                Connection referralConnection = getReferralConnection( url, monitor, this );
                                if ( referralConnection != null )
                                {
                                    String referralSearchBase = url.getDn() != null && !url.getDn().isEmpty() ? url
                                        .getDn().getUpName() : searchBase;
                                    String referralFilter = url.getFilter() != null && url.getFilter().length() == 0 ? url
                                        .getFilter()
                                        : filter;
                                    SearchControls referralSearchControls = new SearchControls();
                                    referralSearchControls.setSearchScope( url.getScope() > -1 ? url.getScope()
                                        : searchControls.getSearchScope() );
                                    referralSearchControls.setReturningAttributes( url.getAttributes() != null
                                        && url.getAttributes().size() > 0 ? url.getAttributes().toArray(
                                        new String[url.getAttributes().size()] ) : searchControls
                                        .getReturningAttributes() );
                                    referralSearchControls.setCountLimit( searchControls.getCountLimit() );
                                    referralSearchControls.setTimeLimit( searchControls.getTimeLimit() );
                                    referralSearchControls.setDerefLinkFlag( searchControls.getDerefLinkFlag() );
                                    referralSearchControls.setReturningObjFlag( searchControls.getReturningObjFlag() );
View Full Code Here

        try
        {
            String info = ( String ) referralException.getReferralInfo();
            String name = referralException.getRemainingName().toString();
            LdapURL url = new LdapURL( info );
            LdapDN dn = new LdapDN( name );
            initialReferralsInfo.addReferralUrl( url, dn );
        }
        catch ( LdapURLEncodingException e )
        {
        }

        while ( referralException.skipReferral() )
        {
            try
            {
                Context ctx = referralException.getReferralContext();
                ctx.list( "" ); //$NON-NLS-1$
            }
            catch ( NamingException ne )
            {
                if ( ne instanceof ReferralException )
                {
                    referralException = ( ReferralException ) ne;
                    try
                    {
                        String info = ( String ) referralException.getReferralInfo();
                        String name = referralException.getRemainingName().toString();
                        LdapURL url = new LdapURL( info );
                        LdapDN dn = new LdapDN( name );
                        initialReferralsInfo.addReferralUrl( url, dn );
                    }
                    catch ( LdapURLEncodingException e )
                    {
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void run()
    {
        LdapURL url = null;
        if ( getSelectedSearches().length > 0 )
        {
            url = getSelectedSearches()[0].getUrl();
        }
        else if ( getSelectedEntries().length > 0 )
        {
            url = getSelectedEntries()[0].getUrl();
        }
        else if ( getSelectedAttributes().length > 0 )
        {
            url = getSelectedAttributes()[0].getEntry().getUrl();
        }
        else if ( getSelectedAttributeHierarchies().length > 0 )
        {
            url = getSelectedAttributeHierarchies()[0].getAttribute().getEntry().getUrl();
        }
        else if ( getSelectedValues().length > 0 )
        {
            url = getSelectedValues()[0].getAttribute().getEntry().getUrl();
        }
        else if ( getSelectedSearchResults().length > 0 )
        {
            url = getSelectedSearchResults()[0].getEntry().getUrl();
        }
        else if ( getSelectedBookmarks().length > 0 )
        {
            url = getSelectedBookmarks()[0].getEntry().getUrl();
        }

        if ( url != null )
        {
            CopyAction.copyToClipboard( new Object[]
                { url.toString() }, new Transfer[]
                { TextTransfer.getInstance() } );
        }
    }
View Full Code Here

        assertEquals( 1, references.size() );

        try
        {
            assertEquals( new LdapURL( "ldap://localhost" ).toString(), references.get( 0 ).toString() );
        }
        catch ( LdapURLEncodingException e )
        {
            fail();
        }
View Full Code Here

        assertEquals( 2, references.size() );

        try
        {
            assertEquals( new LdapURL( "ldap://localhost" ).toString(), references.get( 0 ).toString() );
        }
        catch ( LdapURLEncodingException e )
        {
            fail();
        }

        try
        {
            assertEquals( new LdapURL( "ldap://www.apache.org" ).toString(), references.get( 1 ).toString() );
        }
        catch ( LdapURLEncodingException e )
        {
            fail();
        }
View Full Code Here

     * @return the LDAP URL for the given search parameters
     */
    public static LdapURL getLdapURL( Connection connection, String searchBase, int scope, String filter,
        String[] attributes )
    {
        LdapURL url = new LdapURL();
        url.setScheme( connection.getEncryptionMethod() == EncryptionMethod.LDAPS ? "ldaps://" : "ldap://" );
        url.setHost( connection.getHost() );
        url.setPort( connection.getPort() );
        try
        {
            url.setDn( new LdapDN( searchBase ) );
        }
        catch ( InvalidNameException e )
        {
        }
        if ( attributes != null )
        {
            url.setAttributes( Arrays.asList( attributes ) );
        }
        url.setScope( scope );
        url.setFilter( filter );
        return url;
    }
View Full Code Here

     * @param entry the entry
     * @return the LDAP URL
     */
    public static LdapURL getLdapURL( IBrowserConnection browserConnection )
    {
        LdapURL url = new LdapURL();
        if ( browserConnection.getConnection().getEncryptionMethod() == EncryptionMethod.LDAPS )
        {
            url.setScheme( LdapURL.LDAPS_SCHEME );
        }
        else
        {
            url.setScheme( LdapURL.LDAP_SCHEME );
        }
        url.setHost( browserConnection.getConnection().getHost() );
        url.setPort( browserConnection.getConnection().getPort() );
        return url;
    }
View Full Code Here

     * @param entry the entry
     * @return the LDAP URL
     */
    public static LdapURL getLdapURL( IEntry entry )
    {
        LdapURL url = getLdapURL( entry.getBrowserConnection() );
        url.setDn( entry.getDn() );
        return url;
    }
View Full Code Here

     * @param search the search
     * @return the LDAP URL
     */
    public static LdapURL getLdapURL( ISearch search )
    {
        LdapURL url = getLdapURL( search.getBrowserConnection() );
        url.setDn( search.getSearchBase() );
        if ( search.getReturningAttributes() != null )
        {
            url.setAttributes( Arrays.asList( search.getReturningAttributes() ) );
        }
        url.setScope( search.getScope().getOrdinal() );
        url.setFilter( search.getFilter() );
        return url;
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.codec.util.LdapURL

Copyright © 2018 www.massapicom. 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.