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 == partition.getEntryId( ndn.toString() ) )
                {
                    partition.add( updn, ndn, attrs );
                    load();
View Full Code Here


        {
            entry = ( Attributes ) rec.getAttributes().clone();
        }
        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

        {
            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

                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;
        }

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

        if ( !partitionNexus.hasEntry( ContextPartitionNexus.getAdminName() ) )
        {
            checkPermissionToCreateBootstrapEntries();
            firstStart = true;

            Attributes attributes = new LockableAttributesImpl();
            attributes.put( "objectClass", "top" );
            attributes.put( "objectClass", "person" );
            attributes.put( "objectClass", "organizationalPerson" );
            attributes.put( "objectClass", "inetOrgPerson" );
            attributes.put( "uid", ContextPartitionNexus.ADMIN_UID );
            attributes.put( "userPassword", environment.get( Context.SECURITY_CREDENTIALS ) );
            attributes.put( "displayName", "Directory Superuser" );
            attributes.put( "creatorsName", ContextPartitionNexus.ADMIN_PRINCIPAL );
            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );
            attributes.put( "displayName", "Directory Superuser" );
           
            partitionNexus.add( ContextPartitionNexus.ADMIN_PRINCIPAL, ContextPartitionNexus.getAdminName(), attributes );
        }

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

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

            Attributes attributes = new LockableAttributesImpl();
            attributes.put( "objectClass", "top" );
            attributes.put( "objectClass", "organizationalUnit" );
            attributes.put( "ou", "users" );
            attributes.put( "creatorsName", ContextPartitionNexus.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;
            checkPermissionToCreateBootstrapEntries();

            Attributes attributes = new LockableAttributesImpl();
            attributes.put( "objectClass", "top" );
            attributes.put( "objectClass", "organizationalUnit" );
            attributes.put( "ou", "groups" );
            attributes.put( "creatorsName", ContextPartitionNexus.ADMIN_PRINCIPAL );
            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );

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

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

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

            Attributes attributes = new LockableAttributesImpl();
            attributes.put( "objectClass", "top" );
            attributes.put( "objectClass", "prefNode" );
            attributes.put( "objectClass", "extensibleObject" );
            attributes.put( "prefNodeName", "sysPrefRoot" );
            attributes.put( "creatorsName", ContextPartitionNexus.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 DefaultContextPartitionNexus( new LockableAttributesImpl() );
        partitionNexus.init( configuration, null );
       
        interceptorChain = new InterceptorChain();
        interceptorChain.init( configuration );
    }
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

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

        Attributes attributes = new LockableAttributesImpl();

        LdifParserImpl parser = new LdifParserImpl();

        try
        {
            parser.parse( attributes, LDIF );
        }
        catch ( NamingException e )
        {
            e.printStackTrace();

            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

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.