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