Package org.apache.directory.shared.ldap.message.internal

Examples of org.apache.directory.shared.ldap.message.internal.InternalReferral


            }
           
            // Add the referrals if necessary
            if ( e instanceof LdapReferralException )
            {
                InternalReferral referrals = new ReferralImpl();
               
                do
                {
                    String ref = ((LdapReferralException)e).getReferralInfo();
                    referrals.addLdapUrl( ref );
                }
                while ( ((LdapReferralException)e).skipReferral() );
               
                result.setReferral( referrals );
            }
View Full Code Here


    {
        LOG.debug( "Inside getReferralOnAncestor()" );
       
        ServerAttribute refAttr = ( ServerAttribute ) referralAncestor.getOriginalEntry()
            .get( SchemaConstants.REF_AT );
        InternalReferral referral = new ReferralImpl();

        for ( Value<?> value : refAttr )
        {
            String ref = value.getString();

            LOG.debug( "Calculating LdapURL for referrence value {}", ref );

            // need to add non-ldap URLs as-is
            if ( ! ref.startsWith( "ldap" ) )
            {
                referral.addLdapUrl( ref );
                continue;
            }
           
            // parse the ref value and normalize the DN 
            LdapURL ldapUrl = new LdapURL();
            try
            {
                ldapUrl.parse( ref.toCharArray() );
            }
            catch ( LdapURLEncodingException e )
            {
                LOG.error( I18n.err( I18n.ERR_165, ref, referralAncestor ) );
            }
           
            DN urlDn = new DN( ldapUrl.getDn().getName() );
            urlDn.normalize( session.getCoreSession().getDirectoryService().getSchemaManager()
                .getNormalizerMapping() );
           
            if ( urlDn.getNormName().equals( referralAncestor.getDn().getNormName() ) )
            {
                // according to the protocol there is no need for the dn since it is the same as this request
                StringBuilder buf = new StringBuilder();
                buf.append( ldapUrl.getScheme() );
                buf.append( ldapUrl.getHost() );

                if ( ldapUrl.getPort() > 0 )
                {
                    buf.append( ":" );
                    buf.append( ldapUrl.getPort() );
                }

                referral.addLdapUrl( buf.toString() );
                continue;
            }
           
            /*
             * If we get here then the DN of the referral was not the same as the
             * DN of the ref LDAP URL.  We must calculate the remaining (difference)
             * name past the farthest referral DN which the target name extends.
             */
            int diff = reqTargetDn.size() - referralAncestor.getDn().size();
            DN extra = new DN();

            // TODO - fix this by access unormalized RDN values
            // seems we have to do this because get returns normalized rdns
            DN reqUnnormalizedDn = new DN( reqTargetDn.getName() );
            for ( int jj = 0; jj < diff; jj++ )
            {
                extra.add( reqUnnormalizedDn.get( referralAncestor.getDn().size() + jj ) );
            }

            urlDn.addAll( extra );

            StringBuilder buf = new StringBuilder();
            buf.append( ldapUrl.getScheme() );
            buf.append( ldapUrl.getHost() );

            if ( ldapUrl.getPort() > 0 )
            {
                buf.append( ":" );
                buf.append( ldapUrl.getPort() );
            }

            buf.append( "/" );
            buf.append( LdapURL.urlEncode( urlDn.getName(), false ) );
            referral.addLdapUrl( buf.toString() );
        }
       
        return referral;
    }
