org.opencms.db
Interface I_CmsUserDriver

All Superinterfaces:
I_CmsDriver
All Known Implementing Classes:
CmsUserDriver

public interface I_CmsUserDriver
extends I_CmsDriver

Definitions of all required user driver methods.

Since:
6.0.0
Version:
$Revision: 1.58 $
Author:
Thomas Weckert, Michael Emmerich

Field Summary
static int DRIVER_TYPE_ID
          The type ID to identify user driver implementations.
 
Method Summary
 void createAccessControlEntry(CmsDbContext dbc, CmsProject project, CmsUUID resource, CmsUUID principal, int allowed, int denied, int flags)
          Creates an access control entry.
 CmsGroup createGroup(CmsDbContext dbc, CmsUUID groupId, java.lang.String groupName, java.lang.String description, int flags, java.lang.String parentGroupName, java.lang.Object reservedParam)
          Creates a new group.
 CmsUser createUser(CmsDbContext dbc, java.lang.String name, java.lang.String password, java.lang.String description, java.lang.String firstname, java.lang.String lastname, java.lang.String email, long lastlogin, int flags, java.util.Map additionalInfos, java.lang.String address, int type)
          Creates a new user.
 void createUserInGroup(CmsDbContext dbc, CmsUUID userid, CmsUUID groupid, java.lang.Object reservedParam)
          Adds a user to a group.
 void deleteAccessControlEntries(CmsDbContext dbc, CmsProject project, CmsUUID resource)
          Deletes all access control entries (ACEs) belonging to a resource.
 void deleteGroup(CmsDbContext dbc, java.lang.String name)
          Deletes a group.
 void deleteUser(CmsDbContext dbc, java.lang.String userName)
          Deletes a user.
 void deleteUserInGroup(CmsDbContext dbc, CmsUUID userId, CmsUUID groupId)
          Removes a user from a group.
 void destroy()
          Destroys this driver.
 boolean existsGroup(CmsDbContext dbc, java.lang.String groupname, java.lang.Object reservedParam)
          Tests if a group with the specified name exists.
 boolean existsUser(CmsDbContext dbc, java.lang.String username, int usertype, java.lang.Object reservedParam)
          Tests if a user with the specified name exists.
 CmsSqlManager getSqlManager()
          Returns the SqlManager of this driver.
 CmsUser importUser(CmsDbContext dbc, CmsUUID id, java.lang.String name, java.lang.String password, java.lang.String description, java.lang.String firstname, java.lang.String lastname, java.lang.String email, long lastlogin, int flags, java.util.Map additionalInfos, java.lang.String address, int type, java.lang.Object reservedParam)
          Creates a new user by import.
 CmsSqlManager initSqlManager(java.lang.String classname)
          Initializes the SQL manager for this driver.
 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.
 java.util.List readAccessControlEntries(CmsDbContext dbc, CmsProject project, CmsUUID resource, boolean inheritedOnly)
          Reads all relevant access control entries for a given resource.
 CmsAccessControlEntry readAccessControlEntry(CmsDbContext dbc, CmsProject project, CmsUUID resource, CmsUUID principal)
          Reads an access control entry for a given principal that is attached to a resource.
 java.util.List readChildGroups(CmsDbContext dbc, java.lang.String groupname)
          Reads all child groups of a group.
 CmsGroup readGroup(CmsDbContext dbc, CmsUUID groupId)
          Reads a group based on the group id.
 CmsGroup readGroup(CmsDbContext dbc, java.lang.String groupName)
          Reads a group based on the group name.
 java.util.List readGroups(CmsDbContext dbc)
          Reads all existing groups.
 java.util.List readGroupsOfUser(CmsDbContext dbc, CmsUUID userId, java.lang.String paramStr)
          Reads all groups the given user is a member in.
 CmsUser readUser(CmsDbContext dbc, CmsUUID id)
          Reads a user based on the user id.
 CmsUser readUser(CmsDbContext dbc, java.lang.String name, int type)
          Reads a user based in the user name and user type.
 CmsUser readUser(CmsDbContext dbc, java.lang.String name, java.lang.String password, int type)
          Reads a user from the database, only if the password is correct.
 CmsUser readUser(CmsDbContext dbc, java.lang.String name, java.lang.String password, java.lang.String remoteAddress, int type)
          Reads a user from the database, only if the password is correct.
 java.util.List readUsers(CmsDbContext dbc, int type)
          Reads all existing users of the given type.
 java.util.List readUsersOfGroup(CmsDbContext dbc, java.lang.String name, int type)
          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 writeAccessControlEntry(CmsDbContext dbc, CmsProject project, CmsAccessControlEntry acEntry)
          Writes an access control entry.
 void writeGroup(CmsDbContext dbc, CmsGroup group)
          Writes an already existing group.
 void writePassword(CmsDbContext dbc, java.lang.String userName, int type, java.lang.String oldPassword, java.lang.String newPassword)
          Sets a new password for a user.
 void writeUser(CmsDbContext dbc, CmsUser user)
          Updates the user information.
 void writeUserType(CmsDbContext dbc, CmsUUID userId, int userType)
          Changes the user type of the given user.
 
