Package org.apache.ldap.common.message

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


                if ( ids != null && ids.length > 0 )
                {
                    boolean doSwap = true;

                    Attributes askedFor = new LockableAttributesImpl();

                    for ( int ii = 0; ii < ids.length; ii++ )
                    {
                        if ( ids[ii].trim().equals( "*" ) )
                        {
                            doSwap = false;

                            break;
                        }

                        if ( attrs.get( ids[ii] ) != null )
                        {
                            askedFor.put( attrs.get( ids[ii] ) );
                        }
                    }

                    if ( doSwap )
                    {
View Full Code Here


     */
    public Attributes lookup( Name dn, String[] attrIds throws NamingException
    {
        if ( dn.size() == 0 )
        {
            LockableAttributes retval = new LockableAttributesImpl();

            NamingEnumeration list = rootDSE.getIDs();

            while ( list.hasMore() )
            {
                String id = ( String ) list.next();

                Attribute attr = rootDSE.get( id );

                retval.put( ( Attribute ) attr.clone() );
            }

            retval.setLocked( true );

            return retval;
        }

        DirectoryPartition backend = getBackend( dn );
View Full Code Here

     * @throws NamingException if there are problems accessing attributes
     */
    private Attributes getSubentryOperatationalAttributes( Name name, Attribute administrativeRole )
            throws NamingException
    {
        Attributes operational = new LockableAttributesImpl();
        NamingEnumeration roles = administrativeRole.getAll();
        while ( roles.hasMore() )
        {
            String role = ( String ) roles.next();

            if ( role.equalsIgnoreCase( AUTONOUMOUS_AREA ) )
            {
                if ( operational.get( AUTONOUMOUS_AREA_SUBENTRY ) == null )
                {
                    operational.put( AUTONOUMOUS_AREA_SUBENTRY, name.toString() );
                }
                else
                {
                    operational.get( AUTONOUMOUS_AREA_SUBENTRY ).add( name.toString() );
                }
            }
            else if ( role.equalsIgnoreCase( AC_AREA ) || role.equalsIgnoreCase( AC_INNERAREA ) )
            {
                if ( operational.get( AC_SUBENTRY ) == null )
                {
                    operational.put( AC_SUBENTRY, name.toString() );
                }
                else
                {
                    operational.get( AC_SUBENTRY ).add( name.toString() );
                }
            }
            else if ( role.equalsIgnoreCase( SCHEMA_AREA ) )
            {
                if ( operational.get( SCHEMA_AREA_SUBENTRY ) == null )
                {
                    operational.put( SCHEMA_AREA_SUBENTRY, name.toString() );
                }
                else
                {
                    operational.get( SCHEMA_AREA_SUBENTRY ).add( name.toString() );
                }
            }
            else if ( role.equalsIgnoreCase( COLLECTIVE_AREA ) ||
                      role.equalsIgnoreCase( COLLECTIVE_INNERAREA ) )
            {
                if ( operational.get( COLLECTIVE_ATTRIBUTE_SUBENTRIES ) == null )
                {
                    operational.put( COLLECTIVE_ATTRIBUTE_SUBENTRIES, name.toString() );
                }
                else
                {
                    operational.get( COLLECTIVE_ATTRIBUTE_SUBENTRIES ).add( name.toString() );
                }
            }
            else
            {
                throw new LdapInvalidAttributeValueException( "Encountered invalid administrativeRole '"
View Full Code Here

     *
     * @param name the name of the new ServerPreferences node.
     */
    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();

        parent.bind( "prefNodeName=" + name, null, attrs );

View Full Code Here

         */
        if ( !partitionNexus.hasEntry( DirectoryPartitionNexus.getAdminName() ) )
        {
            firstStart = true;

            Attributes attributes = new LockableAttributesImpl();
            Attribute objectClass = new LockableAttributeImpl( "objectClass" );
            objectClass.add( "top" );
            objectClass.add( "person" );
            objectClass.add( "organizationalPerson" );
            objectClass.add( "inetOrgPerson" );
            attributes.put( objectClass );

            attributes.put( "uid", DirectoryPartitionNexus.ADMIN_UID );
            attributes.put( "userPassword", DirectoryPartitionNexus.ADMIN_PASSWORD );
            attributes.put( "displayName", "Directory Superuser" );
            attributes.put( "cn", "system administrator" );
            attributes.put( "sn", "administrator" );
            attributes.put( "creatorsName", DirectoryPartitionNexus.ADMIN_PRINCIPAL );
            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );
            attributes.put( "displayName", "Directory Superuser" );
           
            partitionNexus.add( DirectoryPartitionNexus.ADMIN_PRINCIPAL, DirectoryPartitionNexus.getAdminName(), attributes );
        }

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

        if ( !partitionNexus.hasEntry( new LdapName( "ou=users,ou=system" ) ) )
        {
            firstStart = true;

            Attributes attributes = new LockableAttributesImpl();
            Attribute objectClass = new LockableAttributeImpl( "objectClass" );
            objectClass.add( "top" );
            objectClass.add( "organizationalUnit" );
            attributes.put( objectClass );

            attributes.put( "ou", "users" );
            attributes.put( "creatorsName", DirectoryPartitionNexus.ADMIN_PRINCIPAL );
            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );

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

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

        if ( !partitionNexus.hasEntry( new LdapName( "ou=groups,ou=system" ) ) )
        {
            firstStart = true;

            Attributes attributes = new LockableAttributesImpl();
            Attribute objectClass = new LockableAttributeImpl( "objectClass" );
            objectClass.add( "top" );
            objectClass.add( "organizationalUnit" );
            attributes.put( objectClass );

            attributes.put( "ou", "groups" );
            attributes.put( "creatorsName", DirectoryPartitionNexus.ADMIN_PRINCIPAL );
            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );

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

        // -------------------------------------------------------------------
        // create administrator group
        // -------------------------------------------------------------------

        String upName = "cn=Administrators,ou=groups,ou=system";
        Name normName = new LdapName( "cn=administrators,ou=groups,ou=system" );
        if ( !partitionNexus.hasEntry( normName ) )
        {
            firstStart = true;

            Attributes attributes = new LockableAttributesImpl();
            Attribute objectClass = new LockableAttributeImpl( "objectClass" );
            objectClass.add( "top" );
            objectClass.add( "groupOfUniqueNames" );
            attributes.put( objectClass );
            attributes.put( "cn", "Administrators" );
            attributes.put( "uniqueMember", DirectoryPartitionNexus.ADMIN_PRINCIPAL );
            attributes.put( "creatorsName", DirectoryPartitionNexus.ADMIN_PRINCIPAL );
            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );

            partitionNexus.add( upName, normName, attributes );
            AuthorizationService authzSrvc = ( AuthorizationService ) interceptorChain.get( "authorizationService" );
            authzSrvc.cacheNewGroup( upName, normName, attributes );
        }

        // -------------------------------------------------------------------
        // create system configuration area
        // -------------------------------------------------------------------

        if ( !partitionNexus.hasEntry( new LdapName( "ou=configuration,ou=system" ) ) )
        {
            firstStart = true;

            Attributes attributes = new LockableAttributesImpl();
            Attribute objectClass = new LockableAttributeImpl( "objectClass" );
            objectClass.add( "top" );
            objectClass.add( "organizationalUnit" );
            attributes.put( objectClass );

            attributes.put( "ou", "configuration" );
            attributes.put( "creatorsName", DirectoryPartitionNexus.ADMIN_PRINCIPAL );
            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );

            partitionNexus.add( "ou=configuration,ou=system", new LdapName( "ou=configuration,ou=system" ), attributes );
        }

        // -------------------------------------------------------------------
        // create system configuration area for partition information
        // -------------------------------------------------------------------

        if ( !partitionNexus.hasEntry( new LdapName( "ou=partitions,ou=configuration,ou=system" ) ) )
        {
            firstStart = true;

            Attributes attributes = new LockableAttributesImpl();
            Attribute objectClass = new LockableAttributeImpl( "objectClass" );
            objectClass.add( "top" );
            objectClass.add( "organizationalUnit" );
            attributes.put( objectClass );

            attributes.put( "ou", "partitions" );
            attributes.put( "creatorsName", DirectoryPartitionNexus.ADMIN_PRINCIPAL );
            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );

            partitionNexus.add( "ou=partitions,ou=configuration,ou=system",
                    new LdapName( "ou=partitions,ou=configuration,ou=system" ), attributes );
        }

        // -------------------------------------------------------------------
        // create system configuration area for services
        // -------------------------------------------------------------------

        if ( !partitionNexus.hasEntry( new LdapName( "ou=services,ou=configuration,ou=system" ) ) )
        {
            firstStart = true;

            Attributes attributes = new LockableAttributesImpl();
            Attribute objectClass = new LockableAttributeImpl( "objectClass" );
            objectClass.add( "top" );
            objectClass.add( "organizationalUnit" );
            attributes.put( objectClass );

            attributes.put( "ou", "services" );
            attributes.put( "creatorsName", DirectoryPartitionNexus.ADMIN_PRINCIPAL );
            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );

            partitionNexus.add( "ou=services,ou=configuration,ou=system",
                    new LdapName( "ou=services,ou=configuration,ou=system" ), attributes );
        }

        // -------------------------------------------------------------------
        // create system configuration area for interceptors
        // -------------------------------------------------------------------

        if ( !partitionNexus.hasEntry( new LdapName( "ou=interceptors,ou=configuration,ou=system" ) ) )
        {
            firstStart = true;

            Attributes attributes = new LockableAttributesImpl();
            Attribute objectClass = new LockableAttributeImpl( "objectClass" );
            objectClass.add( "top" );
            objectClass.add( "organizationalUnit" );
            attributes.put( objectClass );

            attributes.put( "ou", "interceptors" );
            attributes.put( "creatorsName", DirectoryPartitionNexus.ADMIN_PRINCIPAL );
            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );

            partitionNexus.add( "ou=interceptors,ou=configuration,ou=system",
                    new LdapName( "ou=interceptors,ou=configuration,ou=system" ), attributes );
        }

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

        if ( !partitionNexus.hasEntry( new LdapName( "prefNodeName=sysPrefRoot,ou=system" ) ) )
        {
            firstStart = true;

            Attributes attributes = new LockableAttributesImpl();
            Attribute objectClass = new LockableAttributeImpl( "objectClass" );
            objectClass.add( "top" );
            objectClass.add( "organizationalUnit" );
            attributes.put( objectClass );

            attributes.put( "objectClass", "extensibleObject" );
            attributes.put( "prefNodeName", "sysPrefRoot" );
            attributes.put( "creatorsName", DirectoryPartitionNexus.ADMIN_PRINCIPAL );
            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );

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

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

            throw e;
        }

        globalRegistries = new GlobalRegistries( bootstrapRegistries );
       
        partitionNexus = new DefaultDirectoryPartitionNexus( new LockableAttributesImpl() );
        partitionNexus.init( configuration, null );
       
        interceptorChain = new InterceptorChain();
        interceptorChain.init( configuration );
    }
