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");
}
}
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");
}
}
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);
}
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);
}
}
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)));
}
}
Aggregations