Methods inherited from interface org.opencms.db.I_CmsDriver
init, toString
 

Field Detail

DRIVER_TYPE_ID

public static final int DRIVER_TYPE_ID
The type ID to identify user driver implementations.

See Also:
Constant Field Values
Method Detail

createAccessControlEntry

public void createAccessControlEntry(CmsDbContext dbc,
                                     CmsProject project,
                                     CmsUUID resource,
                                     CmsUUID principal,
                                     int allowed,
                                     int denied,
                                     int flags)
                              throws CmsDataAccessException
Creates an access control entry.

Parameters:
dbc - the current database context
project - the project to write the entry
resource - the id of the resource
principal - the id of the principal (user or group)
allowed - the bitset of allowed permissions
denied - the bitset of denied permissions
flags - flags
Throws:
CmsDataAccessException - if something goes wrong

createGroup

public CmsGroup createGroup(CmsDbContext dbc,
                            CmsUUID groupId,
                            java.lang.String groupName,
                            java.lang.String description,
                            int flags,
                            java.lang.String parentGroupName,
                            java.lang.Object reservedParam)
                     throws CmsDataAccessException
Creates a new group.

Parameters:
dbc - the current database context
groupId - the id of the new group
groupName - the name of the new group
description - The description for the new group
flags - the flags for the new group
parentGroupName - the name of the parent group (or null if the group has no parent)
reservedParam - reserved optional parameter, should be null on standard OpenCms installations
Returns:
the created group
Throws:
CmsDataAccessException - if something goes wrong

createUser

public CmsUser createUser(CmsDbContext dbc,
                          java.lang.String name,
                          java.lang.String password,
                          java.lang.String description,
                          java.lang.String firstname,
                          java.lang.String lastname,
                          java.lang.String email,
                          long lastlogin,
                          int flags,
                          java.util.Map additionalInfos,
                          java.lang.String address,
                          int type)
                   throws CmsDataAccessException,
                          CmsPasswordEncryptionException
Creates a new user.

Parameters:
dbc - the current database context
name - the user name
password - the user password
description - the user description
firstname - the user firstname
lastname - the user lastname
email - the user email
lastlogin - the user lastlogin time
flags - the user flags
additionalInfos - the user additional infos
address - the user default address
type - the user type
Returns:
the created user
Throws:
CmsDataAccessException - if something goes wrong
CmsPasswordEncryptionException - if the user password could not be encrypted

createUserInGroup

public void createUserInGroup(CmsDbContext dbc,
                              CmsUUID userid,
                              CmsUUID groupid,
                              java.lang.Object reservedParam)
                       throws CmsDataAccessException
Adds a user to a group.

Parameters:
dbc - the current database context
userid - the id of the user that is to be added to the group
groupid - the id of the group
reservedParam - reserved optional parameter, should be null on standard OpenCms installations
Throws:
CmsDataAccessException - if operation was not succesfull

deleteAccessControlEntries

public void deleteAccessControlEntries(CmsDbContext dbc,
                                       CmsProject project,
                                       CmsUUID resource)
                                throws CmsDataAccessException
Deletes all access control entries (ACEs) belonging to a resource.

Parameters:
dbc - the current database context
project - the project to delete the ACEs in
resource - the id of the resource to delete the ACEs from
Throws:
CmsDataAccessException - if something goes wrong