View Full Code Here

        {
            ids = EMPTY_STRING_ARRAY;
        }

        Set set = new HashSet();
        LockableAttributesImpl attrs = new LockableAttributesImpl();
        LockableAttributeImpl attr;

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

        // Check whether the set contains a plus, and use it below to include all
        // operational attributes.  Due to RFC 3673, and issue DIREVE-228 in JIRA
        boolean returnAllOperationalAttributes = set.contains( "+" );

        if ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 );
        }

        // timeestamps are hacks for now until the schema is actually updateable these
        // use the servers startup time stamp for both modify and create timestamps


        if ( returnAllOperationalAttributes || set.contains( "createtimestamp" ) )
        {
            attr = new LockableAttributeImpl( attrs, "createTimestamp" );
            attr.add( startUpTimeStamp );
            attrs.put( attr );
        }

        if ( returnAllOperationalAttributes || set.contains( "modifytimestamp" ) )
        {
            attr = new LockableAttributeImpl( attrs, "modifyTimestamp" );
            attr.add( startUpTimeStamp );
            attrs.put( attr );
        }

        if ( returnAllOperationalAttributes || set.contains( "creatorsname" ) )
        {
            attr = new LockableAttributeImpl( attrs, "creatorsName" );
            attr.add( DirectoryPartitionNexus.ADMIN_PRINCIPAL );
            attrs.put( attr );
        }

        if ( returnAllOperationalAttributes || set.contains( "modifiersname" ) )
        {
            attr = new LockableAttributeImpl( attrs, "modifiersName" );
            attr.add( DirectoryPartitionNexus.ADMIN_PRINCIPAL );
            attrs.put( attr );
        }

        int minSetSize = 0;
        if ( set.contains( "+" ) )
        {
            minSetSize++;
        }
        if ( set.contains( "*" ) )
        {
            minSetSize++;
        }
        if ( set.contains( "ref" ) )
        {
            minSetSize++;
        }

        // add the objectClass attribute
        if ( set.contains( "*" ) || set.contains( "objectclass" ) || set.size() == minSetSize )
        {
            attr = new LockableAttributeImpl( attrs, "objectClass" );
            attr.add( "top" );
            attr.add( "subschema" );
            attrs.put( attr );
        }

        // add the cn attribute as required for the RDN
        if ( set.contains( "*" ) || set.contains( "cn" ) || set.contains( "commonname" ) || set.size() == minSetSize )
        {
            attrs.put( "cn", "schema" );
        }

        return attrs;
    }
