forked from spring-projects/spring-ldap
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes spring-projectsgh-675
- Loading branch information
Showing
21 changed files
with
4,784 additions
and
128 deletions.
There are no files selected for viewing
569 changes: 569 additions & 0 deletions
569
core/src/main/java/org/springframework/ldap/core/LdapClient.java
Large diffs are not rendered by default.
Oops, something went wrong.
682 changes: 682 additions & 0 deletions
682
core/src/main/java/org/springframework/ldap/core/SpringLdapClient.java
Large diffs are not rendered by default.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
core/src/main/java/org/springframework/ldap/core/SpringLdapClientBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package org.springframework.ldap.core; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
import javax.naming.NameNotFoundException; | ||
import javax.naming.SizeLimitExceededException; | ||
import javax.naming.directory.SearchControls; | ||
|
||
class SpringLdapClientBuilder implements LdapClient.Builder { | ||
private ContextSource contextSource; | ||
|
||
private Supplier<SearchControls> searchControlsSupplier = () -> { | ||
SearchControls controls = new SearchControls(); | ||
controls.setSearchScope(SearchControls.SUBTREE_SCOPE); | ||
controls.setCountLimit(0); | ||
controls.setTimeLimit(0); | ||
return controls; | ||
}; | ||
|
||
private boolean ignorePartialResultException = false; | ||
|
||
private boolean ignoreNameNotFoundException = false; | ||
|
||
private boolean ignoreSizeLimitExceededException = true; | ||
|
||
SpringLdapClientBuilder() {} | ||
|
||
SpringLdapClientBuilder(ContextSource contextSource, | ||
Supplier<SearchControls> searchControlsSupplier) { | ||
this.contextSource = contextSource; | ||
this.searchControlsSupplier = searchControlsSupplier; | ||
} | ||
|
||
@Override | ||
public SpringLdapClientBuilder contextSource(ContextSource contextSource) { | ||
this.contextSource = contextSource; | ||
return this; | ||
} | ||
|
||
@Override | ||
public SpringLdapClientBuilder defaultSearchControls(Supplier<SearchControls> searchControlsSupplier) { | ||
this.searchControlsSupplier = searchControlsSupplier; | ||
return this; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public LdapClient.Builder ignorePartialResultException(boolean ignore) { | ||
this.ignorePartialResultException = ignore; | ||
return this; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public LdapClient.Builder ignoreNameNotFoundException(boolean ignore) { | ||
this.ignoreNameNotFoundException = ignore; | ||
return this; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public LdapClient.Builder ignoreSizeLimitExceededException(boolean ignore) { | ||
this.ignoreSizeLimitExceededException = ignore; | ||
return this; | ||
} | ||
|
||
@Override | ||
public SpringLdapClientBuilder apply(Consumer<LdapClient.Builder> builderConsumer) { | ||
builderConsumer.accept(this); | ||
return this; | ||
} | ||
|
||
@Override | ||
public SpringLdapClientBuilder clone() { | ||
return new SpringLdapClientBuilder(this.contextSource, this.searchControlsSupplier); | ||
} | ||
|
||
@Override | ||
public LdapClient build() { | ||
SpringLdapClient client = new SpringLdapClient(this.contextSource, this.searchControlsSupplier); | ||
client.setIgnorePartialResultException(this.ignorePartialResultException); | ||
client.setIgnoreSizeLimitExceededException(this.ignoreSizeLimitExceededException); | ||
client.setIgnoreNameNotFoundException(this.ignoreNameNotFoundException); | ||
return client; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.