Search in sources :

Example 36 with TLV

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

the class StoreSearchResultAttributeValue method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchResultEntryDecorator> container) {
    SearchResultEntryDecorator searchResultEntry = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // Store the value
    Object value = null;
    try {
        if (tlv.getLength() == 0) {
            searchResultEntry.addAttributeValue("");
            LOG.debug("The attribute value is null");
        } else {
            if (container.isBinary(searchResultEntry.getCurrentAttribute().getId())) {
                value = tlv.getValue().getData();
                if (IS_DEBUG) {
                    LOG.debug("Attribute value {}", Strings.dumpBytes((byte[]) value));
                }
            } else {
                value = Strings.utf8ToString(tlv.getValue().getData());
                LOG.debug("Attribute value {}", value);
            }
            searchResultEntry.addAttributeValue(value);
        }
    } catch (LdapException le) {
    // Just swallow the exception, it can't occur here
    }
    // We can have an END transition
    container.setGrammarEndAllowed(true);
}
Also used : 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)

Example 37 with TLV

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

the class StoreServerSASLCreds method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<BindResponseDecorator> container) throws DecoderException {
    // Get the Value and store it in the BindRequest
    TLV tlv = container.getCurrentTLV();
    // We have to handle the special case of a 0 length server
    // sasl credentials
    byte[] serverSaslCreds;
    if (tlv.getLength() == 0) {
        serverSaslCreds = Strings.EMPTY_BYTES;
    } else {
        serverSaslCreds = tlv.getValue().getData();
    }
    BindResponse response = container.getMessage();
    response.setServerSaslCreds(serverSaslCreds);
    // We can have an END transition
    container.setGrammarEndAllowed(true);
    if (IS_DEBUG) {
        LOG.debug("The SASL credentials value is : {}", Strings.dumpBytes(serverSaslCreds));
    }
}
Also used : BindResponse(org.apache.directory.api.ldap.model.message.BindResponse) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 38 with TLV

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

the class InitCompareResponse method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<CompareResponseDecorator> container) throws DecoderException {
    // Now, we can allocate the CompareResponse Object
    CompareResponseDecorator compareResponse = new CompareResponseDecorator(container.getLdapCodecService(), new CompareResponseImpl(container.getMessageId()));
    container.setMessage(compareResponse);
    // We will check that the request is not null
    TLV tlv = container.getCurrentTLV();
    if (tlv.getLength() == 0) {
        String msg = I18n.err(I18n.ERR_04094);
        LOG.error(msg);
        throw new DecoderException(msg);
    }
    LOG.debug("Compare response ");
}
Also used : DecoderException(org.apache.directory.api.asn1.DecoderException) CompareResponseImpl(org.apache.directory.api.ldap.model.message.CompareResponseImpl) CompareResponseDecorator(org.apache.directory.api.ldap.codec.decorators.CompareResponseDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 39 with TLV

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

the class StoreExtendedResponseValue method action.

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

Example 40 with TLV

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

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