Class LdapIdentityProviderSession
- java.lang.Object
-
- org.camunda.bpm.identity.impl.ldap.LdapIdentityProviderSession
-
- All Implemented Interfaces:
ReadOnlyIdentityProvider
,Session
public class LdapIdentityProviderSession extends Object implements ReadOnlyIdentityProvider
LDAP
ReadOnlyIdentityProvider
.- Author:
- Daniel Meyer
-
-
Field Summary
Fields Modifier and Type Field Description protected LdapContext
initialContext
protected LdapConfiguration
ldapConfiguration
-
Constructor Summary
Constructors Constructor Description LdapIdentityProviderSession(LdapConfiguration ldapConfiguration)
-
Method Summary
-
-
-
Field Detail
-
ldapConfiguration
protected LdapConfiguration ldapConfiguration
-
initialContext
protected LdapContext initialContext
-
-
Constructor Detail
-
LdapIdentityProviderSession
public LdapIdentityProviderSession(LdapConfiguration ldapConfiguration)
-
-
Method Detail
-
closeLdapCtx
protected void closeLdapCtx(LdapContext context)
-
openContext
protected InitialLdapContext openContext(String userDn, String password)
-
ensureContextInitialized
protected void ensureContextInitialized()
-
findUserById
public User findUserById(String userId)
- Specified by:
findUserById
in interfaceReadOnlyIdentityProvider
- Returns:
- a
User
object for the given user id or null if no such user exists.
-
createUserQuery
public UserQuery createUserQuery()
- Specified by:
createUserQuery
in interfaceReadOnlyIdentityProvider
- Returns:
- a
UserQuery
object which can be used for querying for users.
-
createUserQuery
public UserQueryImpl createUserQuery(CommandContext commandContext)
- Specified by:
createUserQuery
in interfaceReadOnlyIdentityProvider
- Returns:
- a
UserQuery
object which can be used in the current command context
-
createNativeUserQuery
public NativeUserQuery createNativeUserQuery()
Description copied from interface:ReadOnlyIdentityProvider
Creates aNativeUserQuery
that allows to select users with native queries.- Specified by:
createNativeUserQuery
in interfaceReadOnlyIdentityProvider
- Returns:
- NativeUserQuery
-
findUserCountByQueryCriteria
public long findUserCountByQueryCriteria(LdapUserQueryImpl query)
-
findUserByQueryCriteria
public List<User> findUserByQueryCriteria(LdapUserQueryImpl query)
-
findUsersByGroupId
protected List<User> findUsersByGroupId(LdapUserQueryImpl query)
-
findUsersWithoutGroupId
public List<User> findUsersWithoutGroupId(LdapUserQueryImpl query, String userBaseDn, boolean ignorePagination)
-
checkPassword
public boolean checkPassword(String userId, String password)
- Specified by:
checkPassword
in interfaceReadOnlyIdentityProvider
- Returns:
- 'true' if the password matches the
-
getUserSearchFilter
protected String getUserSearchFilter(LdapUserQueryImpl query)
-
findGroupById
public Group findGroupById(String groupId)
- Specified by:
findGroupById
in interfaceReadOnlyIdentityProvider
- Returns:
- a
Group
object for the given group id or null if no such group exists.
-
createGroupQuery
public GroupQuery createGroupQuery()
- Specified by:
createGroupQuery
in interfaceReadOnlyIdentityProvider
- Returns:
- a
GroupQuery
object which can be used for querying for groups.
-
createGroupQuery
public GroupQuery createGroupQuery(CommandContext commandContext)
- Specified by:
createGroupQuery
in interfaceReadOnlyIdentityProvider
- Returns:
- a
GroupQuery
object which can be used for querying for groups and can be reused in the current command context.
-
findGroupCountByQueryCriteria
public long findGroupCountByQueryCriteria(LdapGroupQuery ldapGroupQuery)
-
findGroupByQueryCriteria
public List<Group> findGroupByQueryCriteria(LdapGroupQuery query)
-
getGroupSearchFilter
protected String getGroupSearchFilter(LdapGroupQuery query)
-
getStringAttributeValue
protected String getStringAttributeValue(String attrName, Attributes attributes) throws NamingException
- Throws:
NamingException
-
addFilter
protected void addFilter(String attributeName, String attributeValue, StringWriter writer)
-
transformUser
protected LdapUserEntity transformUser(SearchResult result) throws NamingException
- Throws:
NamingException
-
transformGroup
protected GroupEntity transformGroup(SearchResult result) throws NamingException
- Throws:
NamingException
-
getSortingControls
protected List<Control> getSortingControls(AbstractQuery<?,?> query, StringBuilder resultLogger)
Return the list of Controls requested in the query. Query may be run on USERS or on GROUP- Parameters:
query
- query asks, contains the order by requested- Returns:
- list of control to send to LDAP
-
isAuthenticatedUser
protected boolean isAuthenticatedUser(UserEntity user)
- Returns:
- true if the passed-in user is currently authenticated
-
isAuthorized
protected boolean isAuthorized(Permission permission, Resource resource, String resourceId)
-
initializeControls
protected void initializeControls(AbstractQuery<?,?> query, StringBuilder resultLogger) throws NamingException
Initializes paged results and sort controls. Might not be supported by all LDAP implementations.- Throws:
NamingException
-
isNextPageDetected
protected boolean isNextPageDetected(StringBuilder resultLogger)
Check in the context if we reach the last page on the query- Parameters:
resultLogger
- Logger to send information- Returns:
- new page detected
-
isPaginationSupported
protected boolean isPaginationSupported()
-
getPageSize
protected Integer getPageSize()
Return the pageSize. Returns null if pagination is disabled.- Returns:
- the pageSize
-
createTenantQuery
public TenantQuery createTenantQuery()
- Specified by:
createTenantQuery
in interfaceReadOnlyIdentityProvider
- Returns:
- a
TenantQuery
object which can be used for querying for tenants.
-
createTenantQuery
public TenantQuery createTenantQuery(CommandContext commandContext)
- Specified by:
createTenantQuery
in interfaceReadOnlyIdentityProvider
- Returns:
- a
TenantQuery
object which can be used for querying for tenants and can be reused in the current command context.
-
findTenantById
public Tenant findTenantById(String id)
- Specified by:
findTenantById
in interfaceReadOnlyIdentityProvider
- Returns:
- a
Tenant
object for the given id or null if no such tenant exists.
-
-