Search in sources :

Example 31 with TLV

use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.

the class InitAndFilter method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    TLV tlv = container.getCurrentTLV();
    if (tlv.getLength() == 0) {
        String msg = I18n.err(I18n.ERR_04006);
        LOG.error(msg);
        throw new DecoderException(msg);
    }
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    // We can allocate the SearchRequest
    Filter andFilter = new AndFilter(container.getTlvId());
    // Set the filter
    searchRequestDecorator.addCurrentFilter(andFilter);
    if (IS_DEBUG) {
        LOG.debug("Initialize AND filter");
    }
}
Also used : DecoderException(org.apache.directory.api.asn1.DecoderException) AndFilter(org.apache.directory.api.ldap.codec.search.AndFilter) Filter(org.apache.directory.api.ldap.codec.search.Filter) AndFilter(org.apache.directory.api.ldap.codec.search.AndFilter) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 32 with TLV

use of org.apache.directory.api.asn1.ber.tlv.TLV 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 33 with TLV

use of org.apache.directory.api.asn1.ber.tlv.TLV 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 34 with TLV

use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.

the class StoreIntermediateResponseValue method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<IntermediateResponseDecorator<?>> container) throws DecoderException {
    // We can get the IntermediateResponse Object
    IntermediateResponse intermediateResponse = container.getMessage();
    // Get the Value and store it in the IntermediateResponse
    TLV tlv = container.getCurrentTLV();
    // value
    if (tlv.getLength() == 0) {
        intermediateResponse.setResponseValue(Strings.EMPTY_BYTES);
    } else {
        intermediateResponse.setResponseValue(tlv.getValue().getData());
    }
    // We can have an END transition
    container.setGrammarEndAllowed(true);
    if (IS_DEBUG) {
        LOG.debug("Value read : {}", Strings.dumpBytes(intermediateResponse.getResponseValue()));
    }
}
Also used : IntermediateResponse(org.apache.directory.api.ldap.model.message.IntermediateResponse) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 35 with TLV

use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.

the class AddAttributeType method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchResultEntryDecorator> container) throws DecoderException {
    SearchResultEntryDecorator searchResultEntry = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // Store the type
    if (tlv.getLength() == 0) {
        // The type can't be null
        String msg = I18n.err(I18n.ERR_04081);
        LOG.error(msg);
        throw new DecoderException(msg);
    } else {
        try {
            searchResultEntry.addAttribute(tlv.getValue().getData());
        } catch (LdapException ine) {
            String type = Strings.utf8ToString(tlv.getValue().getData());
            // This is for the client side. We will never decode LdapResult on the server
            String msg = "The Attribute type " + type + "is invalid : " + ine.getMessage();
            LOG.error("{} : {}", msg, ine.getMessage());
            throw new DecoderException(msg, ine);
        }
    }
    if (IS_DEBUG) {
        String type = Strings.utf8ToString(tlv.getValue().getData());
        LOG.debug("Attribute type : {}", type);
    }
}
Also used : DecoderException(org.apache.directory.api.asn1.DecoderException) SearchResultEntryDecorator(org.apache.directory.api.ldap.codec.decorators.SearchResultEntryDecorator) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Aggregations

TLV (org.apache.directory.api.asn1.ber.tlv.TLV)92 DecoderException (org.apache.directory.api.asn1.DecoderException)54 BerValue (org.apache.directory.api.asn1.ber.tlv.BerValue)19 SearchRequestDecorator (org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator)17 ResponseCarryingException (org.apache.directory.api.ldap.codec.api.ResponseCarryingException)12 LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)10 Dn (org.apache.directory.api.ldap.model.name.Dn)10 IntegerDecoderException (org.apache.directory.api.asn1.ber.tlv.IntegerDecoderException)9 BindRequest (org.apache.directory.api.ldap.model.message.BindRequest)7 SearchRequest (org.apache.directory.api.ldap.model.message.SearchRequest)6 BooleanDecoderException (org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException)5 Filter (org.apache.directory.api.ldap.codec.search.Filter)5 SubstringFilter (org.apache.directory.api.ldap.codec.search.SubstringFilter)5 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)5 LdapResult (org.apache.directory.api.ldap.model.message.LdapResult)5 ResultResponse (org.apache.directory.api.ldap.model.message.ResultResponse)5 Asn1Decoder (org.apache.directory.api.asn1.ber.Asn1Decoder)4 LdapMessageContainer (org.apache.directory.api.ldap.codec.api.LdapMessageContainer)4 AddRequestDecorator (org.apache.directory.api.ldap.codec.decorators.AddRequestDecorator)4 ModifyRequestDecorator (org.apache.directory.api.ldap.codec.decorators.ModifyRequestDecorator)4