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