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

Examples of org.apache.directory.api.ldap.model.entry.DefaultEntry


    public void testNoSearchByNonAdmin() throws Exception
    {
        LdifEntry akarasulu = getUserAddLdif();
       
        getService().getAdminSession().add(
            new DefaultEntry( getService().getSchemaManager(), akarasulu.getEntry() ) );

        try
        {
            Dn userDn = new Dn( getService().getSchemaManager(), "uid=akarasulu,ou=users,ou=system" );
            LdapPrincipal principal = new LdapPrincipal( getService().getSchemaManager(), userDn, AuthenticationLevel.SIMPLE );
View Full Code Here


            return;
        }

        LdifEntry ldifEntry = itr.next();

        contextEntry = new DefaultEntry( schemaManager, ldifEntry.getEntry() );

        if ( suffixDn.equals( contextEntry.getDn() ) )
        {
            addMandatoryOpAt( contextEntry );

            AddOperationContext addContext = new AddOperationContext( null, contextEntry );
            super.add( addContext );
        }
        else
        {
            parser.close();
            throw new LdapException( "The given LDIF file doesn't contain the context entry" );
        }

        while ( itr.hasNext() )
        {
            ldifEntry = itr.next();

            Entry entry = new DefaultEntry( schemaManager, ldifEntry.getEntry() );

            addMandatoryOpAt( entry );

            AddOperationContext addContext = new AddOperationContext( null, entry );
            super.add( addContext );
View Full Code Here

        while ( reader.hasNext() )
        {
            LdifEntry entry = reader.next();
            getLdapServer().getDirectoryService().getAdminSession().add(
                new DefaultEntry( getLdapServer().getDirectoryService().getSchemaManager(), entry.getEntry() ) );
        }

        reader.close();
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Entry get() throws InvalidCursorPositionException
    {
        return new DefaultEntry( schemaManager );
    }
View Full Code Here

    public void testPsearchMove() throws Exception
    {
        LdapNetworkConnection connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
        connection.bind( "uid=admin,ou=system", "secret" );
       
        Entry newOu = new DefaultEntry( "uid=persist, ou=users,ou=system" );
        newOu.add( "objectClass", "inetOrgPerson" );
        newOu.add( "cn", "persist_cn" );
        newOu.add( "sn", "persist_sn" );
       
        connection.add( newOu );
       
        SearchRequest sr = new SearchRequestImpl();
        sr.setBase( new Dn( BASE ) );
        sr.setFilter( "(objectClass=*)" );
        sr.setScope( SearchScope.SUBTREE );
       
        PersistentSearch ps = new PersistentSearchImpl();
        ps.setChangesOnly( true );
        ps.setReturnECs( true );
        ps.setCritical( true );
       
        sr.addControl( ps );
       
        final SearchCursor cursor = connection.search( sr );
       
        final List<Entry> entryList = new ArrayList<Entry>();
       
        Runnable r = new Runnable()
        {
           
            @Override
            public void run()
            {
                try
                {
                    while( cursor.next() )
                    {
                        entryList.add( cursor.getEntry() );
                    }
                }
                catch( Exception e )
                {
                    throw new RuntimeException( e );
                }
            }
        };
       
        new Thread( r ).start();
       
        connection.move( newOu.getDn(), newOu.getDn().getParent().getParent() );
        Thread.sleep( 1000 );
        assertFalse( entryList.isEmpty() );
        assertEquals( 1, entryList.size() );
        assertEquals( "uid=persist,ou=system", entryList.get( 0 ).getDn().getName() );
       
View Full Code Here

    public void testCsnLessEqualitySearch() throws Exception
    {
        LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );

        Dn dn = new Dn( "cn=testLowerCsnAdd,ou=system" );
        Entry entry = new DefaultEntry( dn );
        entry.add( "objectClass", SchemaConstants.PERSON_OC );
        entry.add( "cn", "testLowerCsnAdd_cn" );
        entry.add( "sn", "testLowerCsnAdd_sn" );

        connection.add( entry );

        // add an entry to have a entry with higher CSN value
        Dn dn2 = new Dn( "cn=testHigherCsnAdd,ou=system" );
        Entry entry2 = new DefaultEntry( dn2,
            "objectClass :person",
            "cn: testHigherCsnAdd_cn",
            "sn: testHigherCsnAdd_sn" );

        connection.add( entry2 );

        entry = connection.lookup( dn.getName(), "+" );
        entry2 = connection.lookup( dn2.getName(), "+" );

        String lowerCsn = entry.get( "entryCsn" ).getString();
        String higherCsn = entry2.get( "entryCsn" ).getString();

        // usecases
        // 1.1 Less than or Equal ( with the lower csn value)
        testUseCases( lowerCsn, new String[]
            { lowerCsn }, connection, 1 );
View Full Code Here

     * Test for method DefaultEntry()
     */
    @Test
    public void testDefaultClientEntry() throws Exception
    {
        Entry entry = new DefaultEntry();
        assertNotNull( entry );
        assertEquals( Dn.EMPTY_DN, entry.getDn() );
        assertEquals( 0, entry.size() );
    }
View Full Code Here

     * Test for method DefaultEntry( registries )
     */
    @Test
    public void testDefaultClientEntryRegistries() throws Exception
    {
        Entry entry = new DefaultEntry( schemaManager );
        assertNotNull( entry );
        assertEquals( Dn.EMPTY_DN, entry.getDn() );
        assertEquals( 0, entry.size() );
    }
View Full Code Here

     * Test for method DefaultEntry( registries, Dn )
     */
    @Test
    public void testDefaultClientEntryRegistriesDN() throws Exception
    {
        Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
        assertNotNull( entry );
        assertEquals( EXAMPLE_DN, entry.getDn() );
        assertEquals( 0, entry.size() );
    }
View Full Code Here

     * Test for method add( EntryAttribute...)
     */
    @Test
    public void testAddEntryAttribute() throws Exception
    {
        Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );

        Attribute oc = new DefaultAttribute( atObjectClass, "top", "person" );
        Attribute cn = new DefaultAttribute( atCN, "test1", "test2" );
        Attribute sn = new DefaultAttribute( atSN, "Test1", "Test2" );
        Attribute up = new DefaultAttribute( atPwd, BYTES1, BYTES2 );
        Attribute email = new DefaultAttribute( atEMail, "FR", "US" );

        entry.add( oc, cn, sn, email );

        assertEquals( 4, entry.size() );
        assertTrue( entry.containsAttribute( "ObjectClass" ) );
        assertTrue( entry.containsAttribute( "CN" ) );
        assertTrue( entry.containsAttribute( "  sn  " ) );
        assertTrue( entry.containsAttribute( " email  " ) );

        Attribute attr = entry.get( "objectclass" );
        assertEquals( 2, attr.size() );

        Attribute email2 = new DefaultAttribute( atEMail, "UK", "DE" );
        entry.add( email2, up );
        assertEquals( 5, entry.size() );

        assertTrue( entry.containsAttribute( "userPassword" ) );
        assertTrue( entry.containsAttribute( " email " ) );

        Attribute attrC = entry.get( "email" );
        assertEquals( 4, attrC.size() );

        entry.clear();
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.entry.DefaultEntry

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.