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

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



    @Test
    public void testEqualsDifferentImpls()
    {
        Referral refs0 = new Referral()
        {
            public Collection<String> getLdapUrls()
            {
                return Collections.emptyList();
            }


            public void addLdapUrl( String url )
            {
            }


            public void removeLdapUrl( String url )
            {
            }


            public void addLdapUrlBytes( byte[] urlBytes )
            {
            }


            public Collection<byte[]> getLdapUrlsBytes()
            {
                return null;
            }


            public int getReferralLength()
            {
                return 0;
            }


            public void setReferralLength( int referralLength )
            {
            }
        };

        ReferralImpl refs1 = new ReferralImpl();

        assertFalse( "Object.equals() in effect because we did not redefine " + " equals for the new impl above", refs0
            .equals( refs1 ) );
        assertTrue( "Empty Referrals should be equal even if they are different" + " implementation classes", refs1
            .equals( refs0 ) );
    }
View Full Code Here


            Element errorMessageElement = root.addElement( "errorMessage" );
            errorMessageElement.addText( errorMessage );
        }

        // Referrals
        Referral referral = result.getReferral();
        if ( referral != null )
        {
            Collection<String> ldapUrls = referral.getLdapUrls();
            if ( ldapUrls != null )
            {
                for ( String ldapUrl : ldapUrls )
                {
                    Element referalElement = root.addElement( "referal" );
View Full Code Here

        for ( int i = 0; i < ldapUrls.length; i++ )
        {
            ldapUrlsSet.add( Strings.utf8ToString( ldapUrls[i].getBytes() ) );
        }

        Referral referral = searchResultReference.getReferral();

        assertNotNull( referral );

        for ( String ldapUrl : referral.getLdapUrls() )
        {
            if ( ldapUrlsSet.contains( ldapUrl ) )
            {
                ldapUrlsSet.remove( ldapUrl );
            }
View Full Code Here

        for ( int i = 0; i < ldapUrls.length; i++ )
        {
            ldapUrlsSet.add( Strings.utf8ToString( ldapUrls[i].getBytes() ) );
        }

        Referral referral = searchResultReference.getReferral();

        assertNotNull( referral );

        for ( String ldapUrl : referral.getLdapUrls() )
        {
            if ( ldapUrlsSet.contains( ldapUrl ) )
            {
                ldapUrlsSet.remove( ldapUrl );
            }
View Full Code Here

        SearchResultReference searchResultReference = ldapMessageContainer.getMessage();

        assertEquals( 1, searchResultReference.getMessageId() );

        Referral referral = searchResultReference.getReferral();

        assertNotNull( referral );

        for ( String ldapUrl : referral.getLdapUrls() )
        {
            assertEquals( "ldap:///", ldapUrl );
        }

        // Check the encoding
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
                {
                    referral.addLdapUrl( new LdapURL( tlv.getValue().getData() ).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

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

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

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.