Search in sources :

Example 46 with SearchRequestDecorator

use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.

the class InitAssertionValueFilter method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // The value can be null.
    byte[] assertion = tlv.getValue().getData();
    AttributeValueAssertionFilter terminalFilter = (AttributeValueAssertionFilter) searchRequestDecorator.getTerminalFilter();
    AttributeValueAssertion attributeValueAssertion = terminalFilter.getAssertion();
    if (assertion == null) {
        attributeValueAssertion.setAssertion(Strings.EMPTY_BYTES);
    } else {
        attributeValueAssertion.setAssertion(assertion);
    }
    // We now have to get back to the nearest filter which is
    // not terminal.
    searchRequestDecorator.unstackFilters(container);
    if (IS_DEBUG) {
        LOG.debug("Initialize Assertion Value filter");
    }
}
Also used : AttributeValueAssertionFilter(org.apache.directory.api.ldap.codec.search.AttributeValueAssertionFilter) AttributeValueAssertion(org.apache.directory.api.ldap.codec.AttributeValueAssertion) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 47 with SearchRequestDecorator

use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.

the class InitAttributeDescFilter method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    AttributeValueAssertion assertion = new AttributeValueAssertion();
    if (tlv.getLength() == 0) {
        String msg = I18n.err(I18n.ERR_04007);
        LOG.error(msg);
        throw new DecoderException(msg);
    } else {
        String type = Strings.utf8ToString(tlv.getValue().getData());
        assertion.setAttributeDesc(type);
        AttributeValueAssertionFilter terminalFilter = (AttributeValueAssertionFilter) searchRequestDecorator.getTerminalFilter();
        terminalFilter.setAssertion(assertion);
    }
    if (IS_DEBUG) {
        LOG.debug("Initialize AttributeDesc filter");
    }
}
Also used : DecoderException(org.apache.directory.api.asn1.DecoderException) AttributeValueAssertionFilter(org.apache.directory.api.ldap.codec.search.AttributeValueAssertionFilter) AttributeValueAssertion(org.apache.directory.api.ldap.codec.AttributeValueAssertion) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 48 with SearchRequestDecorator

use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.

the class InitEqualityMatchFilter method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    // We can allocate the Attribute Value Assertion
    Filter filter = new AttributeValueAssertionFilter(container.getTlvId(), LdapCodecConstants.EQUALITY_MATCH_FILTER);
    searchRequestDecorator.addCurrentFilter(filter);
    // Store the filter structure that still has to be
    // fulfilled
    searchRequestDecorator.setTerminalFilter(filter);
    if (IS_DEBUG) {
        LOG.debug("Initialize Equality Match filter");
    }
}
Also used : AttributeValueAssertionFilter(org.apache.directory.api.ldap.codec.search.AttributeValueAssertionFilter) Filter(org.apache.directory.api.ldap.codec.search.Filter) AttributeValueAssertionFilter(org.apache.directory.api.ldap.codec.search.AttributeValueAssertionFilter) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator)

Example 49 with SearchRequestDecorator

use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.

the class InitExtensibleMatchFilter method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    // We can allocate the ExtensibleMatch Filter
    Filter extensibleMatchFilter = new ExtensibleMatchFilter(container.getTlvId());
    searchRequestDecorator.addCurrentFilter(extensibleMatchFilter);
    searchRequestDecorator.setTerminalFilter(extensibleMatchFilter);
    if (IS_DEBUG) {
        LOG.debug("Initialize Extensible Match filter");
    }
}
Also used : ExtensibleMatchFilter(org.apache.directory.api.ldap.codec.search.ExtensibleMatchFilter) Filter(org.apache.directory.api.ldap.codec.search.Filter) ExtensibleMatchFilter(org.apache.directory.api.ldap.codec.search.ExtensibleMatchFilter) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator)

Example 50 with SearchRequestDecorator

use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.

the class InitGreaterOrEqualFilter method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    // We can allocate the Attribute Value Assertion
    Filter filter = new AttributeValueAssertionFilter(container.getTlvId(), LdapCodecConstants.GREATER_OR_EQUAL_FILTER);
    searchRequestDecorator.addCurrentFilter(filter);
    // Store the filter structure that still has to be
    // fulfilled
    searchRequestDecorator.setTerminalFilter(filter);
    if (IS_DEBUG) {
        LOG.debug("Initialize Greater Or Equal filter");
    }
}
Also used : AttributeValueAssertionFilter(org.apache.directory.api.ldap.codec.search.AttributeValueAssertionFilter) Filter(org.apache.directory.api.ldap.codec.search.Filter) AttributeValueAssertionFilter(org.apache.directory.api.ldap.codec.search.AttributeValueAssertionFilter) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator)

Aggregations

SearchRequestDecorator (org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator)110 DecoderException (org.apache.directory.api.asn1.DecoderException)97 ByteBuffer (java.nio.ByteBuffer)85 Asn1Decoder (org.apache.directory.api.asn1.ber.Asn1Decoder)85 LdapMessageContainer (org.apache.directory.api.ldap.codec.api.LdapMessageContainer)85 AbstractCodecServiceTest (org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)85 Test (org.junit.Test)85 SearchRequest (org.apache.directory.api.ldap.model.message.SearchRequest)48 ExprNode (org.apache.directory.api.ldap.model.filter.ExprNode)37 EncoderException (org.apache.directory.api.asn1.EncoderException)33 AndNode (org.apache.directory.api.ldap.model.filter.AndNode)19 EqualityNode (org.apache.directory.api.ldap.model.filter.EqualityNode)18 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)17 SubstringNode (org.apache.directory.api.ldap.model.filter.SubstringNode)12 OrNode (org.apache.directory.api.ldap.model.filter.OrNode)10 Filter (org.apache.directory.api.ldap.codec.search.Filter)9 PresenceNode (org.apache.directory.api.ldap.model.filter.PresenceNode)9 SubstringFilter (org.apache.directory.api.ldap.codec.search.SubstringFilter)6 GreaterEqNode (org.apache.directory.api.ldap.model.filter.GreaterEqNode)6 NotNode (org.apache.directory.api.ldap.model.filter.NotNode)6