Java Code Examples for org.apache.directory.api.ldap.model.schema.AttributeType#equals()

The following examples show how to use org.apache.directory.api.ldap.model.schema.AttributeType#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultEntry.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Entry add( String upId, AttributeType attributeType, byte[]... values ) throws LdapException
{
    // ObjectClass with binary values are not allowed
    if ( attributeType.equals( objectClassAttributeType ) )
    {
        String message = I18n.err( I18n.ERR_13227_NON_STRING_VALUE_NOT_ALLOWED );
        LOG.error( message );
        throw new UnsupportedOperationException( message );
    }

    Attribute attribute = attributes.get( attributeType.getOid() );

    String id = getUpId( upId, attributeType );

    if ( attribute != null )
    {
        // This Attribute already exist, we add the values
        // into it
        attribute.add( values );
        attribute.setUpId( id, attributeType );
    }
    else
    {
        // We have to create a new Attribute and set the values
        // and the upId
        createAttribute( id, attributeType, values );
    }

    return this;
}
 
Example 2
Source File: DefaultEntry.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void add( String upId, AttributeType attributeType, byte[]... values ) throws LdapException
{
    // ObjectClass with binary values are not allowed
    if ( attributeType.equals( objectClassAttributeType ) )
    {
        String message = I18n.err( I18n.ERR_04461 );
        LOG.error( message );
        throw new UnsupportedOperationException( message );
    }

    Attribute attribute = attributes.get( attributeType.getOid() );

    String id = getUpId( upId, attributeType );

    if ( attribute != null )
    {
        // This Attribute already exist, we add the values
        // into it
        attribute.add( values );
        attribute.setUpId( id, attributeType );
    }
    else
    {
        // We have to create a new Attribute and set the values
        // and the upId
        createAttribute( id, attributeType, values );
    }
}
 
Example 3
Source File: DefaultEntry.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Entry add( String upId, AttributeType attributeType, byte[]... values ) throws LdapException
{
    // ObjectClass with binary values are not allowed
    if ( attributeType.equals( objectClassAttributeType ) )
    {
        String message = I18n.err( I18n.ERR_04461 );
        LOG.error( message );
        throw new UnsupportedOperationException( message );
    }

    Attribute attribute = attributes.get( attributeType.getOid() );

    String id = getUpId( upId, attributeType );

    if ( attribute != null )
    {
        // This Attribute already exist, we add the values
        // into it
        attribute.add( values );
        attribute.setUpId( id, attributeType );
    }
    else
    {
        // We have to create a new Attribute and set the values
        // and the upId
        createAttribute( id, attributeType, values );
    }
    
    return this;
}
 
Example 4
Source File: SearchRequestHandler.java    From MyVirtualDirectory with Apache License 2.0 4 votes vote down vote up
/**
 * Alters the filter expression based on the presence of the
 * ManageDsaIT decorator.  If the decorator is not present, the search
 * filter will be altered to become a disjunction with two terms.
 * The first term is the original filter.  The second term is a
 * (objectClass=referral) assertion.  When OR'd together these will
 * make sure we get all referrals so we can process continuations
 * properly without having the filter remove them from the result
 * set.
 *
 * NOTE: original filter is first since most entries are not referrals
 * so it has a higher probability on average of accepting and shorting
 * evaluation before having to waste cycles trying to evaluate if the
 * entry is a referral.
 *
 * @param session the session to use to construct the filter (schema access)
 * @param req the request to get the original filter from
 * @throws Exception if there are schema access problems
 */
private void modifyFilter( LdapSession session, SearchRequest req ) throws Exception
{
    if ( req.hasControl( ManageDsaIT.OID ) )
    {
        return;
    }

    /*
     * Most of the time the search filter is just (objectClass=*) and if
     * this is the case then there's no reason at all to OR this with an
     * (objectClass=referral).  If we detect this case then we leave it
     * as is to represent the OR condition:
     *
     *  (| (objectClass=referral)(objectClass=*)) == (objectClass=*)
     */
    if ( req.getFilter() instanceof PresenceNode )
    {
        PresenceNode presenceNode = ( PresenceNode ) req.getFilter();

        if ( presenceNode.isSchemaAware() )
        {
            AttributeType attributeType = presenceNode.getAttributeType();

            if ( attributeType.equals( OBJECT_CLASS_AT ) )
            {
                return;
            }
        }
        else
        {
            String attribute = presenceNode.getAttribute();

            if ( attribute.equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT )
                || attribute.equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT_OID ) )
            {
                return;
            }
        }
    }

    /*
     * Do not add the OR'd (objectClass=referral) expression if the user
     * searches for the subSchemaSubEntry as the SchemaIntercepter can't
     * handle an OR'd filter.
     */
    if ( isSubSchemaSubEntrySearch( session, req ) )
    {
        return;
    }

    // using varags to add two expressions to an OR node
    req.setFilter( new OrNode( req.getFilter(), newIsReferralEqualityNode( session ) ) );
}
 
Example 5
Source File: SearchRequestHandler.java    From MyVirtualDirectory with Apache License 2.0 4 votes vote down vote up
/**
 * Handles the RootDSE and lookups searches
 */
