Examples of ReferralImpl


Examples of org.apache.directory.shared.ldap.message.ReferralImpl

        if ( ( ref != null ) && ! hasManageDsaItControl )
        {
            // The entry is a referral.
            InternalSearchResponseReference respRef;
            respRef = new SearchResponseReferenceImpl( req.getMessageId() );
            respRef.setReferral( new ReferralImpl() );
           
            for ( Value<?> val : ref )
            {
                String url = val.getString();
               
View Full Code Here

Examples of org.apache.directory.shared.ldap.message.ReferralImpl

     */
    private void handleReferralEntryForSearch( LdapSession session, InternalSearchRequest req, ClonedServerEntry entry )
        throws Exception
    {
        InternalLdapResult result = req.getResultResponse().getLdapResult();
        ReferralImpl referral = new ReferralImpl();
        result.setReferral( referral );
        result.setResultCode( ResultCodeEnum.REFERRAL );
        result.setErrorMessage( "Encountered referral attempting to handle request." );
        result.setMatchedDn( req.getBase() );

        EntryAttribute refAttr = entry.getOriginalEntry().get( SchemaConstants.REF_AT );
       
        for ( Value<?> refval : refAttr )
        {
            String refstr = refval.getString();
           
            // need to add non-ldap URLs as-is
            if ( ! refstr.startsWith( "ldap" ) )
            {
                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

Examples of org.apache.directory.shared.ldap.message.ReferralImpl

            }
           
            // 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

Examples of org.apache.directory.shared.ldap.message.ReferralImpl

    {
        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

Examples of org.apache.directory.shared.ldap.model.message.ReferralImpl

        if ( responseValue == null )
        {
            this.responseValue = null;
            getDecorated().setDelay( 0 );
            getDecorated().setTimeOffline( 0 );
            getDecorated().getLdapResult().setReferral( new ReferralImpl() );
            return;
        }
       
        ByteBuffer bb = ByteBuffer.wrap( responseValue );
        GracefulDisconnectContainer container = new GracefulDisconnectContainer();
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.ReferralImpl

                    }

                    Message response = container.getMessage();
                    LdapResult ldapResult = ( ( ResultResponse ) response ).getLdapResult();

                    Referral referral = new ReferralImpl();

                    ldapResult.setReferral( referral );
                }
            } );
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.ReferralImpl

        }

        ResultResponse response = ( ResultResponse ) container.getMessage();
        LdapResult ldapResult = response.getLdapResult();

        Referral referral = new ReferralImpl();
        ldapResult.setReferral( referral );

        if ( IS_DEBUG )
        {
            LOG.debug( "Initialising a referrals list" );
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.ReferralImpl

        // Get the referral, or create it if not existing
        Referral referral = searchResultReference.getReferral();

        if ( referral == null )
        {
            referral = new ReferralImpl();
            searchResultReference.setReferral( referral );
        }

        // We have to handle the special case of a 0 length list of referrals
        LdapURL url = LdapURL.EMPTY_URL;
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.ReferralImpl

        if ( ( ref != null ) && !hasManageDsaItControl )
        {
            // The entry is a referral.
            SearchResultReference respRef;
            respRef = new SearchResultReferenceImpl( req.getMessageId() );
            respRef.setReferral( new ReferralImpl() );

            for ( Value<?> val : ref )
            {
                String url = val.getString();
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.ReferralImpl

     */
    private void handleReferralEntryForSearch( LdapSession session, SearchRequest req, Entry entry )
        throws Exception
    {
        LdapResult result = req.getResultResponse().getLdapResult();
        ReferralImpl referral = new ReferralImpl();
        result.setReferral( referral );
        result.setResultCode( ResultCodeEnum.REFERRAL );
        result.setDiagnosticMessage( "Encountered referral attempting to handle request." );
        result.setMatchedDn( req.getBase() );

        Attribute refAttr = ((ClonedServerEntry)entry).getOriginalEntry().get( SchemaConstants.REF_AT );

        for ( Value<?> refval : refAttr )
        {
            String refstr = refval.getString();

            // need to add non-ldap URLs as-is
            if ( !refstr.startsWith( "ldap" ) )
            {
                referral.addLdapUrl( refstr );
                continue;
            }

            // parse the ref value and normalize the Dn
            LdapUrl ldapUrl = null;
           
            try
            {
                ldapUrl = new LdapUrl( refstr );
            }
            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
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.