Search in sources :

Example 1 with BooleanDecoderException

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

the class StoreModifyDnRequestDeleteOldRdn method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<ModifyDnRequestDecorator> container) throws DecoderException {
    ModifyDnRequest modifyDnRequest = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // We get the value. If it's a 0, it's a FALSE. If it's
    // a FF, it's a TRUE. Any other value should be an error,
    // but we could relax this constraint. So if we have
    // something
    // which is not 0, it will be interpreted as TRUE, but we
    // will generate a warning.
    BerValue value = tlv.getValue();
    try {
        modifyDnRequest.setDeleteOldRdn(BooleanDecoder.parse(value));
    } catch (BooleanDecoderException bde) {
        LOG.error(I18n.err(I18n.ERR_04091, Strings.dumpBytes(value.getData()), bde.getMessage()));
        // This will generate a PROTOCOL_ERROR
        throw new DecoderException(bde.getMessage(), bde);
    }
    // We can have an END transition
    container.setGrammarEndAllowed(true);
    if (IS_DEBUG) {
        if (modifyDnRequest.getDeleteOldRdn()) {
            LOG.debug(" Old Rdn attributes will be deleted");
        } else {
            LOG.debug(" Old Rdn attributes will be retained");
        }
    }
}
Also used : BooleanDecoderException(org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException) DecoderException(org.apache.directory.api.asn1.DecoderException) BooleanDecoderException(org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException) BerValue(org.apache.directory.api.asn1.ber.tlv.BerValue) ModifyDnRequest(org.apache.directory.api.ldap.model.message.ModifyDnRequest) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 2 with BooleanDecoderException

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

the class StoreSearchRequestTypesOnly method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequest searchRequest = container.getMessage().getDecorated();
    TLV tlv = container.getCurrentTLV();
    // We get the value. If it's a 0, it's a FALSE. If it's
    // a FF, it's a TRUE. Any other value should be an error,
    // but we could relax this constraint. So if we have
    // something
    // which is not 0, it will be interpreted as TRUE, but we
    // will generate a warning.
    BerValue value = tlv.getValue();
    try {
        searchRequest.setTypesOnly(BooleanDecoder.parse(value));
    } catch (BooleanDecoderException bde) {
        LOG.error(I18n.err(I18n.ERR_04105, Strings.dumpBytes(value.getData()), bde.getMessage()));
        throw new DecoderException(bde.getMessage(), bde);
    }
    if (IS_DEBUG) {
        LOG.debug("The search will return {}", searchRequest.getTypesOnly() ? "only attributs type" : "attributes types and values");
    }
}
Also used : SearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest) BooleanDecoderException(org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException) DecoderException(org.apache.directory.api.asn1.DecoderException) BooleanDecoderException(org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException) BerValue(org.apache.directory.api.asn1.ber.tlv.BerValue) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 3 with BooleanDecoderException

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

the class StoreControlCriticality method action.

/**
 * {@inheritDoc}
 */
public void action(ControlsContainer container) throws DecoderException {
    TLV tlv = container.getCurrentTLV();
    // Get the current control
    Control control = container.getCurrentControl();
    // Store the criticality
    // We get the value. If it's a 0, it's a FALSE. If it's
    // a FF, it's a TRUE. Any other value should be an error,
    // but we could relax this constraint. So if we have
    // something
    // which is not 0, it will be interpreted as TRUE, but we
    // will generate a warning.
    BerValue value = tlv.getValue();
    try {
        control.setCritical(BooleanDecoder.parse(value));
    } catch (BooleanDecoderException bde) {
        LOG.error(I18n.err(I18n.ERR_04100_BAD_CONTROL_CRITICALITY, Strings.dumpBytes(value.getData()), bde.getMessage()));
        // This will generate a PROTOCOL_ERROR
        throw new DecoderException(bde.getMessage(), bde);
    }
    // We can have an END transition
    container.setGrammarEndAllowed(true);
    if (IS_DEBUG) {
        LOG.debug("Control criticality : {}", control.isCritical());
    }
}
Also used : BooleanDecoderException(org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException) DecoderException(org.apache.directory.api.asn1.DecoderException) Control(org.apache.directory.api.ldap.model.message.Control) BooleanDecoderException(org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException) BerValue(org.apache.directory.api.asn1.ber.tlv.BerValue) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 4 with BooleanDecoderException

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