deleteGroup

public void deleteGroup(CmsDbContext dbc,
                        java.lang.String name)
                 throws CmsDataAccessException
Deletes a group.

Only groups that contain no subgroups can be deleted.

Parameters:
dbc - the current database context
name - the name of the group that is to be deleted
Throws:
CmsDataAccessException - if something goes wrong

deleteUser

public void deleteUser(CmsDbContext dbc,
                       java.lang.String userName)
                throws CmsDataAccessException
Deletes a user.

Parameters:
dbc - the current database context
userName - the name of the user to delete
Throws:
CmsDataAccessException - if something goes wrong

deleteUserInGroup

public void deleteUserInGroup(CmsDbContext dbc,
                              CmsUUID userId,
                              CmsUUID groupId)
                       throws CmsDataAccessException
Removes a user from a group.

Parameters:
dbc - the current database context
userId - the id of the user that is to be removed from the group
groupId - the id of the group
Throws:
CmsDataAccessException - if something goes wrong

destroy

public void destroy()
             throws java.lang.Throwable
Destroys this driver.

Throws:
java.lang.Throwable - if something goes wrong

existsGroup

public boolean existsGroup(CmsDbContext dbc,
                           java.lang.String groupname,
                           java.lang.Object reservedParam)
                    throws CmsDataAccessException
Tests if a group with the specified name exists.

Parameters:
dbc - the current database context
groupname - the user name to be checked
reservedParam - reserved optional parameter, should be null on standard OpenCms installations
Returns:
true, if a group with the specified name exists, false otherwise
Throws:
CmsDataAccessException - if something goes wrong

existsUser

public boolean existsUser(CmsDbContext dbc,
                          java.lang.String username,
                          int usertype,
                          java.lang.Object reservedParam)
                   throws CmsDataAccessException
Tests if a user with the specified name exists.

Parameters:
dbc - the current database context
username - the user name to be checked
usertype - the type of the user
reservedParam - reserved optional parameter, should be null on standard OpenCms installations
Returns:
true, if a user with the specified name exists, false otherwise
Throws:
CmsDataAccessException - if something goes wrong

getSqlManager

public CmsSqlManager getSqlManager()
Returns the SqlManager of this driver.

Returns:
the SqlManager of this driver

importUser

public CmsUser importUser(CmsDbContext dbc,
                          CmsUUID id,
                          java.lang.String name,
                          java.lang.String password,
                          java.lang.String description,
                          java.lang.String firstname,
                          java.lang.String lastname,
                          java.lang.String email,
                          long lastlogin,
                          int flags,
                          java.util.Map additionalInfos,
                          java.lang.String address,
                          int type,
                          java.lang.Object reservedParam)
                   throws CmsDataAccessException
Creates a new user by import.

Parameters:
dbc - the current database context
id - the id of the user
name - the new name for the user
password - the new password for the user
description - the description for the user
firstname - the firstname of the user
lastname - the lastname of the user
email - the email of the user
lastlogin - the user lastlogin time
flags - the flags for a user (e.g. I_CmsPrincipal.FLAG_ENABLED)
additionalInfos - a Map with additional infos for the user. These infos may be stored into the Usertables (depending on the implementation).
address - the address of the user
type - the type of the user
reservedParam - reserved optional parameter, should be null on standard OpenCms installations
Returns:
a new CmsUser object representing the added user
Throws:
CmsDataAccessException - if operation was not successful

initSqlManager

public CmsSqlManager initSqlManager(java.lang.String classname)
Initializes the SQL manager for this driver.

To obtain JDBC connections from different pools, further {online|offline|backup} pool Urls have to be specified.

Parameters:
classname - the classname of the SQL manager
Returns:
the SQL manager for this driver

publishAccessControlEntries

public void publishAccessControlEntries(CmsDbContext dbc,
                                        CmsProject offlineProject,
                                        CmsProject onlineProject,
                                        CmsUUID offlineId,
                                        CmsUUID onlineId)
                                 throws CmsDataAccessException
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.

Parameters:
dbc - the current database context
offlineProject - an offline project
onlineProject - the onlie project
offlineId - the offline resource id
onlineId - the online resource id
Throws:
CmsDataAccessException - if something goes wrong

