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

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


            }

            // Add the referrals if necessary
            if ( e instanceof LdapReferralException )
            {
                Referral referrals = new ReferralImpl();

                do
                {
                    String ref = ( (LdapReferralException) e ).getReferralInfo();
                    referrals.addLdapUrl( ref );
                }
                while ( ( ( LdapReferralException ) e ).skipReferral() );

                result.setReferral( referrals );
            }
View Full Code Here


        assertEquals( 1, addResponse.getMessageId() );
        assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode() );
        assertEquals( "", addResponse.getLdapResult().getMatchedDn().getName() );
        assertEquals( "", addResponse.getLdapResult().getDiagnosticMessage() );

        Referral referral = addResponse.getLdapResult().getReferral();

        assertNotNull( referral );
        assertEquals( 1, referral.getLdapUrls().size() );
        Collection<String> ldapUrls = referral.getLdapUrls();

        assertTrue( ldapUrls.contains( "ldap:///" ) );

        try
        {
View Full Code Here

        assertEquals( 1, addResponse.getMessageId() );
        assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode() );
        assertEquals( "", addResponse.getLdapResult().getMatchedDn().getName() );
        assertEquals( "", addResponse.getLdapResult().getDiagnosticMessage() );

        Referral referral = addResponse.getLdapResult().getReferral();

        assertNotNull( referral );

        assertEquals( 2, referral.getLdapUrls().size() );

        Collection<String> ldapUrls = referral.getLdapUrls();

        for ( String ldapUrl : ldapUrls )
        {
            assertEquals( "ldap:///", ldapUrl );
        }
View Full Code Here

        assertEquals( 1, addResponse.getMessageId() );
        assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode() );
        assertEquals( "", addResponse.getLdapResult().getMatchedDn().getName() );
        assertEquals( "", addResponse.getLdapResult().getDiagnosticMessage() );

        Referral referral = addResponse.getLdapResult().getReferral();

        assertNotNull( referral );

        assertEquals( 2, referral.getLdapUrls().size() );

        Collection<String> ldapUrls = referral.getLdapUrls();

        String[] expected = new String[]
            { "ldap:///", "" };
        int i = 0;
View Full Code Here

        // The error message
        BerValue.encode( buffer, getErrorMessageBytes() );

        // The referrals, if any
        Referral referral = getReferral();

        if ( referral != null )
        {
            LdapEncoder.encodeReferral( buffer, referral );
        }
View Full Code Here

    public int computeLength()
    {
        int searchResultReferenceLength = 0;

        // We may have more than one reference.
        Referral referral = getReferral();

        int referralLength = LdapEncoder.computeReferralLength( referral );

        if ( referralLength != 0 )
        {
View Full Code Here

            // The SearchResultReference Tag
            buffer.put( LdapConstants.SEARCH_RESULT_REFERENCE_TAG );
            buffer.put( TLV.getBytes( getSearchResultReferenceLength() ) );

            // The referrals, if any
            Referral referral = searchResultReference.getReferral();

            if ( referral != null )
            {
                // Each referral
                for ( byte[] ldapUrlBytes : referral.getLdapUrlsBytes() )
                {
                    // Encode the current referral
                    BerValue.encode( buffer, ldapUrlBytes );
                }
            }
View Full Code Here

        }

        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

        // Get the Value and store it in the BindRequest
        TLV tlv = container.getCurrentTLV();

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

        if ( tlv.getLength() == 0 )
        {
            referral.addLdapUrl( "" );
        }
        else
        {
            String urlStr = Strings.utf8ToString( tlv.getValue().getData() );

            try
            {
                url = new LdapUrl( urlStr );
                referral.addLdapUrl( urlStr );
            }
            catch ( LdapURLEncodingException luee )
            {
                LOG.error( I18n.err( I18n.ERR_04021, urlStr, luee.getMessage() ) );
                throw new DecoderException( I18n.err( I18n.ERR_04016, luee.getMessage() ) );
View Full Code Here

    {
        TLV tlv = container.getCurrentTLV();

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

        if ( tlv.getLength() == 0 )
        {
            referral.addLdapUrl( "" );
        }
        else
        {
            if ( ldapResult.getResultCode() == ResultCodeEnum.REFERRAL )
            {
                try
                {
                    String url = Strings.utf8ToString( tlv.getValue().getData() );
                    referral.addLdapUrl( new LdapUrl( url ).toString() );
                }
                catch ( LdapURLEncodingException luee )
                {
                    String badUrl = Strings.utf8ToString( tlv.getValue().getData() );
                    LOG.error( I18n.err( I18n.ERR_04015, badUrl, luee.getMessage() ) );
                    throw new DecoderException( I18n.err( I18n.ERR_04016, luee.getMessage() ) );
                }
            }
            else
            {
                LOG.warn( "The Referral error message is not allowed when havind an error code no equals to REFERRAL" );
                referral.addLdapUrl( LdapUrl.EMPTY_URL.toString() );
            }
        }

        if ( IS_DEBUG )
        {
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.message.Referral

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.