@Component(value="ldapAuthorizationGenerator")
public class LdapAuthorizationGenerator
extends java.lang.Object
implements org.pac4j.core.authorization.AuthorizationGenerator<org.pac4j.core.profile.CommonProfile>
AuthorizationGenerator implementation that obtains user roles from an LDAP search.
Two searches are performed by this component for every user details lookup:
setAllowMultipleResults(boolean) property may be toggled to change that behavior.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_ROLE_PREFIX
Default role prefix.
|
| Constructor and Description |
|---|
LdapAuthorizationGenerator()
Instantiates a new Ldap authorization generator.
|
LdapAuthorizationGenerator(org.ldaptive.ConnectionFactory factory,
org.ldaptive.SearchExecutor userSearchExecutor,
org.ldaptive.SearchExecutor roleSearchExecutor,
java.lang.String userAttributeName,
java.lang.String roleAttributeName)
Creates a new instance with the given required parameters.
|
| Modifier and Type | Method and Description |
|---|---|
void |
generate(org.pac4j.core.profile.CommonProfile profile) |
void |
setAllowMultipleResults(boolean allowMultiple)
Sets whether to allow multiple search results for user details given a username.
|
void |
setRolePrefix(java.lang.String rolePrefix)
Sets the prefix appended to the uppercase
roleAttributeName (Spring Security convention). |
public static final java.lang.String DEFAULT_ROLE_PREFIX
public LdapAuthorizationGenerator()
public LdapAuthorizationGenerator(org.ldaptive.ConnectionFactory factory,
org.ldaptive.SearchExecutor userSearchExecutor,
org.ldaptive.SearchExecutor roleSearchExecutor,
java.lang.String userAttributeName,
java.lang.String roleAttributeName)
factory - Source of LDAP connections for searches.userSearchExecutor - Executes the LDAP search for user data.roleSearchExecutor - Executes the LDAP search for role data.userAttributeName - Name of LDAP attribute that contains username for user details.roleAttributeName - Name of LDAP attribute that contains role membership data for the user.public void setRolePrefix(java.lang.String rolePrefix)
roleAttributeName (Spring Security convention).
The default value "ROLE_" is sufficient in most cases.rolePrefix - Role prefix.public void setAllowMultipleResults(boolean allowMultiple)
allowMultiple - True to allow multiple search results in which case the first result
returned is used to construct user details, or false to indicate that
a runtime exception should be raised on multiple search results for user details.public void generate(org.pac4j.core.profile.CommonProfile profile)
generate in interface org.pac4j.core.authorization.AuthorizationGenerator<org.pac4j.core.profile.CommonProfile>