Package org.apache.ldap.common.message

Examples of org.apache.ldap.common.message.LockableAttributeImpl


    }


    public void addAdministrativeRole( String role ) throws NamingException
    {
        Attribute attribute = new LockableAttributeImpl( "administrativeRole" );
        attribute.add( role );
        ModificationItem item = new ModificationItem( DirContext.ADD_ATTRIBUTE, attribute );
        super.sysRoot.modifyAttributes( "", new ModificationItem[] { item } );
    }
View Full Code Here


        // now modify entries included by the subentry to have collectiveExclusions
        // -------------------------------------------------------------------

        ModificationItem[] items = new ModificationItem[] {
            new ModificationItem( DirContext.ADD_ATTRIBUTE,
                    new LockableAttributeImpl( "collectiveExclusions", "c-ou" ) ) };
        super.sysRoot.modifyAttributes( "ou=services,ou=configuration", items );

        // entry should not show the c-ou collective attribute anymore
        attributes = super.sysRoot.getAttributes( "ou=services,ou=configuration" );
        c_ou = attributes.get( "c-ou" );
        if ( c_ou != null )
        {
            assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() );
        }

        // now add more collective subentries - the c-ou should still not show due to exclusions
        super.sysRoot.createSubcontext( "cn=testsubentry2", getTestSubentry2() );

        attributes = super.sysRoot.getAttributes( "ou=services,ou=configuration" );
        c_ou = attributes.get( "c-ou" );
        if ( c_ou != null )
        {
            assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() );
        }

        // entries without the collectiveExclusion should still show both values of c-ou
        attributes = super.sysRoot.getAttributes( "ou=interceptors,ou=configuration" );
        c_ou = attributes.get( "c-ou" );
        assertNotNull( "a collective c-ou attribute should be present", c_ou );
        assertTrue( c_ou.contains( "configuration" ) );
        assertTrue( c_ou.contains( "configuration2" ) );

        // -------------------------------------------------------------------
        // now add the subentry for the c-st collective attribute
        // -------------------------------------------------------------------

        super.sysRoot.createSubcontext( "cn=testsubentry3", getTestSubentry3() );

        // the new attribute c-st should appear in the node with the c-ou exclusion
        attributes = super.sysRoot.getAttributes( "ou=services,ou=configuration" );
        Attribute c_st = attributes.get( "c-st" );
        assertNotNull( "a collective c-st attribute should be present", c_st );
        assertTrue( c_st.contains( "FL" ) );

        // in node without exclusions both values of c-ou should appear with c-st value
        attributes = super.sysRoot.getAttributes( "ou=interceptors,ou=configuration" );
        c_ou = attributes.get( "c-ou" );
        assertNotNull( "a collective c-ou attribute should be present", c_ou );
        assertTrue( c_ou.contains( "configuration" ) );
        assertTrue( c_ou.contains( "configuration2" ) );
        c_st = attributes.get( "c-st" );
        assertNotNull( "a collective c-st attribute should be present", c_st );
        assertTrue( c_st.contains( "FL" ) );

        // -------------------------------------------------------------------
        // now modify an entry to exclude all collective attributes
        // -------------------------------------------------------------------

        items = new ModificationItem[] {
            new ModificationItem( DirContext.REPLACE_ATTRIBUTE,
                    new LockableAttributeImpl( "collectiveExclusions", "excludeAllCollectiveAttributes" ) ) };
        super.sysRoot.modifyAttributes( "ou=interceptors,ou=configuration", items );

        // none of the attributes should appear any longer
        attributes = super.sysRoot.getAttributes( "ou=interceptors,ou=configuration" );
        c_ou = attributes.get( "c-ou" );
