@Test public void searchForSingleEntryInternalAllowsReferrals() throws Exception { String base = ""; String filter = ""; String searchResultName = "ldap://example.com/dc=springframework,dc=org"; Object[] params = new Object[] {}; DirContextAdapter searchResultObject = mock(DirContextAdapter.class); when( ctx.search(any(DistinguishedName.class), eq(filter), eq(params), searchControls.capture())).thenReturn(resultsEnum); when(resultsEnum.hasMore()).thenReturn(true, false); when(resultsEnum.next()).thenReturn(searchResult); when(searchResult.getObject()).thenReturn(searchResultObject); SpringSecurityLdapTemplate.searchForSingleEntryInternal(ctx, mock(SearchControls.class), base, filter, params); assertThat(searchControls.getValue().getReturningObjFlag()).isTrue(); }
/** * Make sure the returnObjFlag is set in the supplied SearchControls. Set it * and log if it's not set. * * @param controls the SearchControls to check. */ private void assureReturnObjFlagSet(SearchControls controls) { Assert.notNull(controls, "controls must not be null"); if (!controls.getReturningObjFlag()) { LOG.debug("The returnObjFlag of supplied SearchControls is not set" + " but a ContextMapper is used - setting flag to true"); controls.setReturningObjFlag(true); } }
/** * Make sure the returnObjFlag is set in the supplied SearchControls. Set it * and log if it's not set. * * @param controls the SearchControls to check. */ private void assureReturnObjFlagSet(SearchControls controls) { Assert.notNull(controls, "controls must not be null"); if (!controls.getReturningObjFlag()) { LOG.debug("The returnObjFlag of supplied SearchControls is not set" + " but a ContextMapper is used - setting flag to true"); controls.setReturningObjFlag(true); } }
/** * Make sure the returnObjFlag is set in the supplied SearchControls. Set it * and log if it's not set. * * @param controls the SearchControls to check. */ private void assureReturnObjFlagSet(SearchControls controls) { Assert.notNull(controls, "controls must not be null"); if (!controls.getReturningObjFlag()) { LOG.debug("The returnObjFlag of supplied SearchControls is not set" + " but a ContextMapper is used - setting flag to true"); controls.setReturningObjFlag(true); } }
/** * Make sure the returnObjFlag is set in the supplied SearchControls. Set it * and log if it's not set. * * @param controls * the SearchControls to check. */ private void assureReturnObjFlagSet(SearchControls controls) { Validate.notNull(controls); if (!controls.getReturningObjFlag()) { log.info("The returnObjFlag of supplied SearchControls is not set" + " but a ContextMapper is used - setting flag to true"); controls.setReturningObjFlag(true); } }
/** * Make sure the returnObjFlag is set in the supplied SearchControls. Set it * and log if it's not set. * * @param controls the SearchControls to check. */ private void assureReturnObjFlagSet(SearchControls controls) { Assert.notNull(controls, "controls must not be null"); if (!controls.getReturningObjFlag()) { LOG.debug("The returnObjFlag of supplied SearchControls is not set" + " but a ContextMapper is used - setting flag to true"); controls.setReturningObjFlag(true); } }
/** * Make sure the returnObjFlag is set in the supplied SearchControls. Set it * and log if it's not set. * * @param controls * the SearchControls to check. */ private void assureReturnObjFlagSet(SearchControls controls) { Validate.notNull(controls); if (!controls.getReturningObjFlag()) { log.info("The returnObjFlag of supplied SearchControls is not set" + " but a ContextMapper is used - setting flag to true"); controls.setReturningObjFlag(true); } }
LDAPUserRegistry.logger.debug(" Return result limit: " + searchControls.getCountLimit()); LDAPUserRegistry.logger.debug(" DerefLink: " + searchControls.getDerefLinkFlag()); LDAPUserRegistry.logger.debug(" Return named object: " + searchControls.getReturningObjFlag()); LDAPUserRegistry.logger.debug(" Time limit for search: " + searchControls.getTimeLimit()); LDAPUserRegistry.logger.debug(" Attributes to return: " + returningAttributes.length + " items.");
LDAPUserRegistry.logger.debug(" Return result limit: " + searchControls.getCountLimit()); LDAPUserRegistry.logger.debug(" DerefLink: " + searchControls.getDerefLinkFlag()); LDAPUserRegistry.logger.debug(" Return named object: " + searchControls.getReturningObjFlag()); LDAPUserRegistry.logger.debug(" Time limit for search: " + searchControls.getTimeLimit()); LDAPUserRegistry.logger.debug(" Attributes to return: " + returningAttributes.length + " items.");
/** * Creates a new instance of SearchOperationContext. * * @param session The session to use * @param dn the dn of the search base * @param filter the filter AST to use for the search * @param searchControls the search controls */ public SearchOperationContext( CoreSession session, Dn dn, ExprNode filter, SearchControls searchControls ) { super( session, dn, searchControls.getReturningAttributes() ); this.filter = filter; scope = SearchScope.getSearchScope( searchControls.getSearchScope() ); timeLimit = searchControls.getTimeLimit(); sizeLimit = searchControls.getCountLimit(); typesOnly = searchControls.getReturningObjFlag(); if ( session != null ) { setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.SEARCH ) ); } }
@Override public boolean matches(Object item) { if (item instanceof SearchControls) { SearchControls s1 = (SearchControls) item; return controls.getSearchScope() == s1.getSearchScope() && controls.getReturningObjFlag() == s1.getReturningObjFlag() && controls.getDerefLinkFlag() == s1.getDerefLinkFlag() && controls.getCountLimit() == s1.getCountLimit() && controls.getTimeLimit() == s1.getTimeLimit() && controls.getReturningAttributes() == s1.getReturningAttributes(); } else { throw new IllegalArgumentException(); } }
referralSearchControls.setTimeLimit( searchControls.getTimeLimit() ); referralSearchControls.setDerefLinkFlag( searchControls.getDerefLinkFlag() ); referralSearchControls.setReturningObjFlag( searchControls.getReturningObjFlag() );
/** * Creates a {@link SearchParams} from JNDI search controls. * * @param searchControls the search controls * @param aliasDerefMode the alias deref mode * @return the search params */ public static SearchParams toSearchParams( SearchControls searchControls, AliasDerefMode aliasDerefMode ) { SearchParams searchParams = new SearchParams(); searchParams.setAliasDerefMode( aliasDerefMode ); searchParams.setTimeLimit( searchControls.getTimeLimit() ); searchParams.setSizeLimit( searchControls.getCountLimit() ); searchParams.setScope( SearchScope.getSearchScope( searchControls.getSearchScope() ) ); searchParams.setTypesOnly( searchControls.getReturningObjFlag() ); if ( searchControls.getReturningAttributes() != null ) { for ( String returningAttribute : searchControls.getReturningAttributes() ) { searchParams.addReturningAttributes( returningAttribute ); } } return searchParams; }
public static SearchParams toSearchParams( SearchControls searchControls, AliasDerefMode aliasDerefMode ) { SearchParams searchParams = new SearchParams(); searchParams.setAliasDerefMode( aliasDerefMode ); searchParams.setTimeLimit( searchControls.getTimeLimit() ); searchParams.setSizeLimit( searchControls.getCountLimit() ); searchParams.setScope( SearchScope.getSearchScope( searchControls.getSearchScope() ) ); searchParams.setTypesOnly( searchControls.getReturningObjFlag() ); if ( searchControls.getReturningAttributes() != null ) { for ( String returningAttribute : searchControls.getReturningAttributes() ) { searchParams.addReturningAttributes( returningAttribute ); } } searchParams.searchControls = searchControls; return searchParams; }
/** * Creates a {@link SearchParams} from JNDI search controls. * * @param searchControls the search controls * @param aliasDerefMode the alias deref mode * @return the search params */ public static SearchParams toSearchParams( SearchControls searchControls, AliasDerefMode aliasDerefMode ) { SearchParams searchParams = new SearchParams(); searchParams.setAliasDerefMode( aliasDerefMode ); searchParams.setTimeLimit( searchControls.getTimeLimit() ); searchParams.setSizeLimit( searchControls.getCountLimit() ); searchParams.setScope( SearchScope.getSearchScope( searchControls.getSearchScope() ) ); searchParams.setTypesOnly( searchControls.getReturningObjFlag() ); if ( searchControls.getReturningAttributes() != null ) { for ( String returningAttribute : searchControls.getReturningAttributes() ) { searchParams.addReturningAttributes( returningAttribute ); } } return searchParams; }
referralSearchControls.setTimeLimit( searchControls.getTimeLimit() ); referralSearchControls.setDerefLinkFlag( searchControls.getDerefLinkFlag() ); referralSearchControls.setReturningObjFlag( searchControls.getReturningObjFlag() );
/** * Creates a {@link SearchParams} from JNDI search controls. * * @param searchControls the search controls * @param aliasDerefMode the alias deref mode * @return the search params */ public static SearchParams toSearchParams( SearchControls searchControls, AliasDerefMode aliasDerefMode ) { SearchParams searchParams = new SearchParams(); searchParams.setAliasDerefMode( aliasDerefMode ); searchParams.setTimeLimit( searchControls.getTimeLimit() ); searchParams.setSizeLimit( searchControls.getCountLimit() ); searchParams.setScope( SearchScope.getSearchScope( searchControls.getSearchScope() ) ); searchParams.setTypesOnly( searchControls.getReturningObjFlag() ); if ( searchControls.getReturningAttributes() != null ) { for ( String returningAttribute : searchControls.getReturningAttributes() ) { searchParams.addReturningAttributes( returningAttribute ); } } return searchParams; }