Search in sources :

Example 41 with TLV

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

the class InitOrFilter 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_04010);
        LOG.error(msg);
        throw new DecoderException(msg);
    }
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    // We can allocate the SearchRequest
    Filter orFilter = new OrFilter(container.getTlvId());
    // Set the filter
    searchRequestDecorator.addCurrentFilter(orFilter);
    if (IS_DEBUG) {
        LOG.debug("Initialize OR filter");
    }
}
Also used : DecoderException(org.apache.directory.api.asn1.DecoderException) Filter(org.apache.directory.api.ldap.codec.search.Filter) OrFilter(org.apache.directory.api.ldap.codec.search.OrFilter) OrFilter(org.apache.directory.api.ldap.codec.search.OrFilter) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 42 with TLV

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

the class InitPresentFilter method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // We can allocate the Attribute Value Assertion
    PresentFilter presentFilter = new PresentFilter(container.getTlvId());
    // add the filter to the request filter
    searchRequestDecorator.addCurrentFilter(presentFilter);
    searchRequestDecorator.setTerminalFilter(presentFilter);
    String value = Strings.utf8ToString(tlv.getValue().getData());
    if (Strings.isEmpty(value)) {
        presentFilter.setAttributeDescription("");
    } else {
        // Store the value.
        String type = Strings.utf8ToString(tlv.getValue().getData());
        presentFilter.setAttributeDescription(type);
    }
    // We now have to get back to the nearest filter which is
    // not terminal.
    searchRequestDecorator.unstackFilters(container);
    if (IS_DEBUG) {
        LOG.debug("Initialize Present filter");
    }
}
Also used : PresentFilter(org.apache.directory.api.ldap.codec.search.PresentFilter) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 43 with TLV

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

the class StoreInitial method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // Store the value.
    SubstringFilter substringFilter = (SubstringFilter) searchRequestDecorator.getTerminalFilter();
    if (tlv.getLength() == 0) {
        String msg = I18n.err(I18n.ERR_04108);
        LOG.error(msg);
        throw new DecoderException(msg);
    }
    substringFilter.setInitialSubstrings(Strings.utf8ToString(tlv.getValue().getData()));
    // We now have to get back to the nearest filter which is
    // not terminal.
    searchRequestDecorator.unstackFilters(container);
}
Also used : DecoderException(org.apache.directory.api.asn1.DecoderException) SubstringFilter(org.apache.directory.api.ldap.codec.search.SubstringFilter) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 44 with TLV

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

the class StoreMatchValue method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator decorator = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // Store the value.
    ExtensibleMatchFilter extensibleMatchFilter = (ExtensibleMatchFilter) decorator.getTerminalFilter();
    byte[] value = tlv.getValue().getData();
    extensibleMatchFilter.setMatchValue(new Value(value));
    // unstack the filters if needed
    decorator.unstackFilters(container);
    if (IS_DEBUG) {
        LOG.debug("Stored a match value : {}", value);
    }
}
Also used : ExtensibleMatchFilter(org.apache.directory.api.ldap.codec.search.ExtensibleMatchFilter) Value(org.apache.directory.api.ldap.model.entry.Value) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 45 with TLV

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

the class AbstractReadBitString method action.

/**
 * {@inheritDoc}
 */
@Override
public final void action(C container) throws DecoderException {
    TLV tlv = container.getCurrentTLV();
    // The Length should not be null, and should be 5
    if (tlv.getLength() != 5) {
        String msg = I18n.err(I18n.ERR_01100_INCORRECT_LENGTH, 5, tlv.getLength());
        LOG.error(msg);
        // This will generate a PROTOCOL_ERROR
        throw new DecoderException(msg);
    }
    byte[] data = tlv.getValue().getData();
    setBitString(data, container);
    if (IS_DEBUG) {
        LOG.debug(I18n.msg(I18n.MSG_01101_BITSTRING_VALUE, Strings.dumpBytes(data)));
    }
}
Also used : DecoderException(org.apache.directory.api.asn1.DecoderException) 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