Skip to content

Commit 8295935

Browse files
committed
Add LdapQueryBuilder#filter Docs
Closes gh-582
1 parent 9516edd commit 8295935

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

core/src/main/java/org/springframework/ldap/query/LdapQueryBuilder.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2005-2013 the original author or authors.
2+
* Copyright 2005-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -171,7 +171,7 @@ private void initRootContainer() {
171171
* validated or escaped in any way. <b>Never</b> use direct user input and use it concatenating strings
172172
* to use as LDAP filters. Doing so opens up for &quot;LDAP injection&quot;, where malicious user
173173
* may inject specifically constructed data to form filters at their convenience. When user input is used
174-
* consider using {@link #where(String)} or {@link #filter(String, Object...)} instead.
174+
* consider using {@link #where(String)}, {@link #filter(String, Object...)}, or {@link #filter(Filter)} instead.
175175
*
176176
* @param hardcodedFilter The hardcoded filter string to use in the search.
177177
* @return this instance.
@@ -183,6 +183,13 @@ public LdapQuery filter(String hardcodedFilter) {
183183
return this;
184184
}
185185

186+
/**
187+
* Specify the filter to use.
188+
*
189+
* @param filter The filter to use in the search.
190+
* @return this instance.
191+
* @throws IllegalStateException if a filter has already been specified.
192+
*/
186193
public LdapQuery filter(Filter filter) {
187194
initRootContainer();
188195
rootContainer.append(filter);

src/docs/asciidoc/index.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,8 @@ There may be occasions when you want to specify a hardcoded filter as input to a
13481348

13491349
* `filter(String filterFormat, String... params)`: Uses the specified string as input to `MessageFormat`, properly encoding the parameters and inserting them at the specified places in the filter string.
13501350

1351+
* `filter(Filter filter)`: Uses the specified filter.
1352+
13511353
You cannot mix the hardcoded filter methods with the `where` approach described earlier. It is either one or the other. If you specify a filter by using `filter()`, you get an exception if you try to call `where` afterwards.
13521354

13531355

0 commit comments

Comments
 (0)