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

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


        for ( Value<?> url:refs )
        {
            // we have to replace the parent by the referral
            try
            {
                LdapURL ldapUrl = new LdapURL( url.getString() );
               
                StringBuilder urlString = new StringBuilder();
   
                if ( ( ldapUrl.getDn() == null ) || ( ldapUrl.getDn() == DN.EMPTY_DN) )
                {
                    ldapUrl.setDn( parentEntry.getDn() );
                }
                else
                {
                    // We have a problem with the DN : we can't use the UpName,
                    // as we may have some spaces around the ',' and '+'.
                    // So we have to take the RDN one by one, and create a
                    // new DN with the type and value UP form
                   
                    DN urlDn = (DN)ldapUrl.getDn().addAll( childDn );
                   
                    ldapUrl.setDn( urlDn );
                }
               
                urlString.append( ldapUrl.toString() ).append( "??" );
               
                switch ( scope )
                {
                    case OBJECT :
                        urlString.append( "base" );
View Full Code Here


    /**
     * @param producer the producer to set
     */
    public void setProducer( String producer ) throws LdapURLEncodingException
    {
        this.producer = new LdapURL( producer );
       
        // Update the other fields
        baseDN = this.producer.getDn();
        useSSL = "ldaps".equalsIgnoreCase( this.producer.getScheme() );
        host = this.producer.getHost();
View Full Code Here

                if ( ! url.startsWith( "ldap" ) )
                {
                    respRef.getReferral().addLdapUrl( url );
                }
               
                LdapURL ldapUrl = new LdapURL();
                ldapUrl.setForceScopeRendering( true );
                try
                {
                    ldapUrl.parse( url.toCharArray() );
                }
                catch ( LdapURLEncodingException e )
                {
                    LOG.error( I18n.err( I18n.ERR_165, url, entry ) );
                }

                switch( req.getScope() )
                {
                    case SUBTREE:
                        ldapUrl.setScope( SearchScope.SUBTREE.getScope() );
                        break;
                       
                    case ONELEVEL: // one level here is object level on remote server
                        ldapUrl.setScope( SearchScope.OBJECT.getScope() );
                        break;
                       
                    default:
                        throw new IllegalStateException( I18n.err( I18n.ERR_686 ) );
                }
               
                respRef.getReferral().addLdapUrl( ldapUrl.toString() );
            }
           
            return respRef;
        }
        else
View Full Code Here

                referral.addLdapUrl( refstr );
                continue;
            }
           
            // parse the ref value and normalize the DN 
            LdapURL ldapUrl = new LdapURL();
            try
            {
                ldapUrl.parse( refstr.toCharArray() );
            }
            catch ( LdapURLEncodingException e )
            {
                LOG.error( I18n.err( I18n.ERR_165, refstr, entry ) );
                continue;
            }
           
            ldapUrl.setForceScopeRendering( true );
            ldapUrl.setAttributes( req.getAttributes() );
            ldapUrl.setScope( req.getScope().getScope() );
            referral.addLdapUrl( ldapUrl.toString() );
        }

        session.getIoSession().write( req.getResultResponse() );
    }
View Full Code Here

     */
    public void setUrl( String url )
    {
        try
        {
            this.url = new LdapURL( url );
        }
        catch ( LdapURLEncodingException luee )
        {
            this.url = null;
        }
View Full Code Here

    {
        ServerStringValue ref = ( ServerStringValue ) value;

        String refVal = ref.getString();

        LdapURL ldapUrl = new LdapURL( refVal );

        // We have a LDAP URL, we have to check that :
        // - we don't have scope specifier
        // - we don't have filters
        // - we don't have attribute description list
        // - we don't have extensions
        // - the DN is not empty

        if ( ldapUrl.getScope() != SearchControls.OBJECT_SCOPE )
        {
            // This is the default value if we don't have any scope
            // Let's assume that it's incorrect if we get something
            // else in the LdapURL
            String message = "An LDAPURL should not contains a scope";
            LOG.error( message );
            throw new NamingException( message );
        }

        if ( !StringTools.isEmpty( ldapUrl.getFilter() ) )
        {
            String message = "An LDAPURL should not contains filters";
            LOG.error( message );
            throw new NamingException( message );
        }

        if ( ( ldapUrl.getAttributes() != null ) && ( ldapUrl.getAttributes().size() != 0 ) )
        {
            String message = "An LDAPURL should not contains any description attribute list";
            LOG.error( message );
            throw new NamingException( message );
        }

        if ( ( ldapUrl.getExtensions() != null ) && ( ldapUrl.getExtensions().size() != 0 ) )
        {
            String message = "An LDAPURL should not contains any extension";
            LOG.error( message );
            throw new NamingException( message );
        }

        if ( ( ldapUrl.getExtensions() != null ) && ( ldapUrl.getExtensions().size() != 0 ) )
        {
            String message = "An LDAPURL should not contains any critical extension";
            LOG.error( message );
            throw new NamingException( message );
        }

        LdapDN dn = ldapUrl.getDn();

        if ( ( dn == null ) || dn.isEmpty() )
        {
            String message = "An LDAPURL should contains a non-empty DN";
            LOG.error( message );
View Full Code Here

       
        // manage each Referral, building the correct URL for each of them
        for ( Value<?> url:refs )
        {
            // we have to replace the parent by the referral
            LdapURL ldapUrl = new LdapURL( url.getString() );
           
            // We have a problem with the DN : we can't use the UpName,
            // as we may have some spaces around the ',' and '+'.
            // So we have to take the RDN one by one, and create a
            // new DN with the type and value UP form
           
            LdapDN urlDn = (LdapDN)ldapUrl.getDn().addAll( childDn );
           
            ldapUrl.setDn( urlDn );
            urls.add( ldapUrl.toString() );
        }
       
        // Return with an exception
        LdapReferralException lre = new LdapReferralException( urls );
        lre.setRemainingName( childDn );
View Full Code Here

        for ( Value<?> url:refs )
        {
            // we have to replace the parent by the referral
            try
            {
                LdapURL ldapUrl = new LdapURL( url.getString() );
               
                StringBuilder urlString = new StringBuilder();
   
                if ( ( ldapUrl.getDn() == null ) || ( ldapUrl.getDn() == LdapDN.EMPTY_LDAPDN) )
                {
                    ldapUrl.setDn( parentEntry.getDn() );
                }
                else
                {
                    // We have a problem with the DN : we can't use the UpName,
                    // as we may have some spaces around the ',' and '+'.
                    // So we have to take the RDN one by one, and create a
                    // new DN with the type and value UP form
                   
                    LdapDN urlDn = (LdapDN)ldapUrl.getDn().addAll( childDn );
                   
                    ldapUrl.setDn( urlDn );
                }
               
                urlString.append( ldapUrl.toString() ).append( "??" );
               
                switch ( scope )
                {
                    case OBJECT :
                        urlString.append( "base" );
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() != null )
        {
            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

TOP

Related Classes of org.apache.directory.shared.ldap.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.