Class LdapIdentityProvider
- java.lang.Object
-
- org.apache.jackrabbit.oak.security.authentication.ldap.impl.LdapIdentityProvider
-
- All Implemented Interfaces:
ExternalIdentityProvider,PrincipalNameResolver
public class LdapIdentityProvider extends Object implements ExternalIdentityProvider, PrincipalNameResolver
LdapIdentityProviderimplements an external identity provider that reads users and groups from an ldap source. Please refer toLdapProviderConfigfor configuration options.
-
-
Constructor Summary
Constructors Constructor Description LdapIdentityProvider()Default constructor for OSGiLdapIdentityProvider(@NotNull LdapProviderConfig config)Constructor for non-OSGi cases.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExternalUserauthenticate(@NotNull Credentials credentials)Authenticates the user represented by the given credentials and returns it.voidclose()Closes this provider and releases the internal pool.@NotNull StringfromExternalIdentityRef(@NotNull ExternalIdentityRef externalIdentityRef)Deduce the name of thePrincipalassociated with theExternalIdentityrepresented by the givenExternalIdentityRef.ExternalGroupgetGroup(@NotNull String name)Returns the group for the given (local) group name.ExternalIdentitygetIdentity(@NotNull ExternalIdentityRef ref)Returns the identity for the given reference ornullif it does not exist.@NotNull StringgetName()Returns the name of this provider.ExternalUsergetUser(@NotNull String userId)Returns the user for the given (local) id.@NotNull Iterator<ExternalGroup>listGroups()List all external groups.@NotNull Iterator<ExternalUser>listUsers()List all external users.
-
-
-
Constructor Detail
-
LdapIdentityProvider
public LdapIdentityProvider()
Default constructor for OSGi
-
LdapIdentityProvider
public LdapIdentityProvider(@NotNull @NotNull LdapProviderConfig config)Constructor for non-OSGi cases.- Parameters:
config- the configuration
-
-
Method Detail
-
close
public void close()
Closes this provider and releases the internal pool. This should be called by Non-OSGi users of this provider.
-
fromExternalIdentityRef
@NotNull public @NotNull String fromExternalIdentityRef(@NotNull @NotNull ExternalIdentityRef externalIdentityRef) throws ExternalIdentityException
Description copied from interface:PrincipalNameResolverDeduce the name of thePrincipalassociated with theExternalIdentityrepresented by the givenExternalIdentityRef.- Specified by:
fromExternalIdentityRefin interfacePrincipalNameResolver- Parameters:
externalIdentityRef- A validExternalIdentityRefto an existingExternalIdentity- Returns:
- The name of the
Principalassociated with the external identity referenced by the givenexternalIdentityRef. - Throws:
ExternalIdentityException- If the reference is not valid or another error occurs.
-
getName
@NotNull public @NotNull String getName()
Description copied from interface:ExternalIdentityProviderReturns the name of this provider.- Specified by:
getNamein interfaceExternalIdentityProvider- Returns:
- the provider name.
-
getIdentity
public ExternalIdentity getIdentity(@NotNull @NotNull ExternalIdentityRef ref) throws ExternalIdentityException
Description copied from interface:ExternalIdentityProviderReturns the identity for the given reference ornullif it does not exist. The provider should check if theprovider namematches his own name or isnulland should not return a foreign identity.- Specified by:
getIdentityin interfaceExternalIdentityProvider- Parameters:
ref- the reference- Returns:
- an identity or
null - Throws:
ExternalIdentityException- if an error occurs.
-
getUser
public ExternalUser getUser(@NotNull @NotNull String userId) throws ExternalIdentityException
Description copied from interface:ExternalIdentityProviderReturns the user for the given (local) id. if the user does not existnullis returned.- Specified by:
getUserin interfaceExternalIdentityProvider- Parameters:
userId- the user id.- Returns:
- the user or
null - Throws:
ExternalIdentityException- if an error occurs.
-
getGroup
public ExternalGroup getGroup(@NotNull @NotNull String name) throws ExternalIdentityException
Description copied from interface:ExternalIdentityProviderReturns the group for the given (local) group name. if the group does not existnullis returned.- Specified by:
getGroupin interfaceExternalIdentityProvider- Parameters:
name- the group name- Returns:
- the group or
null - Throws:
ExternalIdentityException- if an error occurs.
-
listUsers
@NotNull public @NotNull Iterator<ExternalUser> listUsers() throws ExternalIdentityException
Description copied from interface:ExternalIdentityProviderList all external users.- Specified by:
listUsersin interfaceExternalIdentityProvider- Returns:
- an iterator over all external users
- Throws:
ExternalIdentityException- if an error occurs.
-
listGroups
@NotNull public @NotNull Iterator<ExternalGroup> listGroups() throws ExternalIdentityException
Description copied from interface:ExternalIdentityProviderList all external groups.- Specified by:
listGroupsin interfaceExternalIdentityProvider- Returns:
- an iterator over all external groups
- Throws:
ExternalIdentityException- if an error occurs.
-
authenticate
public ExternalUser authenticate(@NotNull @NotNull Credentials credentials) throws ExternalIdentityException, LoginException
Description copied from interface:ExternalIdentityProviderAuthenticates the user represented by the given credentials and returns it. If the user does not exist in this provider,nullis returned. If the authentication fails, a LoginException is thrown.- Specified by:
authenticatein interfaceExternalIdentityProvider- Parameters:
credentials- the credentials- Returns:
- the user or
null - Throws:
ExternalIdentityException- if an error occursLoginException- if the user could not be authenticated
-
-