Class CmsUserDriver
- All Implemented Interfaces:
I_CmsDriver
,I_CmsUserDriver
- Direct Known Subclasses:
CmsUserDriver
,CmsUserDriver
,CmsUserDriver
,CmsUserDriver
,CmsUserDriver
,CmsUserDriver
,CmsUserDriver
- Since:
- 6.0.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected MessageDigest
A digest to encrypt the passwords.protected String
The algorithm used to encode passwords.protected String
The file.encoding to code passwords after encryption with digest.protected CmsDriverManager
The driver manager.protected CmsSqlManager
The SQL manager.static final String
The root path for organizational units.static final String
The internal request attribute to indicate that the password has not to be digested.Fields inherited from interface org.opencms.db.I_CmsDriver
AND_CONDITION, BEGIN_CONDITION, BEGIN_EXCLUDE_CONDITION, BEGIN_INCLUDE_CONDITION, END_CONDITION, OR_CONDITION
Fields inherited from interface org.opencms.db.I_CmsUserDriver
DRIVER_TYPE_ID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addResourceToOrganizationalUnit
(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, CmsResource resource) Adds a resource to the given organizational unit.long
countUsers
(CmsDbContext dbc, CmsUserSearchParameters searchParams) Counts the total number of users which match the given search criteria.void
createAccessControlEntry
(CmsDbContext dbc, CmsProject project, CmsUUID resource, CmsUUID principal, int allowed, int denied, int flags) Creates an access control entry.createGroup
(CmsDbContext dbc, CmsUUID groupId, String groupFqn, String description, int flags, String parentGroupFqn) Creates a new group.createOrganizationalUnit
(CmsDbContext dbc, String name, String description, int flags, CmsOrganizationalUnit parent, String associatedResource) Creates a new organizational unit.protected String
createRoleQuery
(String mainQuery, boolean includeSubOus, boolean readRoles) Returns a sql query to select groups.void
Creates the default root organizational unit.createUser
(CmsDbContext dbc, CmsUUID id, String userFqn, String password, String firstname, String lastname, String email, long lastlogin, int flags, long dateCreated, Map<String, Object> additionalInfos) Creates a new user.void
createUserInGroup
(CmsDbContext dbc, CmsUUID userId, CmsUUID groupId) Adds a user to a group.createUserQuery
(CmsUserSearchParameters searchParams, boolean countOnly) Creates a query for searching users.protected CmsUserQueryBuilder
Creates a new user query builder.void
deleteGroup
(CmsDbContext dbc, String groupFqn) Deletes a group.void
deleteOrganizationalUnit
(CmsDbContext dbc, CmsOrganizationalUnit organizationalUnit) Deletes an organizational unit.void
deleteUser
(CmsDbContext dbc, String userFqn) Deletes a user.void
deleteUserInfos
(CmsDbContext dbc, CmsUUID userId) Deletes the user additional information table.void
deleteUserInGroup
(CmsDbContext dbc, CmsUUID userId, CmsUUID groupId) Removes a user from a group.void
destroy()
Destroys this driver.boolean
existsGroup
(CmsDbContext dbc, String groupFqn) Tests if a group with the specified name exists.boolean
existsUser
(CmsDbContext dbc, String userFqn) Tests if a user with the specified name exists.void
fillDefaults
(CmsDbContext dbc) Initializes the default organizational units, users and groups.getGroups
(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, boolean includeSubOus, boolean readRoles) Returns all groups of the given organizational unit.getOrganizationalUnits
(CmsDbContext dbc, CmsOrganizationalUnit parent, boolean includeChildren) Returns all child organizational units of the given parent organizational unit including hierarchical deeper organization units if needed.Returns all resources of the given organizational unit.Returns the SqlManager of this driver.getUsers
(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, boolean recursive) Returns all users of the given organizational unit.getUsersWithoutAdditionalInfo
(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, boolean recursive) Returns all users of the given organizational unit, without reading their additional infos.void
init
(CmsDbContext dbc, CmsConfigurationManager configurationManager, List<String> successiveDrivers, CmsDriverManager driverManager) Initializes the driver.initSqlManager
(String classname) Initializes the SQL manager for this driver.protected CmsAccessControlEntry
Internal helper method to create an access control entry from a database record.protected CmsAccessControlEntry
internalCreateAce
(ResultSet res, CmsUUID newId) Internal helper method to create an access control entry from a database record.protected void
internalCreateDefaultGroups
(CmsDbContext dbc, String ouFqn, String ouDescription, boolean webuser) Creates the default groups and user for the given organizational unit.protected CmsGroup
Semi-constructor to create aCmsGroup
instance from a JDBC result set.protected CmsOrganizationalUnit
internalCreateOrgUnitFromResource
(CmsDbContext dbc, CmsResource resource) Returns the organizational unit represented by the given resource.protected CmsResource
internalCreateResourceForOrgUnit
(CmsDbContext dbc, String path, int flags) Creates a folder with the given path an properties, offline AND online.protected CmsUser
internalCreateUser
(CmsDbContext dbc, ResultSet res) Semi-constructor to create aCmsUser
instance from a JDBC result set.protected void
internalDeleteOrgUnitResource
(CmsDbContext dbc, CmsResource resource) Deletes a resource representing a organizational unit, offline AND online.protected void
internalDeleteUserInfo
(CmsDbContext dbc, CmsUUID userId, String key) Deletes an additional user info.internalGetUsers
(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, boolean recursive, boolean readAdditionalInfos) Internal implementation for reading users of an OU, with or without additional infos.protected CmsResource
internalOrgUnitFolder
(CmsDbContext dbc, CmsOrganizationalUnit orgUnit) Returns the folder for the given organizational units, or the base folder ifnull
.internalResourcesForOrgUnit
(CmsDbContext dbc, CmsResource ouResource) Returns the list of root paths associated to the organizational unit represented by the given resource.protected void
internalUpdateRoleGroup
(CmsDbContext dbc, String groupName, CmsRole role) Updates a group to a virtual group.protected void
internalUpdateUserInfo
(CmsDbContext dbc, CmsUUID userId, String key, Object value) Updates additional user info.protected void
internalValidateResourceForOrgUnit
(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, String rootPath) Validates the given root path to be in the scope of the resources of the given organizational unit.protected boolean
internalValidateUserInGroup
(CmsDbContext dbc, CmsUUID userId, CmsUUID groupId) Checks if a user is member of a group.protected void
internalWriteOrgUnitProperty
(CmsDbContext dbc, CmsResource resource, CmsProperty property) Writes a property for an organizational unit resource, online AND offline.protected void
internalWriteUserInfo
(CmsDbContext dbc, CmsUUID userId, String key, Object value) Writes a new additional user info.protected void
internalWriteUserInfos
(CmsDbContext dbc, CmsUUID userId, Map<String, Object> additionalInfo) Updates the user additional information map.void
publishAccessControlEntries
(CmsDbContext dbc, CmsProject offlineProject, CmsProject onlineProject, CmsUUID offlineId, CmsUUID onlineId) Publish all access control entries of a resource from the given offline project to the online project.readAccessControlEntries
(CmsDbContext dbc, CmsProject project, CmsUUID resource, boolean inheritedOnly) Reads all relevant access control entries for a given resource.readAccessControlEntry
(CmsDbContext dbc, CmsProject project, CmsUUID resource, CmsUUID principal) Reads an access control entry for a given principal that is attached to a resource.readChildGroups
(CmsDbContext dbc, String parentGroupFqn) Reads all child groups of a group.readGroup
(CmsDbContext dbc, String groupFqn) Reads a group based on the group name.readGroup
(CmsDbContext dbc, CmsUUID groupId) Reads a group based on the group id.readGroupsOfUser
(CmsDbContext dbc, CmsUUID userId, String ouFqn, boolean includeChildOus, String remoteAddress, boolean readRoles) Reads all groups the given user is a member in.readOrganizationalUnit
(CmsDbContext dbc, String ouFqn) Reads an organizational Unit based on its fully qualified name.readUser
(CmsDbContext dbc, String userFqn) Reads a user based in the user fully qualified name.readUser
(CmsDbContext dbc, String userFqn, String password, String remoteAddress) Reads a user from the database, only if the password is correct.readUser
(CmsDbContext dbc, CmsUUID id) Reads a user based on the user id.readUserInfos
(CmsDbContext dbc, CmsUUID userId) Reads the user additional information map.readUsersOfGroup
(CmsDbContext dbc, String groupFqn, boolean includeOtherOuUsers) Reads all users that are members of the given group.void
removeAccessControlEntries
(CmsDbContext dbc, CmsProject project, CmsUUID resource) Removes all access control entries belonging to a resource.void
removeAccessControlEntriesForPrincipal
(CmsDbContext dbc, CmsProject project, CmsProject onlineProject, CmsUUID principal) Removes all access control entries belonging to a principal.void
removeAccessControlEntry
(CmsDbContext dbc, CmsProject project, CmsUUID resource, CmsUUID principal) Removes an access control entry.void
removeResourceFromOrganizationalUnit
(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, CmsResource resource) Removes a resource from the given organizational unit.searchUsers
(CmsDbContext dbc, CmsUserSearchParameters searchParams) Searches for users which match the given search criteria.void
setDriverManager
(CmsDriverManager driverManager) Sets the driver manager for this driver if possible.void
setSqlManager
(CmsSqlManager sqlManager) Sets the SQL manager for this driver if possible.void
setUsersOrganizationalUnit
(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, CmsUser user) Moves an user to the given organizational unit.void
writeAccessControlEntry
(CmsDbContext dbc, CmsProject project, CmsAccessControlEntry acEntry) Writes an access control entry.void
writeGroup
(CmsDbContext dbc, CmsGroup group) Writes an already existing group.void
writeOrganizationalUnit
(CmsDbContext dbc, CmsOrganizationalUnit organizationalUnit) Writes an already existing organizational unit.void
writePassword
(CmsDbContext dbc, String userFqn, String oldPassword, String newPassword) Sets a new password for a user.void
writeUser
(CmsDbContext dbc, CmsUser user) Updates the user information.void
writeUserInfo
(CmsDbContext dbc, CmsUUID userId, String key, Object value) Writes an user additional information entry.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opencms.db.I_CmsDriver
toString
-
Field Details
-
ORGUNIT_BASE_FOLDER
The root path for organizational units.- See Also:
-
REQ_ATTR_DONT_DIGEST_PASSWORD
The internal request attribute to indicate that the password has not to be digested.- See Also:
-
m_digest
A digest to encrypt the passwords. -
m_digestAlgorithm
The algorithm used to encode passwords. -
m_digestFileEncoding
The file.encoding to code passwords after encryption with digest. -
m_driverManager
The driver manager. -
m_sqlManager
The SQL manager.
-
-
Constructor Details
-
CmsUserDriver
public CmsUserDriver()
-
-
Method Details
-
addResourceToOrganizationalUnit
public void addResourceToOrganizationalUnit(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, CmsResource resource) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Adds a resource to the given organizational unit.- Specified by:
addResourceToOrganizationalUnit
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current db contextorgUnit
- the organizational unit to add the resource toresource
- the resource that is to be added to the organizational unit- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
countUsers
public long countUsers(CmsDbContext dbc, CmsUserSearchParameters searchParams) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Counts the total number of users which match the given search criteria.- Specified by:
countUsers
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the database contextsearchParams
- the search criteria- Returns:
- the number of users which match the search criteria
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
createAccessControlEntry
public void createAccessControlEntry(CmsDbContext dbc, CmsProject project, CmsUUID resource, CmsUUID principal, int allowed, int denied, int flags) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Creates an access control entry.- Specified by:
createAccessControlEntry
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextproject
- the project to write the entryresource
- the id of the resourceprincipal
- the id of the principal (user or group)allowed
- the bitset of allowed permissionsdenied
- the bitset of denied permissionsflags
- flags- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
createGroup
public CmsGroup createGroup(CmsDbContext dbc, CmsUUID groupId, String groupFqn, String description, int flags, String parentGroupFqn) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Creates a new group.- Specified by:
createGroup
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextgroupId
- the id of the new groupgroupFqn
- the fully qualified name of the new groupdescription
- The description for the new groupflags
- the flags for the new groupparentGroupFqn
- the name of the parent group (or null if the group has no parent)- Returns:
- the created group
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
createOrganizationalUnit
public CmsOrganizationalUnit createOrganizationalUnit(CmsDbContext dbc, String name, String description, int flags, CmsOrganizationalUnit parent, String associatedResource) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Creates a new organizational unit.- Specified by:
createOrganizationalUnit
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current db contextname
- the name of the new organizational unitdescription
- the description of the new organizational unitflags
- the flags for the new organizational unitparent
- the parent organizational unit (ornull
)associatedResource
- the first associated resource- Returns:
- a
object representing the newly created organizational unitCmsOrganizationalUnit
- Throws:
CmsDataAccessException
- if operation was not successful- See Also:
-
createRootOrganizationalUnit
Description copied from interface:I_CmsUserDriver
Creates the default root organizational unit.- Specified by:
createRootOrganizationalUnit
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database context- See Also:
-
createUser
public CmsUser createUser(CmsDbContext dbc, CmsUUID id, String userFqn, String password, String firstname, String lastname, String email, long lastlogin, int flags, long dateCreated, Map<String, Object> additionalInfos) throws CmsDataAccessExceptionDescription copied from interface:I_CmsUserDriver
Creates a new user.- Specified by:
createUser
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextid
- the id of the useruserFqn
- the fully qualified name of the new userpassword
- the already encripted user passwordfirstname
- the user firstnamelastname
- the user lastnameemail
- the user emaillastlogin
- the user lastlogin timeflags
- the user flagsdateCreated
- the creation dateadditionalInfos
- the user additional infos- Returns:
- the created user
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
createUserInGroup
public void createUserInGroup(CmsDbContext dbc, CmsUUID userId, CmsUUID groupId) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Adds a user to a group.- Specified by:
createUserInGroup
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextuserId
- the id of the user that is to be added to the groupgroupId
- the id of the group- Throws:
CmsDataAccessException
- if operation was not successful- See Also:
-
deleteGroup
Description copied from interface:I_CmsUserDriver
Deletes a group.Only groups that contain no subgroups can be deleted.
- Specified by:
deleteGroup
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextgroupFqn
- the fully qualified name of the group that is to be deleted- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
deleteOrganizationalUnit
public void deleteOrganizationalUnit(CmsDbContext dbc, CmsOrganizationalUnit organizationalUnit) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Deletes an organizational unit.Only organizational units that contain no suborganizational unit can be deleted.
- Specified by:
deleteOrganizationalUnit
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current db contextorganizationalUnit
- the organizational unit to delete- Throws:
CmsDataAccessException
- if operation was not successful- See Also:
-
deleteUser
Description copied from interface:I_CmsUserDriver
Deletes a user.- Specified by:
deleteUser
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextuserFqn
- the fully qualified name of the user to delete- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
deleteUserInfos
Description copied from interface:I_CmsUserDriver
Deletes the user additional information table.- Specified by:
deleteUserInfos
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextuserId
- the id of the user to update- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
deleteUserInGroup
public void deleteUserInGroup(CmsDbContext dbc, CmsUUID userId, CmsUUID groupId) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Removes a user from a group.- Specified by:
deleteUserInGroup
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextuserId
- the id of the user that is to be removed from the groupgroupId
- the id of the group- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
destroy
Description copied from interface:I_CmsUserDriver
Destroys this driver.- Specified by:
destroy
in interfaceI_CmsUserDriver
- Throws:
Throwable
- if something goes wrong- See Also:
-
existsGroup
Description copied from interface:I_CmsUserDriver
Tests if a group with the specified name exists.- Specified by:
existsGroup
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextgroupFqn
- the fully qualified group name to be checked- Returns:
true
, if a group with the specified name exists,false
otherwise- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
existsUser
Description copied from interface:I_CmsUserDriver
Tests if a user with the specified name exists.- Specified by:
existsUser
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextuserFqn
- the fully qualified name of the user to be checked- Returns:
- true, if a user with the specified name exists, false otherwise
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
fillDefaults
Description copied from interface:I_CmsUserDriver
Initializes the default organizational units, users and groups.- Specified by:
fillDefaults
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database context, be aware that this dbc has no runtime data!- Throws:
CmsInitException
- if something goes wrong- See Also:
-
getGroups
public List<CmsGroup> getGroups(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, boolean includeSubOus, boolean readRoles) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Returns all groups of the given organizational unit.- Specified by:
getGroups
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current db contextorgUnit
- the organizational unit to get all groups forincludeSubOus
- flag to signalize the retrieval of groups of sub-organizational units tooreadRoles
- if to read roles or groups- Returns:
- all
objects in the organizational unitCmsGroup
- Throws:
CmsDataAccessException
- if operation was not successful- See Also:
-
getOrganizationalUnits
public List<CmsOrganizationalUnit> getOrganizationalUnits(CmsDbContext dbc, CmsOrganizationalUnit parent, boolean includeChildren) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Returns all child organizational units of the given parent organizational unit including hierarchical deeper organization units if needed.- Specified by:
getOrganizationalUnits
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current db contextparent
- the parent organizational unit, ornull
for the rootincludeChildren
- if hierarchical deeper organization units should also be returned- Returns:
- a list of
objectsCmsOrganizationalUnit
- Throws:
CmsDataAccessException
- if operation was not succesful- See Also:
-
getResourcesForOrganizationalUnit
public List<CmsResource> getResourcesForOrganizationalUnit(CmsDbContext dbc, CmsOrganizationalUnit orgUnit) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Returns all resources of the given organizational unit.- Specified by:
getResourcesForOrganizationalUnit
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current db contextorgUnit
- the organizational unit to get all resources for- Returns:
- all
objects in the organizational unitCmsResource
- Throws:
CmsDataAccessException
- if operation was not successful- See Also:
-
getSqlManager
Description copied from interface:I_CmsUserDriver
Returns the SqlManager of this driver.- Specified by:
getSqlManager
in interfaceI_CmsUserDriver
- Returns:
- the SqlManager of this driver
- See Also:
-
getUsers
public List<CmsUser> getUsers(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, boolean recursive) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Returns all users of the given organizational unit.- Specified by:
getUsers
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current db contextorgUnit
- the organizational unit to get all users forrecursive
- flag to signalize the retrieval of users of sub-organizational units too- Returns:
- all
objects in the organizational unitCmsUser
- Throws:
CmsDataAccessException
- if operation was not successful- See Also:
-
getUsersWithoutAdditionalInfo
public List<CmsUser> getUsersWithoutAdditionalInfo(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, boolean recursive) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Returns all users of the given organizational unit, without reading their additional infos.- Specified by:
getUsersWithoutAdditionalInfo
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current db contextorgUnit
- the organizational unit to get all users forrecursive
- flag to signalize the retrieval of users of sub-organizational units too- Returns:
- all
objects in the organizational unitCmsUser
- Throws:
CmsDataAccessException
- if operation was not successful- See Also:
-
init
public void init(CmsDbContext dbc, CmsConfigurationManager configurationManager, List<String> successiveDrivers, CmsDriverManager driverManager) Description copied from interface:I_CmsDriver
Initializes the driver.- Specified by:
init
in interfaceI_CmsDriver
- Parameters:
dbc
- the current database contextconfigurationManager
- the configuration managersuccessiveDrivers
- a list of successive drivers to be initializeddriverManager
- the initialized OpenCms driver manager- See Also:
-
initSqlManager
Description copied from interface:I_CmsUserDriver
Initializes the SQL manager for this driver.To obtain JDBC connections from different pools, further {online|offline|history} pool Urls have to be specified.
- Specified by:
initSqlManager
in interfaceI_CmsUserDriver
- Parameters:
classname
- the classname of the SQL manager- Returns:
- the SQL manager for this driver
- See Also:
-
publishAccessControlEntries
public void publishAccessControlEntries(CmsDbContext dbc, CmsProject offlineProject, CmsProject onlineProject, CmsUUID offlineId, CmsUUID onlineId) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Publish all access control entries of a resource from the given offline project to the online project.Within the given project, the resource is identified by its offlineId, in the online project, it is identified by the given onlineId.
- Specified by:
publishAccessControlEntries
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextofflineProject
- an offline projectonlineProject
- the onlie projectofflineId
- the offline resource idonlineId
- the online resource id- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readAccessControlEntries
public List<CmsAccessControlEntry> readAccessControlEntries(CmsDbContext dbc, CmsProject project, CmsUUID resource, boolean inheritedOnly) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Reads all relevant access control entries for a given resource.- Specified by:
readAccessControlEntries
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextproject
- the project to write the entryresource
- the id of the resourceinheritedOnly
- flag to indicate that only inherited entries should be returned- Returns:
- a list of
objects defining all permissions for the given resourceCmsAccessControlEntry
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readAccessControlEntry
public CmsAccessControlEntry readAccessControlEntry(CmsDbContext dbc, CmsProject project, CmsUUID resource, CmsUUID principal) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Reads an access control entry for a given principal that is attached to a resource.- Specified by:
readAccessControlEntry
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextproject
- the project to write the entryresource
- the id of the resourceprincipal
- the id of the principal- Returns:
- an access control entry that defines the permissions of the principal for the given resource
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readChildGroups
public List<CmsGroup> readChildGroups(CmsDbContext dbc, String parentGroupFqn) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Reads all child groups of a group.- Specified by:
readChildGroups
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextparentGroupFqn
- the fully qualified name of the group to read the child groups from- Returns:
- a list of all child
objects orCmsGroup
null
- Throws:
CmsDataAccessException
- if operation was not succesful- See Also:
-
readGroup
Description copied from interface:I_CmsUserDriver
Reads a group based on the group id.- Specified by:
readGroup
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextgroupId
- the id of the group that is to be read- Returns:
- the group that was read
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readGroup
Description copied from interface:I_CmsUserDriver
Reads a group based on the group name.- Specified by:
readGroup
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextgroupFqn
- the fully qualified name of the group that is to be read- Returns:
- the group that was read
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readGroupsOfUser
public List<CmsGroup> readGroupsOfUser(CmsDbContext dbc, CmsUUID userId, String ouFqn, boolean includeChildOus, String remoteAddress, boolean readRoles) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Reads all groups the given user is a member in.- Specified by:
readGroupsOfUser
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextuserId
- the id of the userouFqn
- the fully qualified name of the organizational unit to restrict the result set forincludeChildOus
- include groups of child organizational unitsremoteAddress
- the IP address to filter the groups in the result listreadRoles
- if to read roles or groups- Returns:
- a list of
objectsCmsGroup
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readOrganizationalUnit
public CmsOrganizationalUnit readOrganizationalUnit(CmsDbContext dbc, String ouFqn) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Reads an organizational Unit based on its fully qualified name.- Specified by:
readOrganizationalUnit
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current db contextouFqn
- the fully qualified name of the organizational Unit to be read- Returns:
- the organizational Unit with the provided fully qualified name
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readUser
Description copied from interface:I_CmsUserDriver
Reads a user based on the user id.- Specified by:
readUser
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextid
- the id of the user to read- Returns:
- the user that was read
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readUser
Description copied from interface:I_CmsUserDriver
Reads a user based in the user fully qualified name.- Specified by:
readUser
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextuserFqn
- the fully qualified name of the user to read- Returns:
- the user that was read
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readUser
public CmsUser readUser(CmsDbContext dbc, String userFqn, String password, String remoteAddress) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Reads a user from the database, only if the password is correct.- Specified by:
readUser
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextuserFqn
- the name of the userpassword
- the password of the userremoteAddress
- the remote address of the request, may benull
- Returns:
- the user that was read
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readUserInfos
public Map<String,Object> readUserInfos(CmsDbContext dbc, CmsUUID userId) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Reads the user additional information map.- Specified by:
readUserInfos
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextuserId
- the id of the user to update- Returns:
- the user additional information map
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readUsersOfGroup
public List<CmsUser> readUsersOfGroup(CmsDbContext dbc, String groupFqn, boolean includeOtherOuUsers) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Reads all users that are members of the given group.- Specified by:
readUsersOfGroup
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextgroupFqn
- the fully qualified name of the group to read the users fromincludeOtherOuUsers
- include users of other organizational units- Returns:
- all
objects in the groupCmsUser
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
removeAccessControlEntries
public void removeAccessControlEntries(CmsDbContext dbc, CmsProject project, CmsUUID resource) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Removes all access control entries belonging to a resource.- Specified by:
removeAccessControlEntries
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextproject
- the project to write the entryresource
- the id of the resource- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
removeAccessControlEntriesForPrincipal
public void removeAccessControlEntriesForPrincipal(CmsDbContext dbc, CmsProject project, CmsProject onlineProject, CmsUUID principal) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Removes all access control entries belonging to a principal.- Specified by:
removeAccessControlEntriesForPrincipal
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextproject
- the project to write the entryonlineProject
- the online projectprincipal
- the id of the principal- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
removeAccessControlEntry
public void removeAccessControlEntry(CmsDbContext dbc, CmsProject project, CmsUUID resource, CmsUUID principal) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Removes an access control entry.- Specified by:
removeAccessControlEntry
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextproject
- the project to write the entryresource
- the id of the resourceprincipal
- the id of the principal- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
removeResourceFromOrganizationalUnit
public void removeResourceFromOrganizationalUnit(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, CmsResource resource) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Removes a resource from the given organizational unit.- Specified by:
removeResourceFromOrganizationalUnit
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current db contextorgUnit
- the organizational unit to remove the resource fromresource
- the resource that is to be removed from the organizational unit- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
searchUsers
public List<CmsUser> searchUsers(CmsDbContext dbc, CmsUserSearchParameters searchParams) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Searches for users which match the given search criteria.- Specified by:
searchUsers
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the database contextsearchParams
- the search criteria- Returns:
- the users which match the given criteria
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
setDriverManager
Description copied from interface:I_CmsUserDriver
Sets the driver manager for this driver if possible.- Specified by:
setDriverManager
in interfaceI_CmsUserDriver
- Parameters:
driverManager
- the new driver manager- See Also:
-
setSqlManager
Description copied from interface:I_CmsUserDriver
Sets the SQL manager for this driver if possible.- Specified by:
setSqlManager
in interfaceI_CmsUserDriver
- Parameters:
sqlManager
- the new SQL manager- See Also:
-
setUsersOrganizationalUnit
public void setUsersOrganizationalUnit(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, CmsUser user) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Moves an user to the given organizational unit.- Specified by:
setUsersOrganizationalUnit
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current db contextorgUnit
- the organizational unit to move the user touser
- the user that is to be moved to the given organizational unit- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
writeAccessControlEntry
public void writeAccessControlEntry(CmsDbContext dbc, CmsProject project, CmsAccessControlEntry acEntry) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Writes an access control entry.- Specified by:
writeAccessControlEntry
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextproject
- the project to write the entryacEntry
- the entry to write- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
writeGroup
Description copied from interface:I_CmsUserDriver
Writes an already existing group.The group id has to be a valid OpenCms group id.
The group with the given id will be completely overriden by the given data.- Specified by:
writeGroup
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextgroup
- the group to update- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
writeOrganizationalUnit
public void writeOrganizationalUnit(CmsDbContext dbc, CmsOrganizationalUnit organizationalUnit) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Writes an already existing organizational unit.The organizational unit id has to be a valid OpenCms organizational unit id.
The organizational unit with the given id will be completely overriden by the given data.- Specified by:
writeOrganizationalUnit
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current db contextorganizationalUnit
- the organizational unit that should be written- Throws:
CmsDataAccessException
- if operation was not successful- See Also:
-
writePassword
public void writePassword(CmsDbContext dbc, String userFqn, String oldPassword, String newPassword) throws CmsDataAccessException, CmsPasswordEncryptionException Description copied from interface:I_CmsUserDriver
Sets a new password for a user.- Specified by:
writePassword
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextuserFqn
- the fullyqualified name of the user to set the password foroldPassword
- the current passwordnewPassword
- the password to set- Throws:
CmsDataAccessException
- if something goes wrongCmsPasswordEncryptionException
- if the (new) password could not be encrypted- See Also:
-
writeUser
Description copied from interface:I_CmsUserDriver
Updates the user information.The user id has to be a valid OpenCms user id.
The user with the given id will be completely overriden by the given data.
- Specified by:
writeUser
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextuser
- the user to update- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
writeUserInfo
public void writeUserInfo(CmsDbContext dbc, CmsUUID userId, String key, Object value) throws CmsDataAccessException Description copied from interface:I_CmsUserDriver
Writes an user additional information entry.- Specified by:
writeUserInfo
in interfaceI_CmsUserDriver
- Parameters:
dbc
- the current database contextuserId
- the id of the user to updatekey
- the key of the info to writevalue
- the value of the info to write- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
createRoleQuery
Returns a sql query to select groups.- Parameters:
mainQuery
- the main select sql queryincludeSubOus
- if groups in sub-ous should be included in the selectionreadRoles
- if groups or roles whould be selected- Returns:
- a sql query to select groups
-
createUserQuery
protected CmsPair<String,List<Object>> createUserQuery(CmsUserSearchParameters searchParams, boolean countOnly) Creates a query for searching users.- Parameters:
searchParams
- the user search criteriacountOnly
- if true, the query will only count the total number of results instead of returning them- Returns:
- a pair consisting of the query string and its parameters
-
createUserQueryBuilder
Creates a new user query builder.- Returns:
- the new user query builder
-
internalCreateAce
Internal helper method to create an access control entry from a database record.- Parameters:
res
- resultset of the current query- Returns:
- a new
CmsAccessControlEntry
initialized with the values from the current database record - Throws:
SQLException
- if something goes wrong
-
internalCreateAce
Internal helper method to create an access control entry from a database record.- Parameters:
res
- resultset of the current querynewId
- the id of the new access control entry- Returns:
- a new
CmsAccessControlEntry
initialized with the values from the current database record - Throws:
SQLException
- if something goes wrong
-
internalCreateDefaultGroups
protected void internalCreateDefaultGroups(CmsDbContext dbc, String ouFqn, String ouDescription, boolean webuser) throws CmsException Creates the default groups and user for the given organizational unit.- Parameters:
dbc
- the database contextouFqn
- the fully qualified name of the organizational unit to create the principals forouDescription
- the description of the given organizational unitwebuser
- the webuser ou flag- Throws:
CmsException
- if something goes wrong
-
internalCreateGroup
Semi-constructor to create aCmsGroup
instance from a JDBC result set.- Parameters:
res
- the JDBC ResultSet- Returns:
- CmsGroup the new CmsGroup object
- Throws:
SQLException
- in case the result set does not include a requested table attribute
-
internalCreateOrgUnitFromResource
protected CmsOrganizationalUnit internalCreateOrgUnitFromResource(CmsDbContext dbc, CmsResource resource) throws CmsException Returns the organizational unit represented by the given resource.- Parameters:
dbc
- the current db contextresource
- the resource that represents an organizational unit- Returns:
- the organizational unit represented by the given resource
- Throws:
CmsException
- if something goes wrong
-
internalCreateResourceForOrgUnit
protected CmsResource internalCreateResourceForOrgUnit(CmsDbContext dbc, String path, int flags) throws CmsException Creates a folder with the given path an properties, offline AND online.- Parameters:
dbc
- the current database contextpath
- the path to create the folderflags
- the resource flags- Returns:
- the new created offline folder
- Throws:
CmsException
- if something goes wrong
-
internalCreateUser
Semi-constructor to create aCmsUser
instance from a JDBC result set.- Parameters:
dbc
- the current database contextres
- the JDBC ResultSet- Returns:
- the new CmsUser object
- Throws:
SQLException
- in case the result set does not include a requested table attribute
-
internalDeleteOrgUnitResource
protected void internalDeleteOrgUnitResource(CmsDbContext dbc, CmsResource resource) throws CmsException Deletes a resource representing a organizational unit, offline AND online.- Parameters:
dbc
- the current database contextresource
- the resource to delete- Throws:
CmsException
- if something goes wrong
-
internalDeleteUserInfo
protected void internalDeleteUserInfo(CmsDbContext dbc, CmsUUID userId, String key) throws CmsDataAccessException Deletes an additional user info.- Parameters:
dbc
- the current dbcuserId
- the user to delete additional info fromkey
- the additional info to delete- Throws:
CmsDataAccessException
- if something goes wrong
-
internalGetUsers
protected List<CmsUser> internalGetUsers(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, boolean recursive, boolean readAdditionalInfos) throws CmsDataAccessException Internal implementation for reading users of an OU, with or without additional infos.- Parameters:
dbc
- the database contextorgUnit
- the OUrecursive
- if true, sub-OUs should be searchedreadAdditionalInfos
- if true, additional infos should be read- Returns:
- the users which have been read
- Throws:
CmsDataAccessException
- if something goes wrong
-
internalOrgUnitFolder
protected CmsResource internalOrgUnitFolder(CmsDbContext dbc, CmsOrganizationalUnit orgUnit) throws CmsException Returns the folder for the given organizational units, or the base folder ifnull
.The base folder will be created if it does not exist.
- Parameters:
dbc
- the current db contextorgUnit
- the organizational unit to get the folder for- Returns:
- the base folder for organizational units
- Throws:
CmsException
- if something goes wrong
-
internalResourcesForOrgUnit
protected List<String> internalResourcesForOrgUnit(CmsDbContext dbc, CmsResource ouResource) throws CmsException Returns the list of root paths associated to the organizational unit represented by the given resource.- Parameters:
dbc
- the current db contextouResource
- the resource that represents the organizational unit to get the resources for- Returns:
- the list of associated resource names
- Throws:
CmsException
- if something goes wrong
-
internalUpdateRoleGroup
protected void internalUpdateRoleGroup(CmsDbContext dbc, String groupName, CmsRole role) throws CmsDataAccessException Updates a group to a virtual group.- Parameters:
dbc
- the database contextgroupName
- the name of the group to updaterole
- the role for this group- Throws:
CmsDataAccessException
- if something goes wrong
-
internalUpdateUserInfo
protected void internalUpdateUserInfo(CmsDbContext dbc, CmsUUID userId, String key, Object value) throws CmsDataAccessException Updates additional user info.- Parameters:
dbc
- the current dbcuserId
- the user id to add the user info forkey
- the name of the additional user infovalue
- the value of the additional user info- Throws:
CmsDataAccessException
- if something goes wrong
-
internalValidateResourceForOrgUnit
protected void internalValidateResourceForOrgUnit(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, String rootPath) throws CmsException Validates the given root path to be in the scope of the resources of the given organizational unit.- Parameters:
dbc
- the current db contextorgUnit
- the organizational unitrootPath
- the root path to check- Throws:
CmsException
- if something goes wrong
-
internalValidateUserInGroup
protected boolean internalValidateUserInGroup(CmsDbContext dbc, CmsUUID userId, CmsUUID groupId) throws CmsDataAccessException Checks if a user is member of a group.- Parameters:
dbc
- the database contextuserId
- the id of the user to checkgroupId
- the id of the group to check- Returns:
- true if user is member of group
- Throws:
CmsDataAccessException
- if operation was not succesful
-
internalWriteOrgUnitProperty
protected void internalWriteOrgUnitProperty(CmsDbContext dbc, CmsResource resource, CmsProperty property) throws CmsException Writes a property for an organizational unit resource, online AND offline.- Parameters:
dbc
- the current database contextresource
- the resource representing the organizational unitproperty
- the property to write- Throws:
CmsException
- if something goes wrong
-
internalWriteUserInfo
protected void internalWriteUserInfo(CmsDbContext dbc, CmsUUID userId, String key, Object value) throws CmsDataAccessException Writes a new additional user info.- Parameters:
dbc
- the current dbcuserId
- the user id to add the user info forkey
- the name of the additional user infovalue
- the value of the additional user info- Throws:
CmsDataAccessException
- if something goes wrong
-
internalWriteUserInfos
protected void internalWriteUserInfos(CmsDbContext dbc, CmsUUID userId, Map<String, Object> additionalInfo) throws CmsDataAccessExceptionUpdates the user additional information map.- Parameters:
dbc
- the current database contextuserId
- the id of the user to updateadditionalInfo
- the info to write- Throws:
CmsDataAccessException
- if user data could not be written
-