readAccessControlEntries

public java.util.List readAccessControlEntries(CmsDbContext dbc,
                                               CmsProject project,
                                               CmsUUID resource,
                                               boolean inheritedOnly)
                                        throws CmsDataAccessException
Reads all relevant access control entries for a given resource.

Parameters:
dbc - the current database context
project - the project to write the entry
resource - the id of the resource
inheritedOnly - flag to indicate that only inherited entries should be returned
Returns:
a list of CmsAccessControlEntry objects defining all permissions for the given resource
Throws:
CmsDataAccessException - if something goes wrong

readAccessControlEntry

public CmsAccessControlEntry readAccessControlEntry(CmsDbContext dbc,
                                                    CmsProject project,
                                                    CmsUUID resource,
                                                    CmsUUID principal)
                                             throws CmsDataAccessException
Reads an access control entry for a given principal that is attached to a resource.

Parameters:
dbc - the current database context
project - the project to write the entry
resource - the id of the resource
principal - 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

readChildGroups

public java.util.List readChildGroups(CmsDbContext dbc,
                                      java.lang.String groupname)
                               throws CmsDataAccessException
Reads all child groups of a group.

Parameters:
dbc - the current database context
groupname - the name of the group to read the child groups from
Returns:
a list of all child CmsGroup objects or null
Throws:
CmsDataAccessException - if operation was not succesful

readGroup

public CmsGroup readGroup(CmsDbContext dbc,
                          CmsUUID groupId)
                   throws CmsDataAccessException
Reads a group based on the group id.

Parameters:
dbc - the current database context
groupId - the id of the group that is to be read
Returns:
the group that was read
Throws:
CmsDataAccessException - if something goes wrong

readGroup

public CmsGroup readGroup(CmsDbContext dbc,
                          java.lang.String groupName)
                   throws CmsDataAccessException
Reads a group based on the group name.

Parameters:
dbc - the current database context
groupName - the name of the group that is to be read
Returns:
the group that was read
Throws:
CmsDataAccessException - if something goes wrong

readGroups

public java.util.List readGroups(CmsDbContext dbc)
                          throws CmsDataAccessException
Reads all existing groups.

Parameters:
dbc - the current database context
Returns:
a list of all CmsGroup objects
Throws:
CmsDataAccessException - if something goes wrong

readGroupsOfUser

public java.util.List readGroupsOfUser(CmsDbContext dbc,
                                       CmsUUID userId,
                                       java.lang.String paramStr)
                                throws CmsDataAccessException
Reads all groups the given user is a member in.

Parameters:
dbc - the current database context
userId - the id of the user
paramStr - additional parameter
Returns:
a list of CmsGroup objects
Throws:
CmsDataAccessException - if something goes wrong

readUser

public CmsUser readUser(CmsDbContext dbc,
                        CmsUUID id)
                 throws CmsDataAccessException
Reads a user based on the user id.

Parameters:
dbc - the current database context
id - the id of the user to read
Returns:
the user that was read
Throws:
CmsDataAccessException - if something goes wrong

readUser

public CmsUser readUser(CmsDbContext dbc,
                        java.lang.String name,
                        int type)
                 throws CmsDataAccessException
Reads a user based in the user name and user type.

Parameters:
dbc - the current database context
name - the name of the user to read
type - the type of the user to read
Returns:
the user that was read
Throws:
CmsDataAccessException - if something goes wrong

readUser

public CmsUser readUser(CmsDbContext dbc,
                        java.lang.String name,
                        java.lang.String password,
                        int type)
                 throws CmsDataAccessException,
                        CmsPasswordEncryptionException
Reads a user from the database, only if the password is correct.

If the user/pwd pair is not valid a CmsDataAccessException is thrown.

Parameters:
dbc - the current database context
name - the name of the user
password - the password of the user
type - the type of the user
Returns:
the user that was read
Throws:
CmsDataAccessException - if something goes wrong
CmsPasswordEncryptionException - if the password of the user could not be encrypted

readUser

public CmsUser readUser(CmsDbContext dbc,
                        java.lang.String name,
                        java.lang.String password,
                        java.lang.String remoteAddress,
                        int type)
                 throws CmsDataAccessException,
                        CmsPasswordEncryptionException