View Full Code Here

        // now modify entries included by the subentry to have collectiveExclusions
        // -------------------------------------------------------------------

        ModificationItem[] items = new ModificationItem[] {
            new ModificationItem( DirContext.ADD_ATTRIBUTE,
                    new LockableAttributeImpl( "collectiveExclusions", "c-ou" ) ) };
        super.sysRoot.modifyAttributes( "ou=services,ou=configuration", items );
        entries = getAllEntries();

        // entry should not show the c-ou collective attribute anymore
        attributes = ( Attributes ) entries.get( "ou=services,ou=configuration,ou=system" );
        c_ou = attributes.get( "c-ou" );
        if ( c_ou != null )
        {
            assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() );
        }

        // now add more collective subentries - the c-ou should still not show due to exclusions
        super.sysRoot.createSubcontext( "cn=testsubentry2", getTestSubentry2() );
        entries = getAllEntries();

        attributes = ( Attributes ) entries.get( "ou=services,ou=configuration,ou=system" );
        c_ou = attributes.get( "c-ou" );
        if ( c_ou != null )
        {
            assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() );
        }

        // entries without the collectiveExclusion should still show both values of c-ou
        attributes = ( Attributes ) entries.get( "ou=interceptors,ou=configuration,ou=system" );
        c_ou = attributes.get( "c-ou" );
        assertNotNull( "a collective c-ou attribute should be present", c_ou );
        assertTrue( c_ou.contains( "configuration" ) );
        assertTrue( c_ou.contains( "configuration2" ) );

        // -------------------------------------------------------------------
        // now add the subentry for the c-st collective attribute
        // -------------------------------------------------------------------

        super.sysRoot.createSubcontext( "cn=testsubentry3", getTestSubentry3() );
        entries = getAllEntries();

        // the new attribute c-st should appear in the node with the c-ou exclusion
        attributes = ( Attributes ) entries.get( "ou=services,ou=configuration,ou=system" );
        Attribute c_st = attributes.get( "c-st" );
        assertNotNull( "a collective c-st attribute should be present", c_st );
        assertTrue( c_st.contains( "FL" ) );

        // in node without exclusions both values of c-ou should appear with c-st value
        attributes = ( Attributes ) entries.get( "ou=interceptors,ou=configuration,ou=system" );
        c_ou = attributes.get( "c-ou" );
        assertNotNull( "a collective c-ou attribute should be present", c_ou );
        assertTrue( c_ou.contains( "configuration" ) );
        assertTrue( c_ou.contains( "configuration2" ) );
        c_st = attributes.get( "c-st" );
        assertNotNull( "a collective c-st attribute should be present", c_st );
        assertTrue( c_st.contains( "FL" ) );

        // -------------------------------------------------------------------
        // now modify an entry to exclude all collective attributes
        // -------------------------------------------------------------------

        items = new ModificationItem[] {
            new ModificationItem( DirContext.REPLACE_ATTRIBUTE,
                    new LockableAttributeImpl( "collectiveExclusions", "excludeAllCollectiveAttributes" ) ) };
        super.sysRoot.modifyAttributes( "ou=interceptors,ou=configuration", items );
        entries = getAllEntries();

        // none of the attributes should appear any longer
        attributes = ( Attributes ) entries.get( "ou=interceptors,ou=configuration,ou=system" );
View Full Code Here

        {
            String attrKey = ( String ) list.nextElement();

            if ( attrKey.startsWith( keyBase ) )
            {
                LockableAttributeImpl attr = new LockableAttributeImpl( attrs, attrKey.substring( keyBase.length() ) ) ;

                String valueList = ( String ) env.get( attrKey );

                if ( valueList == null || valueList.trim().length() == 0 )
                {
                    // add the empty attribute
                    attrs.put( attr );

                    continue;
                }

                valueList = StringTools.deepTrim( valueList );

                String[] values = valueList.split( " " );

                for ( int ii = 0; ii < values.length; ii++ )
                {
                    attr.add( values[ii] );
                }

                attrs.put( attr );
            }
        }
View Full Code Here

        s_singleton = this;
        this.system = system;

        // setup that root DSE
        this.rootDSE = rootDSE;
        Attribute attr = new LockableAttributeImpl( "subschemaSubentry" );
        attr.add( "cn=schema,ou=system" );
        rootDSE.put( attr );

        attr = new LockableAttributeImpl( "supportedLDAPVersion" );
        rootDSE.put( attr );
        attr.add( "3" );

        attr = new LockableAttributeImpl( "objectClass" );
        rootDSE.put( attr );
        attr.add( "top" );
        attr.add( "extensibleObject" );

        attr = new LockableAttributeImpl( NAMINGCTXS_ATTR );
        rootDSE.put( attr );

        attr = new LockableAttributeImpl( VENDORNAME_ATTR );
        attr.add( ASF );
        rootDSE.put( attr );

        // register will add to the list of namingContexts as well
        register( this.system );
