use of org.apache.directory.api.ldap.model.message.SearchResultDoneImpl 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.model.message.SearchResultDoneImpl in project directory-ldap-api by apache.
the class InitSearchResultDone method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<SearchResultDoneDecorator> container) {
// Now, we can allocate the SearchResultDone Object
SearchResultDoneDecorator searchResultDone = new SearchResultDoneDecorator(container.getLdapCodecService(), new SearchResultDoneImpl(container.getMessageId()));
container.setMessage(searchResultDone);
LOG.debug("Search Result Done found");
}
use of org.apache.directory.api.ldap.model.message.SearchResultDoneImpl in project directory-ldap-api by apache.
the class SearchRequestTest method testDecodeSearchRequestGlobalBadObjectBase.
/**
* Test the decoding of a SearchRequest with a bad objectBase
*/
@Test
public void testDecodeSearchRequestGlobalBadObjectBase() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x90);
stream.put(new byte[] { 0x30, (byte) 0x81, // LDAPMessage ::=SEQUENCE {
(byte) 0x8D, 0x02, 0x01, // messageID MessageID
0x01, 0x63, (byte) 0x81, // CHOICE { ...,
(byte) 0x87, // SearchRequest ::= APPLICATION[3] SEQUENCE {
0x04, // baseObject LDAPDN,
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, // scope ENUMERATED {
0x01, // wholeSubtree (2) },
0x0A, 0x01, // derefAliases ENUMERATED {
0x03, // derefAlways (3) },
0x02, 0x02, 0x03, // sizeLimit INTEGER (0 .. maxInt), (1000)
(byte) 0xE8, 0x02, 0x02, 0x03, // timeLimit INTEGER (0 .. maxInt), (1000)
(byte) 0xE8, 0x01, 0x01, // typesOnly BOOLEAN, (TRUE)
(byte) 0xFF, // filter Filter,
(byte) 0xA0, // Filter ::= CHOICE {
0x3C, // and [0] SET OF Filter,
(byte) 0xA1, // or [1] SET of Filter,
0x24, (byte) 0xA3, // equalityMatch [3]
0x12, // attributeDesc AttributeDescription (LDAPString),
0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's', // assertionValue AssertionValue (OCTET STRING) }
0x04, 0x03, 't', 'o', 'p', (byte) 0xA3, // equalityMatch [3] Assertion,
0x0E, // Assertion ::= SEQUENCE {
0x04, 0x02, 'o', // attributeDesc AttributeDescription (LDAPString),
'u', // assertionValue AssertionValue (OCTET STRING) }
0x04, 0x08, 'c', 'o', 'n', 't', 'a', 'c', 't', 's', (byte) 0xA2, // not [2] Filter,
0x14, (byte) 0xA3, // equalityMatch [3] Assertion,
0x12, // attributeDesc AttributeDescription (LDAPString),
0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's', // assertionValue AssertionValue (OCTET STRING) }
0x04, 0x03, 't', 't', 't', // attributes AttributeDescriptionList }
0x30, // AttributeDescriptionList ::= SEQUENCE OF
0x15, // AttributeDescription
0x04, 0x05, 'a', 't', 't', 'r', // AttributeDescription ::= LDAPString
'0', 0x04, 0x05, 'a', 't', 't', 'r', // AttributeDescription ::= LDAPString
'1', 0x04, 0x05, 'a', 't', 't', 'r', // AttributeDescription ::= LDAPString
'2' });
stream.flip();
// Allocate a LdapMessage Container
LdapMessageContainer<SearchRequestDecorator> ldapMessageContainer = new LdapMessageContainer<SearchRequestDecorator>(codec);
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
assertTrue(de instanceof ResponseCarryingException);
Message response = ((ResponseCarryingException) de).getResponse();
assertTrue(response instanceof SearchResultDoneImpl);
assertEquals(ResultCodeEnum.INVALID_DN_SYNTAX, ((SearchResultDoneImpl) response).getLdapResult().getResultCode());
return;
}
fail("We should not reach this point");
}
Aggregations