Reads a user from the database, only if the password is correct.

Parameters:
dbc - the current database context
name - the name of the user
password - the password of the user
remoteAddress - the remote address of the request
type - the type of the user
Returns:
the user that was read
Throws:
CmsDataAccessException - if something goes wrong
CmsPasswordEncryptionException - if the password of the user could not be encrypted

readUsers

public java.util.List readUsers(CmsDbContext dbc,
                                int type)
                         throws CmsDataAccessException
Reads all existing users of the given type.

Parameters:
dbc - the current database context
type - the type to read the users for
Returns:
a list of all CmsUser objects of the given type
Throws:
CmsDataAccessException - if something goes wrong

readUsersOfGroup

public java.util.List readUsersOfGroup(CmsDbContext dbc,
                                       java.lang.String name,
                                       int type)
                                throws CmsDataAccessException
Reads all users that are members of the given group.

Parameters:
dbc - the current database context
name - the name of the group to read the users from
type - the type of the users to read
Returns:
all CmsUser objects in the group
Throws:
CmsDataAccessException - if something goes wrong

removeAccessControlEntries

public void removeAccessControlEntries(CmsDbContext dbc,
                                       CmsProject project,
                                       CmsUUID resource)
                                throws CmsDataAccessException
Removes all access control entries belonging to a resource.

Parameters:
dbc - the current database context
project - the project to write the entry
resource - the id of the resource
Throws:
CmsDataAccessException - if something goes wrong

removeAccessControlEntriesForPrincipal

public void removeAccessControlEntriesForPrincipal(CmsDbContext dbc,
                                                   CmsProject project,
                                                   CmsProject onlineProject,
                                                   CmsUUID principal)
                                            throws CmsDataAccessException
Removes all access control entries belonging to a principal.

Parameters:
dbc - the current database context
project - the project to write the entry
onlineProject - the online project
principal - the id of the principal
Throws:
CmsDataAccessException - if something goes wrong

removeAccessControlEntry

public void removeAccessControlEntry(CmsDbContext dbc,
                                     CmsProject project,
                                     CmsUUID resource,
                                     CmsUUID principal)
                              throws CmsDataAccessException
Removes an access control entry.

Parameters:
dbc - the current database context
project - the project to write the entry
resource - the id of the resource
principal - the id of the principal
Throws:
CmsDataAccessException - if something goes wrong

writeAccessControlEntry

public void writeAccessControlEntry(CmsDbContext dbc,
                                    CmsProject project,
                                    CmsAccessControlEntry acEntry)
                             throws CmsDataAccessException
Writes an access control entry.

Parameters:
dbc - the current database context
project - the project to write the entry
acEntry - the entry to write
Throws:
CmsDataAccessException - if something goes wrong

writeGroup

public void writeGroup(CmsDbContext dbc,
                       CmsGroup group)
                throws CmsDataAccessException
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.

Parameters:
dbc - the current database context
group - the group to update
Throws:
CmsDataAccessException - if something goes wrong

writePassword

public void writePassword(CmsDbContext dbc,
                          java.lang.String userName,
                          int type,
                          java.lang.String oldPassword,
                          java.lang.String newPassword)
                   throws CmsDataAccessException,
                          CmsPasswordEncryptionException
Sets a new password for a user.

Parameters:
dbc - the current database context
userName - the user to set the password for
type - the type of the user
oldPassword - the current password
newPassword - the password to set
Throws:
CmsDataAccessException - if something goes wrong
CmsPasswordEncryptionException - if the (new) password could not be encrypted

writeUser

public void writeUser(CmsDbContext dbc,
                      CmsUser user)
               throws CmsDataAccessException
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.

Parameters:
dbc - the current database context
user - the user to update
Throws:
CmsDataAccessException - if something goes wrong

writeUserType

public void writeUserType(CmsDbContext dbc,
                          CmsUUID userId,
                          int userType)
                   throws CmsDataAccessException
Changes the user type of the given user.

Parameters:
dbc - the current database context
userId - the id of the user to change
userType - the new type of the user
Throws:
CmsDataAccessException - if something goes wrong