Package org.apache.ldap.common.message

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


            list = new LdifIterator( in );
           
            while ( list.hasNext() )
            {
                String dif = ( String ) list.next();
                LockableAttributesImpl attrs = new LockableAttributesImpl();
                parser.parse( attrs, dif );
                String updn = ( String ) attrs.get( "dn" ).get();
                LdapName ndn =
                    new LdapName( StringTools.deepTrimToLower( updn ) );
                attrs.remove( "dn" );

                if ( null == database.getEntryId( ndn.toString() ) )
                {
                    database.add( updn, ndn, attrs );
                    load();
View Full Code Here


    /**
     * @see Database#getIndices(java.math.BigInteger)
     */
    public Attributes getIndices( BigInteger id ) throws  NamingException
    {
        Attributes attributes = new LockableAttributesImpl();

        // Get the distinguishedName to id mapping
        attributes.put( "_nDn", getEntryDn( id ) );
        attributes.put( "_upDn", getEntryUpdn( id ) );
        attributes.put( "_parent", getParentId( id ) );

        // Get all standard index attribute to value mappings
        Iterator idxList = this.indices.values().iterator();
        while ( idxList.hasNext() )
        {
            Index index = ( Index ) idxList.next();
            NamingEnumeration list = index.listReverseIndices( id );
            while ( list.hasMore() )
            {
                IndexRecord rec = ( IndexRecord ) list.next();
                Object val = rec.getIndexKey();
                attributes.put( index.getAttribute().getName(), val );
            }
        }

        // Get all existance mappings for this id creating a special key
        // that looks like so 'existance[attribute]' and the value is set to id
        NamingEnumeration list = existanceIdx.listReverseIndices( id );
        StringBuffer val = new StringBuffer();
        while ( list.hasMore() )
        {
            IndexRecord rec = ( IndexRecord ) list.next();
            val.append( "_existance[" );
            val.append( rec.getIndexKey() );
            val.append( "]" );
            attributes.put( val.toString(), rec.getEntryId() );
            val.setLength( 0 );
        }

        // Get all parent child mappings for this entry as the parent using the
        // key 'child' with many entries following it.
        list = hierarchyIdx.listIndices( id );
        while ( list.hasMore() )
        {
            IndexRecord rec = ( IndexRecord ) list.next();
            attributes.put( "_child", rec.getEntryId() );
        }

        return attributes;
    }
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
        {
            sysRoot.modifyAttributes( "uid=admin",
                    DirContext.REPLACE_ATTRIBUTE, attributes );
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

            list = new LdifIterator( in );
           
            while ( list.hasNext() )
            {
                String dif = ( String ) list.next();
                LockableAttributesImpl attrs = new LockableAttributesImpl();
                parser.parse( attrs, dif );
                String updn = ( String ) attrs.get( "dn" ).get();
                LdapName ndn =
                    new LdapName( StringTools.deepTrimToLower( updn ) );
                attrs.remove( "dn" );

                if ( null == partition.getEntryId( ndn.toString() ) )
                {
                    partition.add( updn, ndn, attrs );
                    load();
View Full Code Here

    }


    public Attributes getIndices( BigInteger id ) throws  NamingException
    {
        Attributes attributes = new LockableAttributesImpl();

        // Get the distinguishedName to id mapping
        attributes.put( "_nDn", getEntryDn( id ) );
        attributes.put( "_upDn", getEntryUpdn( id ) );
        attributes.put( "_parent", getParentId( id ) );

        // Get all standard index attribute to value mappings
        Iterator idxList = this.indices.values().iterator();
        while ( idxList.hasNext() )
        {
            Index index = ( Index ) idxList.next();
            NamingEnumeration list = index.listReverseIndices( id );
            while ( list.hasMore() )
            {
                IndexRecord rec = ( IndexRecord ) list.next();
                Object val = rec.getIndexKey();
                String attrId = index.getAttribute().getName();
                Attribute attr = attributes.get( attrId );
                if ( attr == null)
                {
                    attr = new LockableAttributeImpl( attrId );
                }
                attr.add( val );
                attributes.put( attr );
            }
        }

        // Get all existance mappings for this id creating a special key
        // that looks like so 'existance[attribute]' and the value is set to id
        NamingEnumeration list = existanceIdx.listReverseIndices( id );
        StringBuffer val = new StringBuffer();
        while ( list.hasMore() )
        {
            IndexRecord rec = ( IndexRecord ) list.next();
            val.append( "_existance[" );
            val.append( rec.getIndexKey() );
            val.append( "]" );

            String valStr = val.toString();
            Attribute attr = attributes.get( valStr );
            if ( attr == null )
            {
                attr = new LockableAttributeImpl( valStr );
            }
            attr.add( rec.getEntryId() );
            attributes.put( attr );
            val.setLength( 0 );
        }

        // Get all parent child mappings for this entry as the parent using the
        // key 'child' with many entries following it.
        list = hierarchyIdx.listIndices( id );
        Attribute childAttr = new LockableAttributeImpl( "_child" );
        attributes.put( childAttr );
        while ( list.hasMore() )
        {
            IndexRecord rec = ( IndexRecord ) list.next();
            childAttr.add( rec.getEntryId() );
        }
View Full Code Here

        {
            entry = ( Attributes ) rec.getAttributes().clone();
        }
        else if ( attrIdsHasPlus )
        {
            entry = new LockableAttributesImpl();

            // add all listed attributes
            for ( int ii = 0; ii < attrIds.length; ii++ )
            {
                if ( attrIds[ii].equals( "+") )
                {
                    continue;
                }
                // there is no attribute by that name in the entry so we continue
                if ( null == rec.getAttributes().get( attrIds[ii] ) )
                {
                    continue;
                }

                // clone attribute to stuff into the new resultant entry
                Attribute attr = ( Attribute ) rec.getAttributes().get( attrIds[ii] ).clone();
                entry.put( attr );
            }

            // add all operational attributes
            NamingEnumeration list = rec.getAttributes().getIDs();
            while ( list.hasMore() )
            {
                String attrId = ( String ) list.next();
                AttributeType attrType = registry.lookup( attrId );
                if ( attrType.getUsage() == UsageEnum.USERAPPLICATIONS )
                {
                    continue;
                }

                Attribute attr = ( Attribute ) rec.getAttributes().get( attrId ).clone();
                entry.put( attr );
            }
        }
        else if ( attrIdsHasStar )
        {
            entry = new LockableAttributesImpl();

            // add all listed operational attributes
            for ( int ii = 0; ii < attrIds.length; ii++ )
            {
                if ( attrIds[ii].equals( "*") )
                {
                    continue;
                }
                // there is no attribute by that name in the entry so we continue
                if ( null == rec.getAttributes().get( attrIds[ii] ) )
                {
                    continue;
                }

                // clone attribute to stuff into the new resultant entry
                Attribute attr = ( Attribute ) rec.getAttributes().get( attrIds[ii] ).clone();
                entry.put( attr );
            }

            // add all user attributes
            NamingEnumeration list = rec.getAttributes().getIDs();
            while ( list.hasMore() )
            {
                String attrId = ( String ) list.next();
                AttributeType attrType = registry.lookup( attrId );
                if ( attrType.getUsage() == UsageEnum.USERAPPLICATIONS )
                {
                    Attribute attr = ( Attribute ) rec.getAttributes().get( attrId ).clone();
                    entry.put( attr );
                }
            }
        }
        else
        {
            entry = new LockableAttributesImpl();

            for ( int ii = 0; ii < attrIds.length; ii++ )
            {
                // there is no attribute by that name in the entry so we continue
                if ( null == rec.getAttributes().get( attrIds[ii] ) )
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

        {
            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

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.