View Full Code Here

        // -------------------------------------------------------------------
        // Add a single test entry
        // -------------------------------------------------------------------

        Attributes attributes = new LockableAttributesImpl();

        LdifParserImpl parser = new LdifParserImpl();

        try
        {
            parser.parse( attributes, LDIF );
        }
        catch ( NamingException e )
        {
            throw new NestableRuntimeException( e );
        }

        testEntries.add( attributes );

        // -------------------------------------------------------------------
        // Add more from an optional LDIF file if they exist
        // -------------------------------------------------------------------

        InputStream in = null;

        if ( loadClass == null && ldifPath != null )
        {
            File ldifFile = new File( ldifPath );

            if ( ldifFile.exists() )
            {
                in = new FileInputStream( ldifPath );
            }
            else
            {
                in = getClass().getResourceAsStream( ldifPath );
            }

            throw new FileNotFoundException( ldifPath );
        }
        else if ( loadClass != null && ldifPath != null )
        {
            in = loadClass.getResourceAsStream( ldifPath );
        }

        if ( in != null )
        {
            LdifIterator list = new LdifIterator( in );

            while ( list.hasNext() )
            {
                String ldif = ( String ) list.next();

                attributes = new LockableAttributesImpl();

                parser.parse( attributes, ldif );

                testEntries.add( attributes );
            }
View Full Code Here

     * @return the set of subentry op attrs for an entry
     * @throws NamingException if there are problems accessing entry information
     */
    public Attributes getSubentryAttributes( Name dn, Attributes entryAttrs ) throws NamingException
    {
        Attributes subentryAttrs = new LockableAttributesImpl();
        Attribute objectClasses = entryAttrs.get( "objectClass" );
        Iterator list = subtrees.keySet().iterator();
        while ( list.hasNext() )
        {
            String subentryDnStr = ( String ) list.next();
            Name subentryDn = new LdapName( subentryDnStr );
            Name apDn = ( Name ) subentryDn.clone();
            apDn.remove( apDn.size() - 1 );
            SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( subentryDn );

            if ( evaluator.evaluate( ss, apDn, dn, objectClasses ) )
            {
                Attribute administrativeRole = nexus.lookup( apDn ).get( "administrativeRole" );
                NamingEnumeration roles = administrativeRole.getAll();
                while ( roles.hasMore() )
                {
                    Attribute operational;
                    String role = ( String ) roles.next();

                    if ( role.equalsIgnoreCase( AUTONOUMOUS_AREA ) )
                    {
                        operational = subentryAttrs.get( AUTONOUMOUS_AREA_SUBENTRY );
                        if ( operational == null )
                        {
                            operational = new LockableAttributeImpl( AUTONOUMOUS_AREA_SUBENTRY );
                            subentryAttrs.put( operational );
                        }
                    }
                    else if ( role.equalsIgnoreCase( AC_AREA ) || role.equalsIgnoreCase( AC_INNERAREA ) )
                    {
                        operational = subentryAttrs.get( AC_SUBENTRY );
                        if ( operational == null )
                        {
                            operational = new LockableAttributeImpl( AC_SUBENTRY );
                            subentryAttrs.put( operational );
                        }
                    }
                    else if ( role.equalsIgnoreCase( SCHEMA_AREA ) )
                    {
                        operational = subentryAttrs.get( SCHEMA_AREA_SUBENTRY );
                        if ( operational == null )
                        {
                            operational = new LockableAttributeImpl( SCHEMA_AREA_SUBENTRY );
                            subentryAttrs.put( operational );
                        }
                    }
                    else if ( role.equalsIgnoreCase( COLLECTIVE_AREA ) ||
                              role.equalsIgnoreCase( COLLECTIVE_INNERAREA ) )
                    {
                        operational = subentryAttrs.get( COLLECTIVE_ATTRIBUTE_SUBENTRIES );
                        if ( operational == null )
                        {
                            operational = new LockableAttributeImpl( COLLECTIVE_ATTRIBUTE_SUBENTRIES );
                            subentryAttrs.put( operational );
                        }
                    }
                    else
                    {
                        throw new LdapInvalidAttributeValueException( "Encountered invalid administrativeRole '"
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

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.