Package org.apache.ldap.common.message

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


        {
            return lookup( dn );
        }

        Attributes entry = lookup( dn );
        Attributes retval = new LockableAttributesImpl();

        for ( int ii = 0; ii < attrIds.length; ii++ )
        {
            Attribute attr = entry.get( attrIds[0] );

            if ( attr != null )
            {
                retval.put( attr );
            }
        }

        return retval;
    }
View Full Code Here


    /**
     * @see javax.naming.Context#createSubcontext(javax.naming.Name)
     */
    public Context createSubcontext( Name name ) throws NamingException
    {
        Attributes attributes = new LockableAttributesImpl();

        LdapName target = buildTarget( name );

        String rdn = name.get( name.size() - 1 );

        String rdnAttribute = NamespaceTools.getRdnAttribute( rdn );

        String rdnValue = NamespaceTools.getRdnValue( rdn );

        attributes.put( rdnAttribute, rdnValue );

        attributes.put( JavaLdapSupport.OBJECTCLASS_ATTR, JavaLdapSupport.JCONTAINER_ATTR );

        attributes.put( JavaLdapSupport.OBJECTCLASS_ATTR, JavaLdapSupport.TOP_ATTR );
       
        /*
         * Add the new context to the server which as a side effect adds
         * operational attributes to the attributes refering instance which
         * can them be used to initialize a new ServerLdapContext.  Remember
View Full Code Here

        }
        else if ( obj instanceof Serializable )
        {
            // Serialize and add outAttrs

            Attributes attributes = new LockableAttributesImpl();

            if ( outAttrs != null && outAttrs.size() > 0 )
            {
                NamingEnumeration list = outAttrs.getAll();

                while ( list.hasMore() )
                {
                    attributes.put( ( Attribute ) list.next() );
                }
            }

            Name target = buildTarget( name );

            // Serialize object into entry attributes and add it.

            JavaLdapSupport.serialize( attributes, obj );

            nexusProxy.add( target.toString(), target, attributes );
        }
        else if ( obj instanceof DirContext )
        {
            // Grab attributes and merge with outAttrs

            Attributes attributes = ( ( DirContext ) obj ).getAttributes( "" );

            if ( outAttrs != null && outAttrs.size() > 0 )
            {
                NamingEnumeration list = outAttrs.getAll();

                while ( list.hasMore() )
                {
                    attributes.put( ( Attribute ) list.next() );
                }
            }

            Name target = buildTarget( name );
View Full Code Here

        assertNotNull( configs[0].getAttributes() );
        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

        assertNotNull( configs[0].getAttributes() );
        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

        }
        else
        {
            isFirstStart = true;

            Attributes attributes = new LockableAttributesImpl();

            attributes.put( "objectClass", "top" );

            attributes.put( "objectClass", "person" );

            attributes.put( "objectClass", "organizationalPerson" );

            attributes.put( "objectClass", "inetOrgPerson" );

            attributes.put( "uid", SystemPartition.ADMIN_UID );

            attributes.put( "userPassword", SystemPartition.ADMIN_PW );

            attributes.put( "displayName", "Directory Superuser" );

            attributes.put( "creatorsName", ADMIN );

            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );

            attributes.put( "displayName", "Directory Superuser" );

            nexus.add( ADMIN, ADMIN_NAME, attributes );
        }

        // -------------------------------------------------------------------
        // create system users area
        // -------------------------------------------------------------------

        if ( nexus.hasEntry( new LdapName( "ou=users,ou=system" ) ) )
        {
            isFirstStart = false;
        }
        else
        {
            isFirstStart = true;

            Attributes attributes = new LockableAttributesImpl();

            attributes.put( "objectClass", "top" );

            attributes.put( "objectClass", "organizationalUnit" );

            attributes.put( "ou", "users" );

            attributes.put( "creatorsName", ADMIN );

            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );

            nexus.add( "ou=users,ou=system", new LdapName( "ou=users,ou=system" ), attributes );
        }

        // -------------------------------------------------------------------
        // create system groups area
        // -------------------------------------------------------------------

        if ( nexus.hasEntry( new LdapName( "ou=groups,ou=system" ) ) )
        {
            isFirstStart = false;
        }
        else
        {
            isFirstStart = true;

            Attributes attributes = new LockableAttributesImpl();

            attributes.put( "objectClass", "top" );

            attributes.put( "objectClass", "organizationalUnit" );

            attributes.put( "ou", "groups" );

            attributes.put( "creatorsName", ADMIN );

            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );

            nexus.add( "ou=groups,ou=system", new LdapName( "ou=groups,ou=system" ), attributes );
        }

        // -------------------------------------------------------------------
        // create system preferences area
        // -------------------------------------------------------------------

        if ( nexus.hasEntry( new LdapName( "prefNodeName=sysPrefRoot,ou=system" ) ) )
        {
            isFirstStart = false;
        }
        else
        {
            isFirstStart = true;

            Attributes attributes = new LockableAttributesImpl();

            attributes.put( "objectClass", "top" );

            attributes.put( "objectClass", "prefNode" );

            attributes.put( "objectClass", "extensibleObject" );

            attributes.put( "prefNodeName", "sysPrefRoot" );

            attributes.put( "creatorsName", ADMIN );

            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );

            LdapName dn = new LdapName( "prefNodeName=sysPrefRoot,ou=system" );

            nexus.add( "prefNodeName=sysPrefRoot,ou=system", dn, attributes );
        }
View Full Code Here

        {
            LdifIterator iterator = new LdifIterator( in );

            while ( iterator.hasNext() )
            {
                Attributes attributes = new LockableAttributesImpl();

                String ldif = ( String ) iterator.next();

                parser.parse( attributes, ldif );

                Name dn = new LdapName( ( String ) attributes.remove( "dn" ).get() );

                dn.remove( 0 );

                ctx.createSubcontext( dn, attributes );
            }
View Full Code Here

        system = new SystemPartition( db, eng, attributes );

        globalRegistries = new GlobalRegistries( system, bootstrapRegistries );

        nexus = new RootNexus( system, new LockableAttributesImpl() );

        provider = new JndiProvider( nexus );

        // --------------------------------------------------------------------
        // Adding interceptors
View Full Code Here

     *
     * @throws NamingException if there are problems
     */
    public void testModifyOnAdminByAdmin() throws NamingException
    {
        Attributes attributes = new LockableAttributesImpl();
        attributes.put( "userPassword", "replaced" );
        sysRoot.modifyAttributes( "uid=admin", DirContext.REPLACE_ATTRIBUTE, attributes );
        Attributes newAttrs = sysRoot.getAttributes( "uid=admin" );
        assertEquals( "replaced", newAttrs.get( "userPassword" ).get() );
    }
View Full Code Here

    /**
     * Makes sure the a non-admin user cannot rename the admin account.
     */
    public void testModifyOnAdminByNonAdmin()
    {
        Attributes attributes = new LockableAttributesImpl();
        attributes.put( "userPassword", "replaced" );

        try
        {
            sysRootAsNonAdminUser.modifyAttributes( "uid=admin",
                    DirContext.REPLACE_ATTRIBUTE, attributes );
View Full Code Here

TOP

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

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.