org.apache.directory.api.ldap.model.message.SearchRequest Java Examples
The following examples show how to use
org.apache.directory.api.ldap.model.message.SearchRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InitGreaterOrEqualFilter.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public void action( LdapMessageContainer<SearchRequest> container ) throws DecoderException { // We can allocate the Attribute Value Assertion Filter filter = new AttributeValueAssertionFilter( container.getCurrentTLV().getId(), LdapCodecConstants.GREATER_OR_EQUAL_FILTER ); container.addCurrentFilter( filter ); // Store the filter structure that still has to be // fulfilled container.setTerminalFilter( filter ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_05147_INITIALIZE_GEQ_FILTER ) ); } }
Example #2
Source File: LdapDataProvider.java From directory-fortress-core with Apache License 2.0 | 6 votes |
/** * This search method uses OpenLDAP Proxy Authorization Control to assert arbitrary user identity onto connection. * * @param connection is LdapConnection object used for all communication with host. * @param baseDn contains address of distinguished name to begin ldap search * @param scope indicates depth of search starting at basedn. 0 (base dn), * 1 (one level down) or 2 (infinite) are valid values. * @param filter contains the search criteria * @param attrs is the requested list of attritubutes to return from directory search. * @param attrsOnly if true pull back attribute names only. * @param userDn string value represents the identity of user on who's behalf the request was initiated. The * value will be stored in openldap auditsearch record AuthZID's attribute. * @return entry containing target ldap node. * @throws LdapException thrown in the event of error in ldap client or server code. * @throws CursorException If we weren't able to fetch an element from the search result */ protected Entry searchNode( LdapConnection connection, String baseDn, SearchScope scope, String filter, String[] attrs, boolean attrsOnly, String userDn ) throws LdapException, CursorException { COUNTERS.incrementSearch(); SearchRequest searchRequest = new SearchRequestImpl(); searchRequest.setBase( new Dn( baseDn ) ); searchRequest.setFilter( filter ); searchRequest.setScope( scope ); searchRequest.setTypesOnly( attrsOnly ); searchRequest.addAttributes( attrs ); SearchCursor result = connection.search( searchRequest ); Entry entry = result.getEntry(); if ( result.next() ) { throw new LdapException( "searchNode failed to return unique record for LDAP search of base DN [" + baseDn + "] filter [" + filter + "]" ); } return entry; }
Example #3
Source File: LdapNetworkConnection.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public SearchFuture searchAsync( Dn baseDn, String filter, SearchScope scope, String... attributes ) throws LdapException { // Create a new SearchRequest object SearchRequest searchRequest = new SearchRequestImpl(); searchRequest.setBase( baseDn ); searchRequest.setFilter( filter ); searchRequest.setScope( scope ); searchRequest.addAttributes( attributes ); searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS ); // Process the request in blocking mode return searchAsync( searchRequest ); }
Example #4
Source File: SearchRequestHandler.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * Handle the replication request. */ private void handleReplication( LdapSession session, SearchRequest searchRequest ) throws LdapException { if ( replicationReqHandler != null ) { replicationReqHandler.handleSyncRequest( session, searchRequest ); } else { // Replication is not allowed on this server. generate a error message LOG.warn( "This server does not allow replication" ); LdapResult result = searchRequest.getResultResponse().getLdapResult(); result.setDiagnosticMessage( "Replication is not allowed on this server" ); result.setResultCode( ResultCodeEnum.OTHER ); session.getIoSession().write( searchRequest.getResultResponse() ); return; } }
Example #5
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test parsing of a request with scope attribute to BaseObject value * @throws NamingException */ @Test public void testRequestWithScopeBaseObject() { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "request_with_scope_baseObject.xml" ).openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); assertEquals( SearchScope.OBJECT, searchRequest.getScope() ); }
Example #6
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test parsing of a request with scope attribute to SingleLevel value * @throws NamingException */ @Test public void testRequestWithScopeSingleLevel() { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "request_with_scope_singleLevel.xml" ).openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); assertEquals( SearchScope.ONELEVEL, searchRequest.getScope() ); }
Example #7
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
public EntryFilteringCursor search( SearchRequest searchRequest ) throws LdapException { SearchOperationContext searchContext = new SearchOperationContext( this, searchRequest ); searchContext.setSyncreplSearch( searchRequest.getControls().containsKey( SyncRequestValue.OID ) ); OperationManager operationManager = directoryService.getOperationManager(); EntryFilteringCursor cursor = null; try { cursor = operationManager.search( searchContext ); } catch ( LdapException e ) { searchRequest.getResultResponse().addAllControls( searchContext.getResponseControls() ); throw e; } searchRequest.getResultResponse().addAllControls( searchContext.getResponseControls() ); return cursor; }
Example #8
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test parsing of a request with derefAliases attribute to derefFindingBaseObj value * @throws NamingException */ @Test public void testRequestWithDerefAliasesDerefFindingBaseObj() { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "request_with_derefAliases_derefFindingBaseObj.xml" ) .openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); assertEquals( AliasDerefMode.DEREF_FINDING_BASE_OBJ, searchRequest.getDerefAliases() ); }
Example #9
Source File: LdapDataProvider.java From directory-fortress-core with Apache License 2.0 | 6 votes |
/** * Perform normal ldap search specifying default batch size and max entries to return. * * @param connection is LdapConnection object used for all communication with host. * @param baseDn contains address of distinguished name to begin ldap search * @param scope indicates depth of search starting at basedn. 0 (base dn), * 1 (one level down) or 2 (infinite) are valid values. * @param filter contains the search criteria * @param attrs is the requested list of attritubutes to return from directory search. * @param attrsOnly if true pull back attribute names only. * @param maxEntries specifies the maximum number of entries to return in this search query. * @return result set containing ldap entries returned from directory. * @throws LdapException thrown in the event of error in ldap client or server code. */ protected SearchCursor search( LdapConnection connection, String baseDn, SearchScope scope, String filter, String[] attrs, boolean attrsOnly, int maxEntries ) throws LdapException { COUNTERS.incrementSearch(); SearchRequest searchRequest = new SearchRequestImpl(); searchRequest.setBase( new Dn( baseDn ) ); searchRequest.setFilter( filter ); searchRequest.setScope( scope ); searchRequest.setSizeLimit( maxEntries ); searchRequest.setTypesOnly( attrsOnly ); searchRequest.addAttributes( attrs ); return connection.search( searchRequest ); }
Example #10
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test parsing of a request with the timeLimit (optional) attribute * @throws NamingException */ @Test public void testRequestWithTimeLimitAttribute() { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "request_with_timeLimit_attribute.xml" ).openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); assertEquals( 60, searchRequest.getTimeLimit() ); }
Example #11
Source File: StoreInitial.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public void action( LdapMessageContainer<SearchRequest> container ) throws DecoderException { TLV tlv = container.getCurrentTLV(); // Store the value. SubstringFilter substringFilter = ( SubstringFilter ) container.getTerminalFilter(); if ( tlv.getLength() == 0 ) { String msg = I18n.err( I18n.ERR_05154_EMPTY_SUBSTRING_INITIAL_FILTER_PDU ); LOG.error( msg ); throw new DecoderException( msg ); } substringFilter.setInitialSubstrings( Strings.utf8ToString( tlv.getValue().getData() ) ); // We now have to get back to the nearest filter which is // not terminal. container.unstackFilters(); }
Example #12
Source File: LdapNetworkConnection.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public SearchCursor search( SearchRequest searchRequest ) throws LdapException { if ( searchRequest == null ) { String msg = I18n.err( I18n.ERR_04130_CANNOT_PROCESS_NULL_SEARCH_REQ ); if ( LOG.isDebugEnabled() ) { LOG.debug( msg ); } throw new IllegalArgumentException( msg ); } SearchFuture searchFuture = searchAsync( searchRequest ); long searchTimeout = getTimeout( timeout, searchRequest.getTimeLimit() ); return new SearchCursorImpl( searchFuture, searchTimeout, TimeUnit.MILLISECONDS ); }
Example #13
Source File: StoreMatchValue.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public void action( LdapMessageContainer<SearchRequest> container ) { TLV tlv = container.getCurrentTLV(); // Store the value. ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) container.getTerminalFilter(); byte[] value = tlv.getValue().getData(); extensibleMatchFilter.setMatchValue( new Value( value ) ); // unstack the filters if needed container.unstackFilters(); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_05156_STORED_MATCH_VALUE, value ) ); } }
Example #14
Source File: LdapConnectionTemplate.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public <T> T searchFirst( SearchRequest searchRequest, EntryMapper<T> entryMapper ) { // in case the caller did not set size limit, we cache original value, // set to 1, then set back to original value before returning... long originalSizeLimit = searchRequest.getSizeLimit(); try { searchRequest.setSizeLimit( 1 ); List<T> entries = search( searchRequest, entryMapper ); return entries.isEmpty() ? null : entries.get( 0 ); } finally { searchRequest.setSizeLimit( originalSizeLimit ); } }
Example #15
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test parsing of a request with an Or Filter */ @Test public void testRequestWithOrFilter() { Dsmlv2Parser parser = null; try { parser = newParser(); parser .setInput( SearchRequestTest.class.getResource( "filters/request_with_or.xml" ).openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); ExprNode filter = searchRequest.getFilter(); assertTrue( filter instanceof OrNode ); }
Example #16
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test parsing of a request with an And Filter */ @Test public void testRequestWithAndFilter() { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "filters/request_with_and.xml" ).openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); ExprNode filter = searchRequest.getFilter(); assertTrue( filter instanceof AndNode ); }
Example #17
Source File: InitApproxMatchFilter.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public void action( LdapMessageContainer<SearchRequest> container ) throws DecoderException { // We can allocate the Attribute Value Assertion Filter filter = new AttributeValueAssertionFilter( container.getCurrentTLV().getId(), LdapCodecConstants.APPROX_MATCH_FILTER ); container.addCurrentFilter( filter ); // Store the filter structure that still has to be // fulfilled container.setTerminalFilter( filter ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_05142_INITIALIZE_APPROX_FILTER ) ); } }
Example #18
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test parsing of a request with derefAliases attribute to neverDerefAliases value * @throws NamingException */ @Test public void testRequestWithDerefAliasesNeverDerefAliases() { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "request_with_derefAliases_neverDerefAliases.xml" ) .openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); assertEquals( AliasDerefMode.NEVER_DEREF_ALIASES, searchRequest.getDerefAliases() ); }
Example #19
Source File: ModelFactoryImpl.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public SearchRequest newSearchRequest( Dn baseDn, FilterBuilder filter, SearchScope scope ) { return newSearchRequest( baseDn, filter.toString(), scope, ( String[] ) null ); }
Example #20
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test parsing of a request with an Equality Filter with base64 value */ @Test public void testRequestWithEqualityMatchFilterBase64Value() { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class .getResource( "filters/request_with_equalityMatch_base64_value.xml" ).openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); ExprNode filter = searchRequest.getFilter(); assertTrue( filter instanceof EqualityNode ); EqualityNode<?> equalityFilter = ( EqualityNode<?> ) filter; assertEquals( "sn", equalityFilter.getAttribute() ); assertEquals( "DSMLv2.0 rocks!!", equalityFilter.getValue().getString() ); }
Example #21
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test parsing of a request with a Substrings Filter with 1 empty Final element */ @Test public void testRequestWithSubstrings1EmptyFinal() { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "filters/request_with_substrings_1_empty_final.xml" ) .openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); ExprNode filter = searchRequest.getFilter(); assertTrue( filter instanceof SubstringNode ); SubstringNode substringFilter = ( SubstringNode ) filter; assertNull( substringFilter.getFinal() ); }
Example #22
Source File: InitAssertionValueFilter.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void action( LdapMessageContainer<SearchRequest> container ) { TLV tlv = container.getCurrentTLV(); // The value can be null. byte[] assertion = tlv.getValue().getData(); AttributeValueAssertionFilter terminalFilter = ( AttributeValueAssertionFilter ) container.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. container.unstackFilters(); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_05144_INITIALIZE_ASSERTION_FILTER ) ); } }
Example #23
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test parsing of a request with an Attributes element with 1 Attribute element * @throws NamingException */ @Test public void testRequestWithAttributes1Attribute() throws LdapException { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "request_with_attributes_1_attribute.xml" ) .openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); List<String> attributes = searchRequest.getAttributes(); assertEquals( 1, attributes.size() ); String attribute = attributes.get( 0 ); assertEquals( "sn", attribute ); }
Example #24
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test parsing of a request with an Attributes element with 2 Attribute elements * @throws NamingException */ @Test public void testRequestWithAttributes2Attribute() throws LdapException { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "request_with_attributes_2_attribute.xml" ) .openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); List<String> attributes = searchRequest.getAttributes(); assertEquals( 2, attributes.size() ); String attribute1 = attributes.get( 0 ); assertEquals( "sn", attribute1 ); String attribute2 = attributes.get( 1 ); assertEquals( "givenName", attribute2 ); }
Example #25
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test parsing of a request with typesOnly to 1 */ @Test public void testRequestWithExtensibleMatchWithDnAttributes1() { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "filters/request_with_extensibleMatch_with_dnAttributes_1.xml" ).openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); ExprNode filter = searchRequest.getFilter(); assertTrue( filter instanceof ExtensibleNode ); ExtensibleNode extensibleMatchFilter = ( ExtensibleNode ) filter; assertTrue( extensibleMatchFilter.hasDnAttributes() ); }
Example #26
Source File: SearchRequestMatchingRuleAssertionTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test the decoding of a SearchRequest with an extensible match and an * empty matching rule */ @Test public void testDecodeSearchRequestExtensibleMatchEmptyMatchingRule() throws DecoderException { byte[] asn1BER = new byte[] { 0x30, 0x3D, 0x02, 0x01, 0x04, // messageID 0x63, 0x38, 0x04, 0x1F, // baseObject LDAPDN, '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, 0x02, ( byte ) 0x81, 0x00, // matchingRule [1] MatchingRuleId OPTIONAL, 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription 0x04, 0x00 }; ByteBuffer stream = ByteBuffer.allocate( asn1BER.length ); stream.put( asn1BER ); stream.flip(); // Allocate a LdapMessage Container LdapMessageContainer<SearchRequest> ldapMessageContainer = new LdapMessageContainer<>( codec ); // Decode a SearchRequest message assertThrows( DecoderException.class, ( ) -> { Asn1Decoder.decode( stream, ldapMessageContainer ); } ); }
Example #27
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test parsing of a request with typesOnly to true */ @Test public void testRequestWithExtensibleMatchWithDnAttributesTrue() { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "filters/request_with_extensibleMatch_with_dnAttributes_true.xml" ).openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); ExprNode filter = searchRequest.getFilter(); assertTrue( filter instanceof ExtensibleNode ); ExtensibleNode extensibleMatchFilter = ( ExtensibleNode ) filter; assertTrue( extensibleMatchFilter.hasDnAttributes() ); }
Example #28
Source File: SearchRequestHandler.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * Manage the abandoned Paged Search (when paged size = 0). We have to * remove the cookie and its associated cursor from the session. */ private SearchResultDone abandonPagedSearch( LdapSession session, SearchRequest req ) throws Exception { PagedResults pagedSearchControl = ( PagedResults ) req.getControls().get( PagedResults.OID ); byte[] cookie = pagedSearchControl.getCookie(); if ( !Strings.isEmpty( cookie ) ) { // If the cookie is not null, we have to destroy the associated // cursor stored into the session (if any) int cookieValue = pagedSearchControl.getCookieValue(); PagedSearchContext psCookie = session.removePagedSearchContext( cookieValue ); pagedSearchControl.setCookie( psCookie.getCookie() ); pagedSearchControl.setSize( 0 ); pagedSearchControl.setCritical( true ); // Close the cursor Cursor<Entry> cursor = psCookie.getCursor(); if ( cursor != null ) { cursor.close(); } } else { pagedSearchControl.setSize( 0 ); pagedSearchControl.setCritical( true ); } // and return // DO NOT WRITE THE RESPONSE - JUST RETURN IT LdapResult ldapResult = req.getResultResponse().getLdapResult(); ldapResult.setResultCode( ResultCodeEnum.SUCCESS ); req.getResultResponse().addControl( pagedSearchControl ); return ( SearchResultDone ) req.getResultResponse(); }
Example #29
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test parsing of a request with an lessOrEqual Filter */ @Test public void testRequestWithLessOrEqualFilter() { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "filters/request_with_lessOrEqual.xml" ).openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); ExprNode filter = searchRequest.getFilter(); assertTrue( filter instanceof LessEqNode ); LessEqNode<?> lessOrEqFilter = ( LessEqNode<?> ) filter; assertEquals( "sn", lessOrEqFilter.getAttribute() ); assertEquals( "foobar", lessOrEqFilter.getValue().getString() ); }
Example #30
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test parsing of a request with an lessOrEqual Filter with Base64 value */ @Test public void testRequestWithLessOrEqualFilterBase64Value() { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "filters/request_with_lessOrEqual_base64_value.xml" ) .openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); ExprNode filter = searchRequest.getFilter(); assertTrue( filter instanceof LessEqNode ); LessEqNode<?> lessOrEqFilter = ( LessEqNode<?> ) filter; assertEquals( "sn", lessOrEqFilter.getAttribute() ); assertEquals( "DSMLv2.0 rocks!!", lessOrEqFilter.getValue().getString() ); }