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

Examples of org.apache.directory.shared.ldap.message.control.Control


        LOG.debug( "Handling single searchResultDone response: {}", response );
       
        SearchResultDoneCodec searchResult = (SearchResultDoneCodec)response;
       
        // Get the control
        Control control = searchResult.getCurrentControl();
        SyncDoneValueControl syncDoneCtrl = ( SyncDoneValueControl ) control;

        /** the sync cookie sent by the server */
        byte[] syncCookie;

View Full Code Here


    public void handleSearchDone( SearchResultDone searchDone )
    {
        LOG.debug( "///////////////// handleSearchDone //////////////////" );

        Control ctrl = searchDone.getControl( SyncDoneValueControl.CONTROL_OID );
        SyncDoneValueControl syncDoneCtrl = new SyncDoneValueControl();
        try
        {
            syncDoneCtrl = ( SyncDoneValueControl ) syncDoneControlDecoder.decode( ctrl.getValue(), syncDoneCtrl );
            refreshDeletes = syncDoneCtrl.isRefreshDeletes();
        }
        catch ( Exception e )
        {
            LOG.error( "Failed to decode the syncDoneControlCodec", e );
View Full Code Here

        try
        {
            Entry remoteEntry = syncResult.getEntry();

            Control ctrl = syncResult.getControl( SyncStateValueControl.CONTROL_OID );
            SyncStateValueControl syncStateCtrl = new SyncStateValueControl();

            try
            {
                syncStateCtrl = ( SyncStateValueControl ) syncStateControlDecoder.decode( ctrl.getValue(), syncStateCtrl );
            }
            catch ( Exception e )
            {
                LOG.error( "Failed to decode syncStateControl", e );
            }
View Full Code Here

                if ( cc == null )
                {
                    continue;
                }

                Control control = new ControlImpl( cc.getOid() );
                control.setValue( cc.getValue() );
                control.setCritical( cc.isCritical() );

                message.add( control );
            }
        }
    }
View Full Code Here


    @Test
    public void testFailureWithUnsupportedControl() throws Exception
    {
        Control unsupported = new ControlImpl( "1.1.1.1" )
        {
            boolean isCritical = true;
            private static final long serialVersionUID = 1L;


            @SuppressWarnings("unused")
            public String getType()
            {
                return "1.1.1.1";
            }


            public byte[] getValue()
            {
                return new byte[0];
            }


            public void setValue( byte[] value )
            {
            }


            public boolean isCritical()
            {
                return isCritical;
            }


            public void setCritical( boolean isCritical )
            {
                this.isCritical = isCritical;
            }


            public String getOid()
            {
                return "1.1.1.1";
            }
        };
       
        ldapServer.getDirectoryService().setAllowAnonymousAccess( true );
       
        Hashtable<String, Object> env = new Hashtable<String, Object>();

        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapServer.getPort() + "/ou=system" );
        env.put( "java.naming.ldap.version", "3" );
        env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
        env.put( Context.SECURITY_AUTHENTICATION, "simple" );
        env.put( Context.SECURITY_CREDENTIALS, "secret" );
        env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
        InitialLdapContext ctx = new InitialLdapContext( env, null );

        Attributes user = new BasicAttributes( "cn", "Kate Bush", true );
        Attribute oc = new BasicAttribute( "objectClass" );
        oc.add( "top" );
        oc.add( "person" );
        oc.add( "organizationalPerson" );
        oc.add( "inetOrgPerson" );
        user.put( oc );
        user.put( "sn", "Bush" );
        user.put( "userPassword", "Aerial" );
        ctx.setRequestControls( JndiUtils.toJndiControls( new Control[]
                {unsupported} ) );

        try
        {
            ctx.createSubcontext( "cn=Kate Bush", user );
            fail();
        }
        catch ( OperationNotSupportedException e )
        {
        }

        unsupported.setCritical( false );
        ctx.setRequestControls( JndiUtils.toJndiControls( new Control[]{unsupported} ) );
       
        DirContext kate = ctx.createSubcontext( "cn=Kate Bush", user );
        assertNotNull( kate );
        assertTrue( ArrayUtils.isEquals( Asn1StringUtils.getBytesUtf8( "Aerial" ), kate.getAttributes( "" ).get(
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.message.control.Control

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.