use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.
the class InitControls method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<MessageDecorator<? extends Message>> container) throws DecoderException {
TLV tlv = container.getCurrentTLV();
int expectedLength = tlv.getLength();
// The Length can be null
if (expectedLength != 0) {
if (IS_DEBUG) {
LOG.debug("A new list of controls has been initialized");
}
} else {
if (IS_DEBUG) {
LOG.debug("An empty list of controls has been initialized");
}
}
// We can have an END transition
container.setGrammarEndAllowed(true);
}
use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.
the class StoreControlValue method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<MessageDecorator<? extends Message>> container) throws DecoderException {
TLV tlv = container.getCurrentTLV();
MessageDecorator<?> message = container.getMessage();
CodecControl<? extends Control> control = message.getCurrentControl();
// Get the current control
BerValue value = tlv.getValue();
// Store the value - have to handle the special case of a 0 length value
if (tlv.getLength() == 0) {
control.setValue(Strings.EMPTY_BYTES);
} else {
control.setValue(value.getData());
control.decode(value.getData());
}
// We can have an END transition
container.setGrammarEndAllowed(true);
if (IS_DEBUG) {
LOG.debug("Control value : " + Strings.dumpBytes(control.getValue()));
}
}
use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.
the class StoreSearchRequestSizeLimit method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
SearchRequest searchRequest = container.getMessage().getDecorated();
TLV tlv = container.getCurrentTLV();
// The current TLV should be a integer
// We get it and store it in sizeLimit
BerValue value = tlv.getValue();
long sizeLimit = 0;
try {
sizeLimit = LongDecoder.parse(value, 0, Integer.MAX_VALUE);
} catch (LongDecoderException lde) {
String msg = I18n.err(I18n.ERR_04103, value.toString());
LOG.error(msg);
throw new DecoderException(msg, lde);
}
searchRequest.setSizeLimit(sizeLimit);
if (IS_DEBUG) {
LOG.debug("The sizeLimit value is set to {} objects", Long.valueOf(sizeLimit));
}
}
use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.
the class StoreSearchRequestTimeLimit method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
SearchRequest searchRequest = container.getMessage().getDecorated();
TLV tlv = container.getCurrentTLV();
// The current TLV should be a integer
// We get it and store it in timeLimit
BerValue value = tlv.getValue();
int timeLimit = 0;
try {
timeLimit = IntegerDecoder.parse(value, 0, Integer.MAX_VALUE);
} catch (IntegerDecoderException ide) {
String msg = I18n.err(I18n.ERR_04104, value.toString());
LOG.error(msg);
throw new DecoderException(msg, ide);
}
searchRequest.setTimeLimit(timeLimit);
if (IS_DEBUG) {
LOG.debug("The timeLimit value is set to {} seconds", Integer.valueOf(timeLimit));
}
}
use of org.apache.directory.api.asn1.ber.tlv.TLV 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");
}
}
Aggregations