Package org.apache.ldap.common.schema

Examples of org.apache.ldap.common.schema.Normalizer


    {
        RE regex = null;
        Index idx = null;
        final SubstringNode snode = ( SubstringNode ) node;
        AttributeType type = attributeTypeRegistry.lookup( snode.getAttribute() );
        Normalizer normalizer = type.getSubstr().getNormalizer();

        if ( db.hasUserIndexOn( snode.getAttribute() ) )
        {
            /*
             * Build out regex in this block so we do not do it twice in the
View Full Code Here


            // create the database/store
            // ----------------------------------------------------------------

            Name upSuffix = new LdapName( configs[ii].getSuffix() );

            Normalizer dnNorm = reg.lookup( "distinguishedNameMatch" ) .getNormalizer();

            Name normSuffix = new LdapName( ( String ) dnNorm.normalize( configs[ii].getSuffix() ) );

            Database db = new JdbmDatabase( upSuffix, normSuffix, wkdir );

            // ----------------------------------------------------------------
            // create the search engine using db, enumerators and evaluators
View Full Code Here

       
        /*
         * We need to iterate through all values and for each value we normalize
         * and use the comparator to determine if a match exists.
         */
        Normalizer normalizer = getNormalizer( attrId );
        Comparator comparator = getComparator( attrId );
        Object filterValue = normalizer.normalize( node.getValue() );
        NamingEnumeration list = attr.getAll();
       
        /*
         * Cheaper to not check isGreater in one loop - better to separate
         * out into two loops which you choose to execute based on isGreater
         */
        if ( isGreater )
        {
            while ( list.hasMore() )
            {
                Object value = normalizer.normalize( list.next() );
           
                // Found a value that is greater than or equal to the ava value
                if ( 0 >= comparator.compare( value, filterValue ) )
                {
                    return true;
                }
            }
        }
        else
        {   
            while ( list.hasMore() )
            {
                Object value = normalizer.normalize( list.next() );
           
                // Found a value that is less than or equal to the ava value
                if ( 0 <= comparator.compare( value, filterValue ) )
                {
                    return true;
View Full Code Here

        {
            Index idx = db.getUserIndex( node.getAttribute() );
            return idx.hasValue( node.getValue(), rec.getEntryId() );
        }

        Normalizer normalizer = getNormalizer( node.getAttribute() );
        Comparator comparator = getComparator( node.getAttribute() );

        /*
         * Get the attribute and if it is not set in rec then resusitate it
         * from the master table and set it in rec for use later if at all.
         * Before iterating through all values for a match check to see if the
         * AVA value is contained or the normalized form of the AVA value is
         * contained.
         */
       
        // resusitate entry if need be
        if ( null == rec.getAttributes() )
        {
            rec.setAttributes( db.lookup( rec.getEntryId() ) );
        }
       
        // get the attribute associated with the node
        Attribute attr = rec.getAttributes().get( node.getAttribute() );
       
        // If we do not have the attribute just return false
        if ( null == attr )
        {
            return false;
        }
       
        // check if AVA value exists in attribute
        if ( attr.contains( node.getValue() ) )
        {
            return true;
        }

        // get the normalized AVA filter value
        Object filterValue = normalizer.normalize( node.getValue() );

        // check if the normalized value is present
        if ( attr.contains( filterValue ) )
        {
            return true;
        }
       
        /*
         * We need to now iterate through all values because we could not get
         * a lookup to work.  For each value we normalize and use the comparator
         * to determine if a match exists.
         */
        NamingEnumeration list = attr.getAll();
        while ( list.hasMore() )
        {
            Object value = normalizer.normalize( list.next() );
           
            if ( 0 == comparator.compare( value, filterValue ) )
            {
                return true;
            }
View Full Code Here

    }


    public Normalizer lookup( String oid ) throws NamingException
    {
        Normalizer c;
        NamingException e;

        if ( normalizers.containsKey( oid ) )
        {
            c = ( Normalizer ) normalizers.get( oid );
View Full Code Here

    {
        RE regex = null;
        SubstringNode snode = ( SubstringNode ) node;
        String oid = oidRegistry.getOid( snode.getAttribute() );
        AttributeType type = attributeTypeRegistry.lookup( oid );
        Normalizer normalizer = type.getSubstr().getNormalizer();

        if ( db.hasUserIndexOn( snode.getAttribute() ) )
        {
            Index idx = db.getUserIndex( snode.getAttribute() );
       
            /*
             * Note that this is using the reverse half of the index giving a
             * considerable performance improvement on this kind of operation.
             * Otherwise we would have to scan the entire index if there were
             * no reverse lookups.
             */
       
            NamingEnumeration list = idx.listReverseIndices( record.getEntryId() );

            // compile the regular expression to search for a matching attribute
            try
            {
                regex = snode.getRegex( normalizer );
            }
            catch ( RESyntaxException e )
            {
                NamingException ne = new NamingException( "SubstringNode '"
                    + node + "' had " + "incorrect syntax" );
                ne.setRootCause( e );
                throw ne;
            }

            // cycle through the attribute values testing for a match
            while ( list.hasMore() )
            {
                IndexRecord rec = ( IndexRecord ) list.next();
           
                // once match is found cleanup and return true
                if ( regex.match( ( String ) rec.getIndexKey() ) )
                {
                    list.close();
                    return true;
                }
            }

            // we fell through so a match was not found - assertion was false.
            return false;
        }

        // --------------------------------------------------------------------
        // Index not defined beyond this point
        // --------------------------------------------------------------------
       
        // resusitate the entry if it has not been and set entry in IndexRecord
        if ( null == record.getAttributes() )
        {
            Attributes attrs = db.lookup( record.getEntryId() );
            record.setAttributes( attrs );
        }
       
        // get the attribute
        Attribute attr = record.getAttributes().get( snode.getAttribute() );
       
        // if the attribute does not exist just return false
        if ( null == attr )
        {
            return false;
        }

        // compile the regular expression to search for a matching attribute
        try
        {
            regex = snode.getRegex( normalizer );
        }
        catch ( RESyntaxException e )
        {
            NamingException ne = new NamingException( "SubstringNode '"
                + node + "' had " + "incorrect syntax" );
            ne.setRootCause( e );
            throw ne;
        }
       
        /*
         * Cycle through the attribute values testing normalized version
         * obtained from using the substring matching rule's normalizer.
         * The test uses the comparator obtained from the appropriate
         * substring matching rule.
         */
        NamingEnumeration list = attr.getAll();
        while ( list.hasMore() )
        {
            String value = ( String )
                normalizer.normalize( list.next() );
           
            // Once match is found cleanup and return true
            if ( regex.match( value ) )
            {
                list.close();
View Full Code Here

            ( 2.5.13.12 NAME 'caseIgnoreListSubstringsMatch'
              SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
        */

        Normalizer normalizer;

        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
        cb.schemaObjectProduced( this, "2.5.13.5", normalizer );

        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
View Full Code Here

                + oid + " does not exist!" );
            monitor.lookupFailed( oid, e );
            throw e;
        }

        Normalizer normalizer = ( Normalizer ) byOid.get( oid );
        monitor.lookedUp( oid, normalizer );
        return normalizer;
    }
View Full Code Here

     * @see org.apache.ldap.server.schema.bootstrap.BootstrapProducer#produce(BootstrapRegistries, ProducerCallback)
     */
    public void produce( BootstrapRegistries registries, ProducerCallback cb )
        throws NamingException
    {
        Normalizer normalizer;

        /* Really an openLDAP matching rule but its used in he nis so its here
         *
            ( 1.3.6.1.4.1.4203.1.2.1 NAME 'caseExactIA5SubstringsMatch'
             SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
View Full Code Here

     * @see org.apache.ldap.server.schema.bootstrap.BootstrapProducer#produce(org.apache.ldap.server.schema.bootstrap.BootstrapRegistries, org.apache.ldap.server.schema.bootstrap.ProducerCallback)
     */
    public void produce( BootstrapRegistries registries, ProducerCallback cb )
        throws NamingException
    {
        Normalizer normalizer;

        // For exactDnAsStringMatch -> 1.2.6.1.4.1.18060.1.1.1.2.1
        normalizer = new NoOpNormalizer();
        cb.schemaObjectProduced( this, "1.2.6.1.4.1.18060.1.1.1.2.1", normalizer );

View Full Code Here

TOP

Related Classes of org.apache.ldap.common.schema.Normalizer

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.