private boolean handleLookupAndRootDse( LdapSession session, SearchRequest req ) throws Exception
{
    boolean isBaseScope = req.getScope() == SearchScope.OBJECT;
    boolean isObjectClassFilter = false;

    if ( req.getFilter() instanceof PresenceNode )
    {
        ExprNode filter = req.getFilter();

        if ( filter.isSchemaAware() )
        {
            AttributeType attributeType = ( ( PresenceNode ) req.getFilter() ).getAttributeType();
            isObjectClassFilter = attributeType.equals( OBJECT_CLASS_AT );
        }
        else
        {
            String attribute = ( ( PresenceNode ) req.getFilter() ).getAttribute();
            isObjectClassFilter = attribute.equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT )
                || attribute.equals( SchemaConstants.OBJECT_CLASS_AT_OID );
        }
    }

    /*
            if ( isBaseScope && isObjectClassFilter )
            {
                // This is a lookup
                handleLookup( session, req );

                return true;
            }
            else
            {
                // a standard search
                return false;
            }
    */
    boolean isBaseIsRoot = req.getBase().isEmpty();

    if ( isBaseScope && isObjectClassFilter )
    {
        if ( isBaseIsRoot )
        {
            // This is a rootDse lookup
            handleLookup( session, req );

            return true;
        }
        else
        {
            // This is a lookup
            //handleLookup( session, req );

            return false;
        }
    }
    else
    {
        // a standard search
        return false;
    }
}
 
Example 6
Source File: SearchRequestHandler.java    From MyVirtualDirectory with Apache License 2.0 4 votes vote down vote up
/**
 * Alters the filter expression based on the presence of the
 * ManageDsaIT decorator.  If the decorator is not present, the search
 * filter will be altered to become a disjunction with two terms.
 * The first term is the original filter.  The second term is a
 * (objectClass=referral) assertion.  When OR'd together these will
 * make sure we get all referrals so we can process continuations
 * properly without having the filter remove them from the result
 * set.
 *
 * NOTE: original filter is first since most entries are not referrals
 * so it has a higher probability on average of accepting and shorting
 * evaluation before having to waste cycles trying to evaluate if the
 * entry is a referral.
 *
 * @param session the session to use to construct the filter (schema access)
 * @param req the request to get the original filter from
 * @throws Exception if there are schema access problems
 */
private void modifyFilter( LdapSession session, SearchRequest req ) throws Exception
{
    if ( req.hasControl( ManageDsaIT.OID ) )
    {
        return;
    }

    /*
     * Most of the time the search filter is just (objectClass=*) and if
     * this is the case then there's no reason at all to OR this with an
     * (objectClass=referral).  If we detect this case then we leave it
     * as is to represent the OR condition:
     *
     *  (| (objectClass=referral)(objectClass=*)) == (objectClass=*)
     */
    if ( req.getFilter() instanceof PresenceNode )
    {
        PresenceNode presenceNode = ( PresenceNode ) req.getFilter();

        if ( presenceNode.isSchemaAware() )
        {
            AttributeType attributeType = presenceNode.getAttributeType();

            if ( attributeType.equals( OBJECT_CLASS_AT ) )
            {
                return;
            }
        }
        else
        {
            String attribute = presenceNode.getAttribute();

            if ( attribute.equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT )
                || attribute.equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT_OID ) )
            {
                return;
            }
        }
    }

    /*
     * Do not add the OR'd (objectClass=referral) expression if the user
     * searches for the subSchemaSubEntry as the SchemaIntercepter can't
     * handle an OR'd filter.
     */
    if ( isSubSchemaSubEntrySearch( session, req ) )
    {
        return;
    }

    // using varags to add two expressions to an OR node
    req.setFilter( new OrNode( req.getFilter(), newIsReferralEqualityNode( session ) ) );
}
 
Example 7
Source File: SearchRequestHandler.java    From MyVirtualDirectory with Apache License 2.0 4 votes vote down vote up
/**
 * Handles the RootDSE and lookups searches
 */
private boolean handleLookupAndRootDse( LdapSession session, SearchRequest req ) throws Exception
{
    boolean isBaseScope = req.getScope() == SearchScope.OBJECT;
    boolean isObjectClassFilter = false;

    if ( req.getFilter() instanceof PresenceNode )
    {
        ExprNode filter = req.getFilter();

        if ( filter.isSchemaAware() )
        {
            AttributeType attributeType = ( ( PresenceNode ) req.getFilter() ).getAttributeType();
            isObjectClassFilter = attributeType.equals( OBJECT_CLASS_AT );
        }
        else
        {
            String attribute = ( ( PresenceNode ) req.getFilter() ).getAttribute();
            isObjectClassFilter = attribute.equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT )
                || attribute.equals( SchemaConstants.OBJECT_CLASS_AT_OID );
        }
    }

    /*
            if ( isBaseScope && isObjectClassFilter )
            {
                // This is a lookup
                handleLookup( session, req );

                return true;
            }
            else
            {
                // a standard search
                return false;
            }
    */
    boolean isBaseIsRoot = req.getBase().isEmpty();

    if ( isBaseScope && isObjectClassFilter )
    {
        if ( isBaseIsRoot )
        {
            // This is a rootDse lookup
            handleLookup( session, req );

            return true;
        }
        else
        {
            // This is a lookup
            //handleLookup( session, req );

            return false;
        }
    }
    else
    {
        // a standard search
        return false;
    }
}