View Full Code Here

    {
        LOG.debug( "Inside getReferralOnAncestor()" );
    
        ServerAttribute refAttr = ( ServerAttribute ) referralAncestor.getOriginalEntry()
            .get( SchemaConstants.REF_AT );
        InternalReferral referral = new ReferralImpl();

        for ( Value<?> value : refAttr )
        {
            String ref = value.getString();

            LOG.debug( "Calculating LdapURL for referrence value {}", ref );

            // need to add non-ldap URLs as-is
            if ( ! ref.startsWith( "ldap" ) )
            {
                referral.addLdapUrl( ref );
                continue;
            }
           
            // Parse the ref value  
            LdapURL ldapUrl = new LdapURL();
            try
            {
                ldapUrl.parse( ref.toCharArray() );
            }
            catch ( LdapURLEncodingException e )
            {
                LOG.error( I18n.err( I18n.ERR_165, ref, referralAncestor ) );
            }
           
            // Normalize the DN to check for same dn
            DN urlDn = new DN( ldapUrl.getDn().getName() );
            urlDn.normalize( session.getCoreSession().getDirectoryService().getSchemaManager()
                .getNormalizerMapping() );
           
            if ( urlDn.getNormName().equals( req.getBase().getNormName() ) )
            {
                ldapUrl.setForceScopeRendering( true );
                ldapUrl.setAttributes( req.getAttributes() );
                ldapUrl.setScope( req.getScope().getScope() );
                referral.addLdapUrl( ldapUrl.toString() );
                continue;
            }
           
            /*
             * If we get here then the DN of the referral was not the same as the
             * DN of the ref LDAP URL.  We must calculate the remaining (difference)
             * name past the farthest referral DN which the target name extends.
             */
            int diff = req.getBase().size() - referralAncestor.getDn().size();
            DN extra = new DN();

            // TODO - fix this by access unormalized RDN values
            // seems we have to do this because get returns normalized rdns
            DN reqUnnormalizedDn = new DN( req.getBase().getName() );
            for ( int jj = 0; jj < diff; jj++ )
            {
                extra.add( reqUnnormalizedDn.get( referralAncestor.getDn().size() + jj ) );
            }

            ldapUrl.getDn().addAll( extra );
            ldapUrl.setForceScopeRendering( true );
            ldapUrl.setAttributes( req.getAttributes() );
            ldapUrl.setScope( req.getScope().getScope() );
            referral.addLdapUrl( ldapUrl.toString() );
        }
       
        return referral;
    }
View Full Code Here

                }
                 
                // if we get here then we have a valid referral ancestor
                try
                {
                    InternalReferral referral = getReferralOnAncestorForSearch( session, ( InternalSearchRequest ) req, referralAncestor );
                   
                    result.setResultCode( ResultCodeEnum.REFERRAL );
                    result.setReferral( referral );
                    session.getIoSession().write( req.getResultResponse() );
                }
View Full Code Here

    {
        LOG.debug( "Inside getReferralOnAncestor()" );
       
        EntryAttribute refAttr =referralAncestor.getOriginalEntry()
            .get( SchemaConstants.REF_AT );
        InternalReferral referral = new ReferralImpl();

        for ( Value<?> value : refAttr )
        {
            String ref = value.getString();

            LOG.debug( "Calculating LdapURL for referrence value {}", ref );

            // need to add non-ldap URLs as-is
            if ( ! ref.startsWith( "ldap" ) )
            {
                referral.addLdapUrl( ref );
                continue;
            }
           
            // parse the ref value and normalize the DN 
            LdapURL ldapUrl = new LdapURL();
            try
            {
                ldapUrl.parse( ref.toCharArray() );
            }
            catch ( LdapURLEncodingException e )
            {
                LOG.error( I18n.err( I18n.ERR_165, ref, referralAncestor ) );
            }
           
            DN urlDn = new DN( ldapUrl.getDn().getName() );
            urlDn.normalize( session.getCoreSession().getDirectoryService().getSchemaManager()
                .getNormalizerMapping() );
           
            if ( urlDn.getNormName().equals( referralAncestor.getDn().getNormName() ) )
            {
                // according to the protocol there is no need for the dn since it is the same as this request
                StringBuilder buf = new StringBuilder();
                buf.append( ldapUrl.getScheme() );
                buf.append( ldapUrl.getHost() );

                if ( ldapUrl.getPort() > 0 )
                {
                    buf.append( ":" );
                    buf.append( ldapUrl.getPort() );
                }

                referral.addLdapUrl( buf.toString() );
                continue;
            }
           
            /*
             * If we get here then the DN of the referral was not the same as the
             * DN of the ref LDAP URL.  We must calculate the remaining (difference)
             * name past the farthest referral DN which the target name extends.
             */
            int diff = reqTargetDn.size() - referralAncestor.getDn().size();
            DN extra = new DN();

            // TODO - fix this by access unormalized RDN values
            // seems we have to do this because get returns normalized rdns
            DN reqUnnormalizedDn = new DN( reqTargetDn.getName() );
            for ( int jj = 0; jj < diff; jj++ )
            {
                extra.add( reqUnnormalizedDn.get( referralAncestor.getDn().size() + jj ) );
            }

            urlDn.addAll( extra );

            StringBuilder buf = new StringBuilder();
            buf.append( ldapUrl.getScheme() );
            buf.append( ldapUrl.getHost() );

            if ( ldapUrl.getPort() > 0 )
            {
                buf.append( ":" );
                buf.append( ldapUrl.getPort() );
            }

            buf.append( "/" );
            buf.append( LdapURL.urlEncode( urlDn.getName(), false ) );
            referral.addLdapUrl( buf.toString() );
        }
       
        return referral;
    }
