use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.
the class SearchRequestMatchingRuleAssertionTest method testDecodeSearchRequestEmptyExtensibleMatch.
/**
* Test the decoding of a SearchRequest with an empty extensible match
*/
@Test
public void testDecodeSearchRequestEmptyExtensibleMatch() {
byte[] asn1BER = new byte[] { 0x30, 0x3B, 0x02, 0x01, // messageID
0x04, 0x63, // baseObject LDAPDN,
0x36, 0x04, 0x1F, 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, (byte) 0xFF, (byte) 0xA9, 0x00, 0x30, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
0x02, 0x04, 0x00 };
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(asn1BER.length);
stream.put(asn1BER);
stream.flip();
// Allocate a LdapMessage Container
LdapMessageContainer<SearchRequestDecorator> ldapMessageContainer = new LdapMessageContainer<SearchRequestDecorator>(codec);
// Decode a SearchRequest message
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
assertTrue(true);
return;
}
fail("We should not reach this point");
}
use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.
the class ApiLdapCodecCoreOsgiTest method useBundleClasses.
@Override
protected void useBundleClasses() throws Exception {
LdapStatesEnum.END_STATE.isEndState();
new InitBindRequest();
new InitBindResponse();
new InitAddRequest();
new InitAddResponse();
new InitSearchRequest();
new InitSearchResultDone();
new AndFilter();
new SubstringFilter();
SearchRequest decoratedMessage = new SearchRequestImpl();
new SearchRequestDecorator(ldapApiService, decoratedMessage);
}
use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.
the class InitSearchRequest method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<SearchRequestDecorator> container) {
// Now, we can allocate the SearchRequest Object
TLV tlv = container.getCurrentTLV();
SearchRequest internalSearchRequest = new SearchRequestImpl();
internalSearchRequest.setMessageId(container.getMessageId());
SearchRequestDecorator searchRequest = new SearchRequestDecorator(container.getLdapCodecService(), internalSearchRequest);
searchRequest.setTlvId(tlv.getId());
container.setMessage(searchRequest);
LOG.debug("Search Request");
}
use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.
the class StoreSearchRequestBaseObject method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
SearchRequestDecorator searchRequestDecorator = container.getMessage();
SearchRequest searchRequest = searchRequestDecorator.getDecorated();
TLV tlv = container.getCurrentTLV();
// We have to check that this is a correct Dn
Dn baseObject;
// root.
if (tlv.getLength() != 0) {
byte[] dnBytes = tlv.getValue().getData();
String dnStr = Strings.utf8ToString(dnBytes);
try {
baseObject = new Dn(dnStr);
} catch (LdapInvalidDnException ine) {
String msg = "Invalid root Dn given : " + dnStr + " (" + Strings.dumpBytes(dnBytes) + ") is invalid";
LOG.error("{} : {}", msg, ine.getMessage());
SearchResultDoneImpl response = new SearchResultDoneImpl(searchRequest.getMessageId());
throw new ResponseCarryingException(msg, response, ResultCodeEnum.INVALID_DN_SYNTAX, Dn.EMPTY_DN, ine);
}
} else {
baseObject = Dn.EMPTY_DN;
}
searchRequest.setBase(baseObject);
LOG.debug("Searching with root Dn : {}", baseObject);
}
use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator 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");
}
}
Aggregations