Package org.apache.directory.api.ldap.model.schema

Examples of org.apache.directory.api.ldap.model.schema.SchemaManager


    @Test
    public void testLoadSchema() throws Exception
    {
        connection.loadSchema();
        SchemaManager manager = connection.getSchemaManager();
        assertNotNull( manager );
        assertTrue( manager.isEnabled( "system" ) );
        assertFalse( manager.isEnabled( "nis" ) );
        assertEquals( manager.getLoader().getAllSchemas().size(), manager.getEnabled().size() );
    }
View Full Code Here


        if ( request.getDerefAliases() != previousSearchRequest.getDerefAliases() )
        {
            return false;
        }

        SchemaManager schemaManager =
            session.getLdapServer().getDirectoryService().getSchemaManager();

        // Compares the attributes
        if ( request.getAttributes() == null )
        {
View Full Code Here

     * @param replicaId The replica ID
     */
    public ReplicaEventLog( DirectoryService directoryService, int replicaId ) throws IOException
    {
        PROVIDER_LOG.debug( "Creating the replication queue for replica {}", replicaId );
        SchemaManager schemaManager = directoryService.getSchemaManager();
        this.replicaId = replicaId;
        this.searchCriteria = new NotificationCriteria();
        this.searchCriteria.setEventMask( EventType.ALL_EVENT_TYPES_MASK );

        // Create the journal file, or open if already exists
View Full Code Here

        {
            // The schema has already been extracted, bypass
        }

        SchemaLoader loader = new LdifSchemaLoader( schemaRepository );
        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();

        // Tell all the normalizer comparators that they should not normalize anything
        ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry();

        for ( LdapComparator<?> comparator : comparatorRegistry )
        {
            if ( comparator instanceof NormalizingComparator )
            {
                ( ( NormalizingComparator ) comparator ).setOnServer();
            }
        }

        directoryService.setSchemaManager( schemaManager );

        // Init the LdifPartition
        LdifPartition ldifPartition = new LdifPartition( schemaManager, directoryService.getDnFactory() );
        ldifPartition.setPartitionPath( new File( workingDirectory, "schema" ).toURI() );
        SchemaPartition schemaPartition = new SchemaPartition( schemaManager );
        schemaPartition.setWrappedPartition( ldifPartition );
        directoryService.setSchemaPartition( schemaPartition );

        List<Throwable> errors = schemaManager.getErrors();

        if ( errors.size() != 0 )
        {
            throw new Exception( I18n.err( I18n.ERR_317, Exceptions.printErrors( errors ) ) );
        }
View Full Code Here

            authenticationInterceptor.init( service );
        }

        service.setInterceptors( interceptorList );

        SchemaManager schemaManager = service.getSchemaManager();

        // process the schemas
        for ( LoadSchema loadedSchema : dsBuilder.loadedSchemas() )
        {
            String schemaName = loadedSchema.name();
            Boolean enabled = loadedSchema.enabled();

            // Check if the schema is loaded or not
            boolean isLoaded = schemaManager.isSchemaLoaded( schemaName );

            if ( !isLoaded )
            {
                // We have to load the schema, if it exists
                try
                {
                    isLoaded = schemaManager.load( schemaName );
                }
                catch ( LdapUnwillingToPerformException lutpe )
                {
                    // Cannot load the schema, it does not exists
                    LOG.error( lutpe.getMessage() );
                    continue;
                }
            }

            if ( isLoaded )
            {
                if ( enabled )
                {
                    schemaManager.enable( schemaName );

                    if ( schemaManager.isDisabled( schemaName ) )
                    {
                        LOG.error( "Cannot enable " + schemaName );
                    }
                }
                else
                {
                    schemaManager.disable( schemaName );

                    if ( schemaManager.isEnabled( schemaName ) )
                    {
                        LOG.error( "Cannot disable " + schemaName );
                    }
                }
            }
View Full Code Here

    {
        LOG.debug( "Starting the server" );

        initSchema();

        SchemaManager schemaManager = directoryService.getSchemaManager();

        if ( !directoryService.isStarted() )
        {
            // inject the schema manager and set the partition directory
            // once the CiDIT gets done we need not do this kind of dirty hack
View Full Code Here

            SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
            extractor.extractOrCopy();
        }

        SchemaLoader loader = new LdifSchemaLoader( schemaRepository );
        SchemaManager schemaManager = new DefaultSchemaManager( loader );
        directoryService.setSchemaManager( schemaManager );

        // Init the LdifPartition
        LdifPartition ldifPartition = new LdifPartition( schemaManager, directoryService.getDnFactory() );
        ldifPartition.setPartitionPath( new File( workingDirectory, "schema" ).toURI() );

        schemaPartition.setWrappedPartition( ldifPartition );

        // 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();

        schemaPartition.setSchemaManager( schemaManager );

        List<Throwable> errors = schemaManager.getErrors();

        if ( errors.size() != 0 )
        {
            throw new Exception( I18n.err( I18n.ERR_317, Exceptions.printErrors( errors ) ) );
        }
View Full Code Here

        index.setCacheSize( jdbmIndexBean.getIndexCacheSize() );
        index.setNumDupLimit( jdbmIndexBean.getIndexNumDupLimit() );

        // Find the OID for this index
        SchemaManager schemaManager = directoryService.getSchemaManager();

        try
        {
            AttributeType indexAT = schemaManager.lookupAttributeTypeRegistry( indexFileName );
            indexFileName = indexAT.getOid();
        }
        catch ( LdapException le )
        {
            // Not found ? We will use the index file name
View Full Code Here

            {
                throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_HARDERROR,
                    ( "No such principal " + byPrincipal ).getBytes() );
            }

            SchemaManager schemaManager = directoryService.getSchemaManager();

            CoreSession bySession = null;

            boolean isAdmin = ebyPrincipalEntry.getDn().getNormName()
                .equals( ServerDNConstants.ADMIN_SYSTEM_DN_NORMALIZED );

            if ( !isInitialTicket && !isAdmin )
            {
                throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_INITIAL_FLAG_NEEDED );
            }

            // if admin assign the admin session
            if ( isAdmin )
            {
                bySession = adminSession;
            }
            // otherwise create a new session for the user with 'byPrincipal' who is trying to change the password for 'forPrincipal'
            else
            {
                LdapPrincipal byLdapPrincipal = new LdapPrincipal( schemaManager, ebyPrincipalEntry.getDn(),
                    AuthenticationLevel.SIMPLE );

                bySession = new DefaultCoreSession( byLdapPrincipal, directoryService );
            }

            Attribute newPasswordAttribute = new DefaultAttribute(
                schemaManager.lookupAttributeTypeRegistry( SchemaConstants.USER_PASSWORD_AT ),
                Strings.getBytesUtf8( newPassword ) );
            Modification passwordMod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
                newPasswordAttribute );

            Attribute principalAttribute = new DefaultAttribute(
                schemaManager.lookupAttributeTypeRegistry( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT ),
                forPrincipal.getName() );
            Modification principalMod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
                principalAttribute );

            Entry forPrincipalEntry = StoreUtils.findPrincipalEntry( bySession, searchBaseDn, forPrincipal.getName() );
View Full Code Here

     * @throws LdapException with problems initializing cache
     */
    public TriggerSpecCache( DirectoryService directoryService ) throws LdapException
    {
        this.nexus = directoryService.getPartitionNexus();
        final SchemaManager schemaManager = directoryService.getSchemaManager();

        triggerSpecParser = new TriggerSpecificationParser( new NormalizerMappingResolver()
        {
            public Map<String, OidNormalizer> getNormalizerMapping() throws Exception
            {
                return schemaManager.getNormalizerMapping();
            }
        } );

        initialize( directoryService );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.schema.SchemaManager

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.