the class StoreMatchingRuleDnAttributes method action.

public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator searchRequest = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // Store the value.
    ExtensibleMatchFilter extensibleMatchFilter = (ExtensibleMatchFilter) searchRequest.getTerminalFilter();
    // We get the value. If it's a 0, it's a FALSE. If it's
    // a FF, it's a TRUE. Any other value should be an error,
    // but we could relax this constraint. So if we have
    // something
    // which is not 0, it will be interpreted as TRUE, but we
    // will generate a warning.
    BerValue value = tlv.getValue();
    try {
        extensibleMatchFilter.setDnAttributes(BooleanDecoder.parse(value));
    } catch (BooleanDecoderException bde) {
        LOG.error(I18n.err(I18n.ERR_04110, Strings.dumpBytes(value.getData()), bde.getMessage()));
        throw new DecoderException(bde.getMessage(), bde);
    }
    if (IS_DEBUG) {
        LOG.debug("Dn Attributes : {}", Boolean.valueOf(extensibleMatchFilter.isDnAttributes()));
    }
    // unstack the filters if needed
    searchRequest.unstackFilters(container);
}
Also used : BooleanDecoderException(org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException) DecoderException(org.apache.directory.api.asn1.DecoderException) BooleanDecoderException(org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException) BerValue(org.apache.directory.api.asn1.ber.tlv.BerValue) ExtensibleMatchFilter(org.apache.directory.api.ldap.codec.search.ExtensibleMatchFilter) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 5 with BooleanDecoderException

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

the class StoreControlCriticality method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<MessageDecorator<? extends Message>> container) throws DecoderException {
    TLV tlv = container.getCurrentTLV();
    // Get the current control
    MessageDecorator<? extends Message> message = container.getMessage();
    Control control = message.getCurrentControl();
    // Store the criticality
    // We get the value. If it's a 0, it's a FALSE. If it's
    // a FF, it's a TRUE. Any other value should be an error,
    // but we could relax this constraint. So if we have
    // something
    // which is not 0, it will be interpreted as TRUE, but we
    // will generate a warning.
    BerValue value = tlv.getValue();
    try {
        control.setCritical(BooleanDecoder.parse(value));
    } catch (BooleanDecoderException bde) {
        LOG.error(I18n.err(I18n.ERR_04100_BAD_CONTROL_CRITICALITY, Strings.dumpBytes(value.getData()), bde.getMessage()));
        // This will generate a PROTOCOL_ERROR
        throw new DecoderException(bde.getMessage(), bde);
    }
    // We can have an END transition
    container.setGrammarEndAllowed(true);
    if (IS_DEBUG) {
        LOG.debug("Control criticality : {}", control.isCritical());
    }
}
Also used : BooleanDecoderException(org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException) DecoderException(org.apache.directory.api.asn1.DecoderException) Control(org.apache.directory.api.ldap.model.message.Control) BooleanDecoderException(org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException) BerValue(org.apache.directory.api.asn1.ber.tlv.BerValue) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Aggregations

DecoderException (org.apache.directory.api.asn1.DecoderException)5 BerValue (org.apache.directory.api.asn1.ber.tlv.BerValue)5 BooleanDecoderException (org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException)5 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)5 Control (org.apache.directory.api.ldap.model.message.Control)2 SearchRequestDecorator (org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator)1 ExtensibleMatchFilter (org.apache.directory.api.ldap.codec.search.ExtensibleMatchFilter)1 ModifyDnRequest (org.apache.directory.api.ldap.model.message.ModifyDnRequest)1 SearchRequest (org.apache.directory.api.ldap.model.message.SearchRequest)1