Package org.apache.directory.server.core.entry

Examples of org.apache.directory.server.core.entry.DefaultServerEntry


        modifier.setMaxBaseDistance( 3 );
        modifier.setBase( new DN( "ou=users" ) );
        SubtreeSpecification ss = modifier.getSubtreeSpecification();
        DN apDn = new DN( "ou=system" );
        DN entryDn = new DN( "ou=users,ou=system" );
        ServerEntry entry = new DefaultServerEntry( schemaManager, entryDn, "objectClass" );

        assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );

        entryDn = new DN( "uid=akarasulu,ou=users,ou=system" );
        assertTrue( evaluator.evaluate( ss, apDn, entryDn, entry ) );
View Full Code Here


    @Test public void testSerializeServerEntryWithNoAttributes() throws Exception
    {
        DN dn = new DN( "" );
        dn.normalize( oids );
       
        ServerEntry entry = new DefaultServerEntry( schemaManager, dn );

        ServerEntrySerializer ses = new ServerEntrySerializer( schemaManager );
       
        byte[] data = ses.serialize( entry );
       
View Full Code Here

        modifier.setMaxBaseDistance( 3 );
        modifier.setBase( new DN( "ou=users" ) );
        SubtreeSpecification ss = modifier.getSubtreeSpecification();
        DN apDn = new DN( "ou=system" );
        DN entryDn = new DN( "ou=users,ou=system" );
        ServerEntry entry = new DefaultServerEntry( schemaManager, entryDn, "objectClass" );

        assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );

        entryDn = new DN( "uid=akarasulu,ou=users,ou=system" );
        assertTrue( evaluator.evaluate( ss, apDn, entryDn, entry ) );
View Full Code Here

    @Test public void testSerializeServerEntryWithAttributeNoValue() throws Exception
    {
        DN dn = new DN( "" );
        dn.normalize( oids );
       
        ServerEntry entry = new DefaultServerEntry( schemaManager, dn );

        ServerEntrySerializer ses = new ServerEntrySerializer( schemaManager );
        EntryAttribute oc = new DefaultServerAttribute( "ObjectClass", schemaManager.lookupAttributeTypeRegistry( "objectclass" ) );
        entry.add( oc );
       
        byte[] data = ses.serialize( entry );
       
        ServerEntry result = (ServerEntry)ses.deserialize( data );
       
View Full Code Here

        modifier.setMaxBaseDistance( 3 );
        modifier.setBase( new DN( "ou=users" ) );
        SubtreeSpecification ss = modifier.getSubtreeSpecification();
        DN apDn = new DN( "ou=system" );
        DN entryDn = new DN( "ou=users,ou=system" );
        ServerEntry entry = new DefaultServerEntry( schemaManager, entryDn );
        entry.put( "objectClass", "person" );

        assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );

        entryDn = new DN( "uid=akarasulu,ou=users,ou=system" );
        assertTrue( evaluator.evaluate( ss, apDn, entryDn, entry ) );

        entryDn = new DN( "ou=system" );
        assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );

        entryDn = new DN( "ou=twolevels,uid=akarasulu,ou=users,ou=system" );
        assertTrue( evaluator.evaluate( ss, apDn, entryDn, entry ) );

        entryDn = new DN( "ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
        assertTrue( evaluator.evaluate( ss, apDn, entryDn, entry ) );

        entryDn = new DN( "ou=fourlevels,ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
        assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );

        // now change the refinement so the entry is rejected
        entry = new DefaultServerEntry( schemaManager, entryDn );
        entry.put( "objectClass", "organizationalUnit" );
       

        assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );

        entryDn = new DN( "uid=akarasulu,ou=users,ou=system" );
View Full Code Here

    @Test public void testSerializeServerEntryWithAttributeStringValue() throws Exception
    {
        DN dn = new DN( "" );
        dn.normalize( oids );
       
        ServerEntry entry = new DefaultServerEntry( schemaManager, dn );

        ServerEntrySerializer ses = new ServerEntrySerializer( schemaManager );
        entry.add( "ObjectClass", "top", "person" );
       
        byte[] data = ses.serialize( entry );
       
        ServerEntry result = (ServerEntry)ses.deserialize( data );
       
View Full Code Here

    @Test public void testSerializeServerEntryWithAttributeBinaryValue() throws Exception
    {
        DN dn = new DN( "" );
        dn.normalize( oids );
       
        ServerEntry entry = new DefaultServerEntry( schemaManager, dn );

        ServerEntrySerializer ses = new ServerEntrySerializer( schemaManager );
        entry.add( "userPassword", StringTools.getBytesUtf8( "secret" ) );
       
        byte[] data = ses.serialize( entry );
       
        ServerEntry result = (ServerEntry)ses.deserialize( data );
       
View Full Code Here

        modifier.setBase( new DN( "ou=users" ) );
        SubtreeSpecification ss = modifier.getSubtreeSpecification();
        DN apDn = new DN( "ou=system" );
        DN entryDn = new DN( "ou=users,ou=system" );

        ServerEntry entry = new DefaultServerEntry( schemaManager, entryDn );;
        entry.put( "objectClass", "person" );
        entry.put( "cn", "Ersin" );

        assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );

        entryDn = new DN( "cn=Ersin,ou=users,ou=system" );
        assertTrue( evaluator.evaluate( ss, apDn, entryDn, entry ) );

        // now change the filter so the entry is rejected
        entry = new DefaultServerEntry( schemaManager, entryDn );;
        entry.put( "objectClass", "person" );
        entry.put( "cn", "Alex" );

        assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );

        entryDn = new DN( "cn=Alex,ou=users,ou=system" );
        assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );
View Full Code Here

    @Test
    public void testPreventStructuralClassRemovalOnModifyReplace() throws Exception
    {
        DN name = new DN( "uid=akarasulu,ou=users,dc=example,dc=com" );
        ModificationOperation mod = ModificationOperation.REPLACE_ATTRIBUTE;
        ServerEntry modifyAttributes = new DefaultServerEntry( schemaManager );
        AttributeType atCN = schemaManager.lookupAttributeTypeRegistry( "cn" );
        modifyAttributes.put( new DefaultServerAttribute( atCN ) );

        // this should pass
        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( schemaManager.getObjectClassRegistry(), name, mod, modifyAttributes );

        // this should succeed since person is still in replaced set and is structural
        modifyAttributes.removeAttributes( atCN );
        AttributeType atOC = schemaManager.lookupAttributeTypeRegistry( "objectClass" );
        EntryAttribute objectClassesReplaced = new DefaultServerAttribute( atOC );
        objectClassesReplaced.add( "top" );
        objectClassesReplaced.add( "person" );
        modifyAttributes.put( objectClassesReplaced );
        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( schemaManager.getObjectClassRegistry(), name, mod, modifyAttributes );

        // this should fail since only top is left
        objectClassesReplaced = new DefaultServerAttribute( atOC );
        objectClassesReplaced.add( "top" );
        modifyAttributes.put( objectClassesReplaced );
        try
        {
            SchemaChecker.preventStructuralClassRemovalOnModifyReplace( schemaManager.getObjectClassRegistry(), name, mod, modifyAttributes );
            fail( "should never get here due to an LdapSchemaViolationException" );
        }
        catch ( LdapSchemaViolationException e )
        {
            assertEquals( e.getResultCode(), ResultCodeEnum.OBJECT_CLASS_MODS_PROHIBITED );
        }

        // this should fail since the modify operation tries to delete all
        // objectClass attribute values
        modifyAttributes.removeAttributes( "cn" );
        objectClassesReplaced = new DefaultServerAttribute( atOC );
        modifyAttributes.put( objectClassesReplaced );
        try
        {
            SchemaChecker.preventStructuralClassRemovalOnModifyReplace( schemaManager.getObjectClassRegistry(), name, mod, modifyAttributes );
            fail( "should never get here due to an LdapSchemaViolationException" );
        }
View Full Code Here

    @Test
    public void testPreventRdnChangeOnModifyRemove() throws Exception
    {
        ModificationOperation mod = ModificationOperation.REMOVE_ATTRIBUTE;
        DN name = new DN( "ou=user,dc=example,dc=com" );
        ServerEntry attributes = new DefaultServerEntry( schemaManager, name );
        attributes.put( "cn", "does not matter" );

        // postive test which should pass
        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, schemaManager );

        // test should fail since we are removing the ou attribute
        AttributeType OU_AT = schemaManager.lookupAttributeTypeRegistry( "ou" );
        attributes.put( new DefaultServerAttribute( "ou", OU_AT ) );

        try
        {
            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, schemaManager );
            fail( "should never get here due to a LdapSchemaViolationException being thrown" );
        }
        catch ( LdapSchemaViolationException e )
        {
            assertEquals( ResultCodeEnum.NOT_ALLOWED_ON_RDN, e.getResultCode() );
        }

        // test success using more than one attribute for the Rdn but not modifying rdn attribute
        name = new DN( "ou=users+cn=system users,dc=example,dc=com" );
        attributes = new DefaultServerEntry( schemaManager, name );
        attributes.put( "sn", "does not matter" );
        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, schemaManager );

        // test for failure when modifying Rdn attribute in multi attribute Rdn
        AttributeType CN_AT = schemaManager.lookupAttributeTypeRegistry( "cn" );
        attributes.put( new DefaultServerAttribute( "cn", CN_AT ) );
       
        try
        {
            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, schemaManager );
            fail( "should never get here due to a LdapSchemaViolationException being thrown" );
        }
        catch ( LdapSchemaViolationException e )
        {
            assertEquals( ResultCodeEnum.NOT_ALLOWED_ON_RDN, e.getResultCode() );
        }

        // should succeed since the value being deleted from the rdn attribute is
        // is not used when composing the Rdn
        attributes = new DefaultServerEntry( schemaManager, name );
        attributes.put( "ou", "container" );
        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, schemaManager );

        // now let's make it fail again just by providing the right value for ou (users)
        attributes = new DefaultServerEntry( schemaManager, name );
        attributes.put( "ou", "users" );
        try
        {
            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, schemaManager );
            fail( "should never get here due to a LdapSchemaViolationException being thrown" );
        }
View Full Code Here

TOP

Related Classes of org.apache.directory.server.core.entry.DefaultServerEntry

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.