Package org.apache.directory.shared.ldap.schema

Examples of org.apache.directory.shared.ldap.schema.AttributeType


            // Read the attribute's OID
            String oid = in.readUTF();
           
            try
            {
                AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( oid );
               
                // Create the attribute we will read
                DefaultServerAttribute attribute = new DefaultServerAttribute( attributeType );
               
                // Read the attribute
View Full Code Here



    public PresenceCursor( Store<ServerEntry, ID> db, PresenceEvaluator<ID> presenceEvaluator ) throws Exception
    {
        this.presenceEvaluator = presenceEvaluator;
        AttributeType type = presenceEvaluator.getAttributeType();

        // we don't maintain a presence index for objectClass, entryUUID, and entryCSN
        // as it doesn't make sense because every entry has such an attribute
        // instead for those attributes and all un-indexed attributes we use the ndn index
        if ( db.hasUserIndexOn( type.getOid() ) )
        {
            presenceCursor = db.getPresenceIndex().forwardCursor( type.getOid() );
            ndnCursor = null;
        }
        else
        {
            presenceCursor = null;
View Full Code Here

            Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants(
                node.getAttribute() );

            while ( descendants.hasNext() )
            {
                AttributeType descendant = descendants.next();

                attr = ( ServerAttribute ) entry.get( descendant );

                if ( null != attr )
                {
View Full Code Here

            Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants(
                node.getAttribute() );

            while ( descendants.hasNext() )
            {
                AttributeType descendant = descendants.next();

                attr = ( ServerAttribute ) entry.get( descendant );

                if ( null != attr )
                {
View Full Code Here

        // Build the set of attributeType from the attributes
        for ( String attribute:request.getAttributes() )
        {
            try
            {
                AttributeType at = schemaManager.lookupAttributeTypeRegistry( attribute );
                requestSet.add( at.getOid() );
            }
            catch ( NamingException ne )
            {
                // Deal with special attributes : '*', '+' and '1.1'
                if ( attribute.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) ||
View Full Code Here

     */
    private String getFileName( RDN rdn ) throws NamingException
    {
        // First, get the AT name, or OID
        String normAT = rdn.getAtav().getNormType();
        AttributeType at = schemaManager.lookupAttributeTypeRegistry( normAT );

        String atName = at.getName();

        // Now, get the normalized value
        String normValue = rdn.getAtav().getNormValue().getString();

        String fileName = atName + "=" + normValue;
View Full Code Here

        for ( RDN rdn : dn.getRdns() )
        {
            // First, get the AT name, or OID
            String normAT = rdn.getAtav().getNormType();
            AttributeType at = schemaManager.lookupAttributeTypeRegistry( normAT );

            String atName = at.getName();

            // Now, get the normalized value
            String normValue = rdn.getAtav().getNormValue().getString();

            if ( isFirst )
View Full Code Here

        }
    }

    /* no protection*/ static AttributeType getCaseIgnoringAttributeNoNumbersType()
    {
        AttributeType attributeType = new AttributeType( "1.1.3.1" );
        LdapSyntax syntax = new LdapSyntax( "1.1.1.1", "", true );

        syntax.setSyntaxChecker( new SyntaxChecker( "1.1.2.1" )
        {
            private static final long serialVersionUID = 0L;

            public boolean isValidSyntax( Object value )
            {
                if ( !( value instanceof String ) )
                {
                    return false;
                }

                String strval = ( String ) value;
               
                for ( char c:strval.toCharArray() )
                {
                    if ( Character.isDigit( c ) )
                    {
                        return false;
                    }
                }
                return true;
            }
        } );
       
        MatchingRule matchingRule = new MatchingRule( "1.1.2.1" );
        matchingRule.setSyntax( syntax );


        matchingRule.setLdapComparator( new LdapComparator<String>( matchingRule.getOid() )
        {
            private static final long serialVersionUID = 0L;

            public int compare( String o1, String o2 )
            {
                return ( o1 == null ?
                    ( o2 == null ? 0 : -1 ) :
                    ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
            }

            int getValue( String val )
            {
                if ( val.equals( "LOW" ) )
                {
                    return 0;
                }
                else if ( val.equals( "MEDIUM" ) )
                {
                    return 1;
                }
                else if ( val.equals( "HIGH" ) )
                {
                    return 2;
                }
               
                throw new IllegalArgumentException( I18n.err( I18n.ERR_472 ) );
            }
        } );
       
        Normalizer normalizer = new Normalizer( "1.1.1" )
        {
            private static final long serialVersionUID = 0L;

            public Value<?> normalize( Value<?> value ) throws NamingException
            {
                if ( !value.isBinary() )
                {
                    return new ClientStringValue( value.getString().toLowerCase() );
                }

                throw new IllegalStateException( I18n.err( I18n.ERR_473 ) );
            }
           
           
            public String normalize( String value ) throws NamingException
            {
                return value.toLowerCase();
            }
        };
       
        matchingRule.setNormalizer( normalizer );
       
        attributeType.setEquality( matchingRule );
        attributeType.setSyntax( syntax );
       
        return attributeType;
    }
View Full Code Here

    }


    /* no protection*/ static AttributeType getIA5StringAttributeType()
    {
        AttributeType attributeType = new AttributeType( "1.1" );
        attributeType.addName( "1.1" );
        LdapSyntax syntax = new LdapSyntax( "1.1.1", "", true );

        syntax.setSyntaxChecker( new SyntaxChecker( "1.1.2" )
        {
            private static final long serialVersionUID = 0L;

            public boolean isValidSyntax( Object value )
            {
                return ((String)value == null) || (((String)value).length() < 7) ;
            }
        } );
       
        MatchingRule matchingRule = new MatchingRule( "1.1.2" );
        matchingRule.setSyntax( syntax );


        matchingRule.setLdapComparator( new LdapComparator<String>( matchingRule.getOid() )
        {
            private static final long serialVersionUID = 0L;

            public int compare( String o1, String o2 )
            {
                return ( ( o1 == null ) ?
                    ( o2 == null ? 0 : -1 ) :
                    ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
            }
        } );
       
        matchingRule.setNormalizer( new DeepTrimToLowerNormalizer( matchingRule.getOid() ) );
       
        attributeType.setEquality( matchingRule );
        attributeType.setSyntax( syntax );
       
        return attributeType;
    }
View Full Code Here

    }


    /* No protection */ static AttributeType getBytesAttributeType()
    {
        AttributeType attributeType = new AttributeType( "1.2" );
        LdapSyntax syntax = new LdapSyntax( "1.2.1", "", true );

        syntax.setSyntaxChecker( new SyntaxChecker( "1.2.1" )
        {
            private static final long serialVersionUID = 0L;

            public boolean isValidSyntax( Object value )
            {
                return ( value == null ) || ( ((byte[])value).length < 5 );
            }
        } );

        MatchingRule matchingRule = new MatchingRule( "1.2.2" );
        matchingRule.setSyntax( syntax );

        matchingRule.setLdapComparator( new ByteArrayComparator( "1.2.2" ) );
       
        matchingRule.setNormalizer( new Normalizer( "1.1.1" )
        {
            // The serial UID
            private static final long serialVersionUID = 1L;
           
            public Value<?> normalize( Value<?> value ) throws NamingException
            {
                if ( value.isBinary() )
                {
                    byte[] val = value.getBytes();
                   
                    // each byte will be changed to be > 0, and spaces will be trimmed
                    byte[] newVal = new byte[ val.length ];
                   
                    int i = 0;
                   
                    for ( byte b:val )
                    {
                        newVal[i++] = (byte)(b & 0x007F);
                    }
                   
                    return new ClientBinaryValue( StringTools.trim( newVal ) );
                }

                throw new IllegalStateException( I18n.err( I18n.ERR_474 ) );
            }

            public String normalize( String value ) throws NamingException
            {
                throw new IllegalStateException( I18n.err( I18n.ERR_474 ) );
            }
        } );
       
        attributeType.setEquality( matchingRule );
        attributeType.setSyntax( syntax );

        return attributeType;
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.schema.AttributeType

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.