Esempio n. 1
0
        /// <summary>
        /// Initialize the server. It creates the partition, adds the index, and
        /// injects the context entries for the created partitions.
        /// </summary>
        /// <exception cref="Exception"> if there were some problems while initializing the system </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void initializeDirectory() throws Exception
        protected internal virtual void initializeDirectory()
        {
            workingDirectory.mkdirs();

            service = new DefaultDirectoryService();
            InstanceLayout il = new InstanceLayout(workingDirectory);

            service.InstanceLayout = il;

            CacheService cacheService = new CacheService();

            cacheService.initialize(service.InstanceLayout);
            service.CacheService = cacheService;

            initSchemaPartition();

            // then the system partition
            // this is a MANDATORY partition
            // DO NOT add this via addPartition() method, trunk code complains about duplicate partition
            // while initializing
            JdbmPartition systemPartition = new JdbmPartition(service.SchemaManager, service.DnFactory);

            systemPartition.Id            = "system";
            systemPartition.PartitionPath = (new File(service.InstanceLayout.PartitionsDirectory, systemPartition.Id)).toURI();
            systemPartition.SuffixDn      = new Dn(ServerDNConstants.SYSTEM_DN);
            systemPartition.SchemaManager = service.SchemaManager;

            // mandatory to call this method to set the system partition
            // Note: this system partition might be removed from trunk
            service.SystemPartition = systemPartition;

            // Disable the ChangeLog system
            service.ChangeLog.Enabled         = false;
            service.DenormalizeOpAttrsEnabled = true;

            Partition camundaPartition = addPartition("camunda", BASE_DN, service.DnFactory);

            addIndex(camundaPartition, "objectClass", "ou", "uid");

            service.startup();

            // Create the root entry
            if (!service.AdminSession.exists(camundaPartition.SuffixDn))
            {
                Dn    dn    = new Dn(BASE_DN);
                Entry entry = service.newEntry(dn);
                entry.add("objectClass", "top", "domain", "extensibleObject");
                entry.add("dc", "camunda");
                service.AdminSession.add(entry);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// initialize the schema manager and add the schema partition to directory
        /// service
        /// </summary>
        /// <exception cref="Exception"> if the schema LDIF files are not found on the classpath </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void initSchemaPartition() throws Exception
        protected internal virtual void initSchemaPartition()
        {
            InstanceLayout instanceLayout = service.InstanceLayout;

            File schemaPartitionDirectory = new File(instanceLayout.PartitionsDirectory, "schema");

            // Extract the schema on disk (a brand new one) and load the registries
            if (schemaPartitionDirectory.exists())
            {
                LOG.info("schema partition already exists, skipping schema extraction");
            }
            else
            {
                SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(instanceLayout.PartitionsDirectory);
                extractor.extractOrCopy();
            }

            SchemaLoader  loader        = new LdifSchemaLoader(schemaPartitionDirectory);
            SchemaManager schemaManager = new DefaultSchemaManager(loader);

            // We have to load the schema now, otherwise we won't be able
            // to initialize the Partitions, as we won't be able to parse
            // and normalize their suffix Dn
            schemaManager.loadAllEnabled();

            IList <Exception> errors = schemaManager.Errors;

            if (errors.Count > 0)
            {
                throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
            }

            service.SchemaManager = schemaManager;

            // Init the LdifPartition with schema
            LdifPartition schemaLdifPartition = new LdifPartition(schemaManager, service.DnFactory);

            schemaLdifPartition.PartitionPath = schemaPartitionDirectory.toURI();

            // The schema partition
            SchemaPartition schemaPartition = new SchemaPartition(schemaManager);

            schemaPartition.WrappedPartition = schemaLdifPartition;
            service.SchemaPartition          = schemaPartition;
        }
Esempio n. 3
0
        /// <exception cref="System.Exception"/>
        private void InitDirectoryService()
        {
            ds = new DefaultDirectoryService();
            ds.SetInstanceLayout(new InstanceLayout(workDir));
            CacheService cacheService = new CacheService();

            ds.SetCacheService(cacheService);
            // first load the schema
            InstanceLayout instanceLayout           = ds.GetInstanceLayout();
            FilePath       schemaPartitionDirectory = new FilePath(instanceLayout.GetPartitionsDirectory
                                                                       (), "schema");
            SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(instanceLayout.GetPartitionsDirectory
                                                                               ());

            extractor.ExtractOrCopy();
            SchemaLoader  loader        = new LdifSchemaLoader(schemaPartitionDirectory);
            SchemaManager schemaManager = new DefaultSchemaManager(loader);

            schemaManager.LoadAllEnabled();
            ds.SetSchemaManager(schemaManager);
            // Init the LdifPartition with schema
            LdifPartition schemaLdifPartition = new LdifPartition(schemaManager);

            schemaLdifPartition.SetPartitionPath(schemaPartitionDirectory.ToURI());
            // The schema partition
            SchemaPartition schemaPartition = new SchemaPartition(schemaManager);

            schemaPartition.SetWrappedPartition(schemaLdifPartition);
            ds.SetSchemaPartition(schemaPartition);
            JdbmPartition systemPartition = new JdbmPartition(ds.GetSchemaManager());

            systemPartition.SetId("system");
            systemPartition.SetPartitionPath(new FilePath(ds.GetInstanceLayout().GetPartitionsDirectory
                                                              (), systemPartition.GetId()).ToURI());
            systemPartition.SetSuffixDn(new DN(ServerDNConstants.SystemDn));
            systemPartition.SetSchemaManager(ds.GetSchemaManager());
            ds.SetSystemPartition(systemPartition);
            ds.GetChangeLog().SetEnabled(false);
            ds.SetDenormalizeOpAttrsEnabled(true);
            ds.AddLast(new KeyDerivationInterceptor());
            // create one partition
            string orgName = conf.GetProperty(OrgName).ToLower(Extensions.GetEnglishCulture()
                                                               );
            string orgDomain = conf.GetProperty(OrgDomain).ToLower(Extensions.GetEnglishCulture()
                                                                   );
            JdbmPartition partition = new JdbmPartition(ds.GetSchemaManager());

            partition.SetId(orgName);
            partition.SetPartitionPath(new FilePath(ds.GetInstanceLayout().GetPartitionsDirectory
                                                        (), orgName).ToURI());
            partition.SetSuffixDn(new DN("dc=" + orgName + ",dc=" + orgDomain));
            ds.AddPartition(partition);
            // indexes
            ICollection <Index <object, object, string> > indexedAttributes = new HashSet <Index <
                                                                                               object, object, string> >();

            indexedAttributes.AddItem(new JdbmIndex <string, Org.Apache.Directory.Api.Ldap.Model.Entry.Entry
                                                     >("objectClass", false));
            indexedAttributes.AddItem(new JdbmIndex <string, Org.Apache.Directory.Api.Ldap.Model.Entry.Entry
                                                     >("dc", false));
            indexedAttributes.AddItem(new JdbmIndex <string, Org.Apache.Directory.Api.Ldap.Model.Entry.Entry
                                                     >("ou", false));
            partition.SetIndexedAttributes(indexedAttributes);
            // And start the ds
            ds.SetInstanceId(conf.GetProperty(Instance));
            ds.Startup();
            // context entry, after ds.startup()
            DN dn = new DN("dc=" + orgName + ",dc=" + orgDomain);

            Org.Apache.Directory.Api.Ldap.Model.Entry.Entry entry = ds.NewEntry(dn);
            entry.Add("objectClass", "top", "domain");
            entry.Add("dc", orgName);
            ds.GetAdminSession().Add(entry);
        }