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

Examples of org.apache.directory.api.ldap.model.message.AddRequest


    @Test
    public void testOnReferralWithManageDsaITControl() throws Exception
    {
        LdapConnection conn = getWiredConnection( getLdapServer() );

        AddRequest addRequest = new AddRequestImpl();
        ManageDsaIT manageDSAIT = new ManageDsaITImpl();
        manageDSAIT.setCritical( true );
        addRequest.addControl( manageDSAIT );

        // add success
        Entry entry = new DefaultEntry( "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system",
            "objectClass", "organizationalUnit",
            "ou", "UnderReferral" );

        addRequest.setEntry( entry );

        AddResponse addResponse = conn.add( addRequest );
        assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode() );

        assertNull( conn.lookup( "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system", new Control[]
View Full Code Here


    {
        LOG.debug( "" );

        LdapConnection conn = getWiredConnection( getLdapServer() );

        AddRequest addRequest = new AddRequestImpl();

        // referrals failure
        Entry entry = new DefaultEntry(
            "ou=UnderReferral,ou=Computers,uid=akarasuluref,ou=users,ou=system",
            "objectClass", "organizationalUnit",
            "ou", "UnderReferral" );
        addRequest.setEntry( entry );

        AddResponse addResponse = conn.add( addRequest );

        assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode() );
View Full Code Here

    @Test
    public void testOnReferral() throws Exception
    {
        LdapConnection conn = getWiredConnection( getLdapServer() );

        AddRequest addRequest = new AddRequestImpl();
        ManageDsaIT manageDSAIT = new ManageDsaITImpl();
        manageDSAIT.setCritical( true );
        //addRequest.addControl( manageDSAIT );

        // referrals failure
        Entry entry = new DefaultEntry(
            "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system",
            "objectClass", "organizationalUnit",
            "ou", "UnderReferral" );

        addRequest.setEntry( entry );

        AddResponse addResponse = conn.add( addRequest );

        assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode() );
View Full Code Here

            String msg = "Cannot add an empty entry";
            LOG.debug( msg );
            throw new IllegalArgumentException( msg );
        }

        AddRequest addRequest = new AddRequestImpl();
        addRequest.setEntry( entry );
        addRequest.setEntryDn( entry.getDn() );

        AddResponse addResponse = add( addRequest );

        processResponse( addResponse );
    }
View Full Code Here

            "ObjectClass : person",
            "cn: testadd_sn",
            "sn: testadd_sn"
            );

        AddRequest addRequest = new AddRequestImpl();
        addRequest.setEntry( entry );
        addRequest.addControl( new ManageDsaITImpl() );

        AddResponse response = connection.add( addRequest );

        assertNotNull( response );
        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
View Full Code Here

        entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC );
        entry.add( SchemaConstants.CN_AT, "testAsyncAdd_cn" );
        entry.add( SchemaConstants.SN_AT, "testAsyncAdd_sn" );

        assertFalse( session.exists( dn ) );
        AddRequest addRequest = new AddRequestImpl();
        addRequest.setEntry( entry );

        AddFuture addFuture = connection.addAsync( addRequest );

        AddResponse addResponse = addFuture.get( 1000, TimeUnit.MILLISECONDS );
View Full Code Here

            "ObjectClass: person",
            "cn: testAsyncAdd_cn",
            "sn: testAsyncAdd_sn" );

        assertFalse( session.exists( "cn=testAsyncAdd,ou=system" ) );
        AddRequest addRequest = new AddRequestImpl();
        addRequest.setEntry( entry );

        AddFuture addFuture = connection.addAsync( addRequest );

        AddResponse addResponse = addFuture.get( 1000, TimeUnit.MILLISECONDS );
View Full Code Here

        entry.add( SchemaConstants.OBJECT_CLASS_AT, "person" );
        entry.add( SchemaConstants.OBJECT_CLASS_AT, "OrganizationalPerson" );
        entry.add( SchemaConstants.CN_AT, value );
        entry.add( SchemaConstants.SN_AT, value );

        AddRequest addRequest = new AddRequestImpl();
        addRequest.setEntry( entry );
        addRequest.setEntryDn( dn );

        AddResponse resp = getAdminConnection( getService() ).add( addRequest );

        return resp;
    }
View Full Code Here

            "objectClass: subentry",
            "objectClass: accessControlSubentry",
            "subtreeSpecification", subtree,
            "prescriptiveACI", aciItem );

        AddRequest addRequest = new AddRequestImpl();
        addRequest.setEntry( subEntry );
        AddResponse addResponse = connection.add( addRequest );

        return addResponse.getLdapResult().getResultCode();
    }
View Full Code Here

        {
            de.printStackTrace();
            fail( de.getMessage() );
        }

        AddRequest addRequest = container.getMessage();

        // Check the decoded message
        assertEquals( 1, addRequest.getMessageId() );
        assertEquals( "cn=testModify,ou=users,ou=system", addRequest.getEntryDn().toString() );

        Entry entry = addRequest.getEntry();

        assertEquals( 2, entry.size() );

        Set<String> expectedTypes = new HashSet<String>();

        expectedTypes.add( "l" );
        expectedTypes.add( "attrs" );

        Map<String, Set<String>> typesVals = new HashMap<String, Set<String>>();

        Set<String> lVal1 = new HashSet<String>();
        lVal1.add( "Paris" );
        typesVals.put( "l", lVal1 );

        Set<String> lVal2 = new HashSet<String>();
        lVal2.add( "test1" );
        lVal2.add( "test2" );
        lVal2.add( "test3" );
        typesVals.put( "attrs", lVal2 );

        Attribute attribute = entry.get( "l" );

        assertTrue( expectedTypes.contains( Strings.toLowerCase( attribute.getId() ) ) );

        Set<String> vals = ( Set<String> ) typesVals.get( Strings.toLowerCase( attribute.getId() ) );

        for ( Value<?> value : attribute )
        {
            assertTrue( vals.contains( value.getValue() ) );

            vals.remove( value.getValue() );
        }

        attribute = entry.get( "attrs" );

        assertTrue( expectedTypes.contains( Strings.toLowerCase( attribute.getId() ) ) );

        vals = ( Set<String> ) typesVals.get( Strings.toLowerCase( attribute.getId() ) );

        for ( Value<?> value : attribute )
        {
            assertTrue( vals.contains( value.getValue() ) );

            vals.remove( value.getValue() );
        }

        // Check the encoding
        try
        {
            ByteBuffer bb = encoder.encodeMessage( addRequest );

            // Check the length
            assertEquals( 0x59, bb.limit() );

            // We cannot compare the PDU, as the attributes order is not
            // kept. Let's decode again and compare the resulting AddRequest
            try
            {
                ldapDecoder.decode( bb, container );
            }
            catch ( DecoderException de )
            {
                de.printStackTrace();
                fail( de.getMessage() );
            }

            AddRequest addRequest2 = container.getMessage();
            assertEquals( addRequest, addRequest2 );
        }
        catch ( EncoderException ee )
        {
            ee.printStackTrace();
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.message.AddRequest

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.