View Full Code Here

    {
        LOG.debug( "Inside getReferralOnAncestor()" );
    
        EntryAttribute refAttr = referralAncestor.getOriginalEntry()
            .get( SchemaConstants.REF_AT );
        InternalReferral referral = new ReferralImpl();

        for ( Value<?> value : refAttr )
        {
            String ref = value.getString();

            LOG.debug( "Calculating LdapURL for referrence value {}", ref );

            // need to add non-ldap URLs as-is
            if ( ! ref.startsWith( "ldap" ) )
            {
                referral.addLdapUrl( ref );
                continue;
            }
           
            // Parse the ref value  
            LdapURL ldapUrl = new LdapURL();
            try
            {
                ldapUrl.parse( ref.toCharArray() );
            }
            catch ( LdapURLEncodingException e )
            {
                LOG.error( I18n.err( I18n.ERR_165, ref, referralAncestor ) );
            }
           
            // Normalize the DN to check for same dn
            DN urlDn = new DN( ldapUrl.getDn().getName() );
            urlDn.normalize( session.getCoreSession().getDirectoryService().getSchemaManager()
                .getNormalizerMapping() );
           
            if ( urlDn.getNormName().equals( req.getBase().getNormName() ) )
            {
                ldapUrl.setForceScopeRendering( true );
                ldapUrl.setAttributes( req.getAttributes() );
                ldapUrl.setScope( req.getScope().getScope() );
                referral.addLdapUrl( ldapUrl.toString() );
                continue;
            }
           
            /*
             * If we get here then the DN of the referral was not the same as the
             * DN of the ref LDAP URL.  We must calculate the remaining (difference)
             * name past the farthest referral DN which the target name extends.
             */
            int diff = req.getBase().size() - referralAncestor.getDn().size();
            DN extra = new DN();

            // TODO - fix this by access unormalized RDN values
            // seems we have to do this because get returns normalized rdns
            DN reqUnnormalizedDn = new DN( req.getBase().getName() );
            for ( int jj = 0; jj < diff; jj++ )
            {
                extra.add( reqUnnormalizedDn.get( referralAncestor.getDn().size() + jj ) );
            }

            ldapUrl.getDn().addAll( extra );
            ldapUrl.setForceScopeRendering( true );
            ldapUrl.setAttributes( req.getAttributes() );
            ldapUrl.setScope( req.getScope().getScope() );
            referral.addLdapUrl( ldapUrl.toString() );
        }
       
        return referral;
    }
View Full Code Here

                }
                 
                // if we get here then we have a valid referral ancestor
                try
                {
                    InternalReferral referral = getReferralOnAncestorForSearch( session, ( InternalSearchRequest ) req, referralAncestor );
                   
                    result.setResultCode( ResultCodeEnum.REFERRAL );
                    result.setReferral( referral );
                    session.getIoSession().write( req.getResultResponse() );
                }
View Full Code Here

            }
           
            // Add the referrals if necessary
            if ( e instanceof LdapReferralException )
            {
                InternalReferral referrals = new ReferralImpl();
               
                do
                {
                    String ref = ((LdapReferralException)e).getReferralInfo();
                    referrals.addLdapUrl( ref );
                }
                while ( ((LdapReferralException)e).skipReferral() );
               
                result.setReferral( referrals );
            }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.message.internal.InternalReferral

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.