View Full Code Here

     */
    private void setUpNode( String name ) throws NamingException
    {
        Attributes attrs = new LockableAttributesImpl();

        Attribute attr = new LockableAttributeImpl( ( Lockable ) attrs, "objectClass" );

        attr.add( "top" );

        attr.add( "prefNode" );

        attr.add( "extensibleObject" );

        attrs.put( attr );

        attr = new LockableAttributeImpl( ( Lockable ) attrs, "prefNodeName" );

        attr.add( name );

        attrs.put( attr );

        LdapContext parent = ( ( ServerSystemPreferences ) parent() ).getLdapContext();

View Full Code Here

            return new LockableAttributesImpl();
        }

        HashSet set = new HashSet( ids.length );
        LockableAttributesImpl attrs = new LockableAttributesImpl();
        LockableAttributeImpl attr = null;

        for ( int ii = 0; ii < ids.length; ii++ )
        {
            set.add( ids[ii].toLowerCase() );
        }


        if ( set.contains( "objectclasses" ) )
        {
            attr = new LockableAttributeImpl( attrs, "objectClasses" );
            Iterator list = globalRegistries.getObjectClassRegistry().list();
            while ( list.hasNext() )
            {
                ObjectClass oc = ( ObjectClass ) list.next();
                attr.add( SchemaUtils.render( oc ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "attributetypes" ) )
        {
            attr = new LockableAttributeImpl( attrs, "attributeTypes" );
            Iterator list = globalRegistries.getAttributeTypeRegistry().list();
            while ( list.hasNext() )
            {
                AttributeType at = ( AttributeType ) list.next();
                attr.add( SchemaUtils.render( at ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "matchingrules" ) )
        {
            attr = new LockableAttributeImpl( attrs, "matchingRules" );
            Iterator list = globalRegistries.getMatchingRuleRegistry().list();
            while ( list.hasNext() )
            {
                MatchingRule mr = ( MatchingRule ) list.next();
                attr.add( SchemaUtils.render( mr ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "matchingruleuse" ) )
        {
            attr = new LockableAttributeImpl( attrs, "matchingRuleUse" );
            Iterator list = globalRegistries.getMatchingRuleUseRegistry().list();
            while ( list.hasNext() )
            {
                MatchingRuleUse mru = ( MatchingRuleUse ) list.next();
                attr.add( SchemaUtils.render( mru ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "ldapsyntaxes" ) )
        {
            attr = new LockableAttributeImpl( attrs, "ldapSyntaxes" );
            Iterator list = globalRegistries.getSyntaxRegistry().list();
            while ( list.hasNext() )
            {
                Syntax syntax = ( Syntax ) list.next();
                attr.add( SchemaUtils.render( syntax ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "ditcontentrules" ) )
        {
            attr = new LockableAttributeImpl( attrs, "dITContentRules" );
            Iterator list = globalRegistries.getDitContentRuleRegistry().list();
            while ( list.hasNext() )
            {
                DITContentRule dcr = ( DITContentRule ) list.next();
                attr.add( SchemaUtils.render( dcr ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "ditstructurerules" ) )
        {
            attr = new LockableAttributeImpl( attrs, "dITStructureRules" );
            Iterator list = globalRegistries.getDitStructureRuleRegistry().list();
            while ( list.hasNext() )
            {
                DITStructureRule dsr = ( DITStructureRule ) list.next();
                attr.add( SchemaUtils.render( dsr ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "nameforms" ) )
        {
            attr = new LockableAttributeImpl( attrs, "nameForms" );
            Iterator list = globalRegistries.getNameFormRegistry().list();
            while ( list.hasNext() )
            {
                NameForm nf = ( NameForm ) list.next();
                attr.add( SchemaUtils.render( nf ).toString() );
            }
            attrs.put( attr );
        }

        // add the objectClass attribute
        attr = new LockableAttributeImpl( attrs, "objectClass" );
        attr.add( "top" );
        attr.add( "subschema" );
        attrs.put( attr );

        // add the cn attribute as required for the RDN
        attrs.put( "cn", "schema" );
View Full Code Here

            if ( asBinary )
            {
                Attribute attribute = entry.get( id );

                Attribute binary = new LockableAttributeImpl( id );

                for ( int ii = 0; ii < attribute.size(); ii++ )
                {
                    Object value = attribute.get( ii );

                    if ( value instanceof String )
                    {
                        binary.add( ii, ( ( String ) value ).getBytes() );
                    }
                    else
                    {
                        binary.add( ii, value );
                    }
                }

                entry.remove( id );
View Full Code Here

        assertEquals( 2, configs[0].getAttributes().size() );
        assertEquals( 3, configs[0].getIndices().length );
        assertTrue( ArrayUtils.isEquals( new String[]{ "ou", "objectClass", "uid" },
                configs[0].getIndices() ) );
        LockableAttributesImpl attrs = new LockableAttributesImpl();
        LockableAttributeImpl attr = new LockableAttributeImpl( "dc" );
        attrs.put( attr );
        attr.add( "apache" );
        attr = new LockableAttributeImpl( "objectClass" );
        attrs.put( attr );
        attr.add( "top" );
        attr.add( "domain" );
        attr.add( "extensibleObject" );
        assertTrue( attrs.equals( configs[0].getAttributes() ) );

        // test the 'test' config bean
        assertEquals( "test", configs[1].getId() );
        assertEquals( "ou=test", configs[1].getSuffix() );
        assertNotNull( configs[1].getAttributes() );
        assertEquals( 2, configs[1].getAttributes().size() );
        assertEquals( 2, configs[1].getIndices().length );
        assertTrue( ArrayUtils.isEquals( new String[]{ "ou", "objectClass" },
                configs[1].getIndices() ) );
        attrs = new LockableAttributesImpl();
        attr = new LockableAttributeImpl( "ou" );
        attrs.put( attr );
        attr.add( "test" );
        attr = new LockableAttributeImpl( "objectClass" );
        attrs.put( attr );
        attr.add( "top" );
        attr.add( "extensibleObject" );
        attr.add( "organizationalUnit" );
        assertTrue( attrs.equals( configs[1].getAttributes() ) );
    }
View Full Code Here

        assertEquals( 2, configs[0].getAttributes().size() );
        assertEquals( 3, configs[0].getIndices().length );
        assertTrue( ArrayUtils.isEquals( new String[]{ "ou", "objectClass", "uid" },
                configs[0].getIndices() ) );
        LockableAttributesImpl attrs = new LockableAttributesImpl();
        LockableAttributeImpl attr = new LockableAttributeImpl( "dc" );
        attrs.put( attr );
        attr.add( "apache" );
        attr = new LockableAttributeImpl( "objectClass" );
        attrs.put( attr );
        attr.add( "top" );
        attr.add( "domain" );
        attr.add( "extensibleObject" );
        assertTrue( attrs.equals( configs[0].getAttributes() ) );

        // test the 'test' config bean
        assertEquals( "test", configs[1].getId() );
        assertEquals( "ou=test", configs[1].getSuffix() );
        assertNotNull( configs[1].getAttributes() );
        assertEquals( 2, configs[1].getAttributes().size() );
        assertEquals( 2, configs[1].getIndices().length );
        assertTrue( ArrayUtils.isEquals( new String[]{ "ou", "objectClass" },
                configs[1].getIndices() ) );
        attrs = new LockableAttributesImpl();
        attr = new LockableAttributeImpl( "ou" );
        attrs.put( attr );
        attr.add( "test" );
        attr = new LockableAttributeImpl( "objectClass" );
        attrs.put( attr );
        attr.add( "top" );
        attr.add( "extensibleObject" );
        attr.add( "organizationalUnit" );
        assertTrue( attrs.equals( configs[1].getAttributes() ) );
    }
View Full Code Here

TOP

Related Classes of org.apache.ldap.common.message.LockableAttributeImpl

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.