@Service public class LdapIdentityProvider extends java.lang.Object implements ExternalIdentityProvider, PrincipalNameResolver
LdapIdentityProvider
implements an external identity provider that reads users and groups from an ldap
source.
Please refer to LdapProviderConfig
for configuration options.Constructor and Description |
---|
LdapIdentityProvider()
Default constructor for OSGi
|
LdapIdentityProvider(@NotNull LdapProviderConfig config)
Constructor for non-OSGi cases.
|
Modifier and Type | Method and Description |
---|---|
ExternalUser |
authenticate(@NotNull Credentials credentials)
Authenticates the user represented by the given credentials and returns it.
|
void |
close()
Closes this provider and releases the internal pool.
|
@NotNull java.lang.String |
fromExternalIdentityRef(@NotNull ExternalIdentityRef externalIdentityRef)
Deduce the name of the
Principal associated with the
ExternalIdentity represented by the given ExternalIdentityRef . |
ExternalGroup |
getGroup(@NotNull java.lang.String name)
Returns the group for the given (local) group name.
|
ExternalIdentity |
getIdentity(@NotNull ExternalIdentityRef ref)
Returns the identity for the given reference or
null if it does not exist. |
@NotNull java.lang.String |
getName()
Returns the name of this provider.
|
ExternalUser |
getUser(@NotNull java.lang.String userId)
Returns the user for the given (local) id.
|
@NotNull java.util.Iterator<ExternalGroup> |
listGroups()
List all external groups.
|
@NotNull java.util.Iterator<ExternalUser> |
listUsers()
List all external users.
|
public LdapIdentityProvider()
public LdapIdentityProvider(@NotNull @NotNull LdapProviderConfig config)
config
- the configurationpublic void close()
@NotNull public @NotNull java.lang.String fromExternalIdentityRef(@NotNull @NotNull ExternalIdentityRef externalIdentityRef) throws ExternalIdentityException
PrincipalNameResolver
Principal
associated with the
ExternalIdentity
represented by the given ExternalIdentityRef
.fromExternalIdentityRef
in interface PrincipalNameResolver
externalIdentityRef
- A valid ExternalIdentityRef
to an existing ExternalIdentity
Principal
associated with the external identity referenced by the given externalIdentityRef
.ExternalIdentityException
- If the reference is not valid or another error occurs.@NotNull public @NotNull java.lang.String getName()
ExternalIdentityProvider
getName
in interface ExternalIdentityProvider
public ExternalIdentity getIdentity(@NotNull @NotNull ExternalIdentityRef ref) throws ExternalIdentityException
ExternalIdentityProvider
null
if it does not exist. The provider should check if
the provider name
matches his own name or is null
and
should not return a foreign identity.getIdentity
in interface ExternalIdentityProvider
ref
- the referencenull
ExternalIdentityException
- if an error occurs.public ExternalUser getUser(@NotNull @NotNull java.lang.String userId) throws ExternalIdentityException
ExternalIdentityProvider
null
is returned.getUser
in interface ExternalIdentityProvider
userId
- the user id.null
ExternalIdentityException
- if an error occurs.public ExternalGroup getGroup(@NotNull @NotNull java.lang.String name) throws ExternalIdentityException
ExternalIdentityProvider
null
is returned.getGroup
in interface ExternalIdentityProvider
name
- the group namenull
ExternalIdentityException
- if an error occurs.@NotNull public @NotNull java.util.Iterator<ExternalUser> listUsers() throws ExternalIdentityException
ExternalIdentityProvider
listUsers
in interface ExternalIdentityProvider
ExternalIdentityException
- if an error occurs.@NotNull public @NotNull java.util.Iterator<ExternalGroup> listGroups() throws ExternalIdentityException
ExternalIdentityProvider
listGroups
in interface ExternalIdentityProvider
ExternalIdentityException
- if an error occurs.public ExternalUser authenticate(@NotNull @NotNull Credentials credentials) throws ExternalIdentityException, javax.security.auth.login.LoginException
ExternalIdentityProvider
null
is returned. If the authentication fails, a LoginException is thrown.authenticate
in interface ExternalIdentityProvider
credentials
- the credentialsnull
ExternalIdentityException
- if an error occursjavax.security.auth.login.LoginException
- if the user could not be authenticatedCopyright © 2012–2022 The Apache Software Foundation. All rights reserved.