org.opencms.db.generic
Class CmsUserDriver

java.lang.Object
  extended byorg.opencms.db.generic.CmsUserDriver
All Implemented Interfaces:
I_CmsDriver, I_CmsUserDriver
Direct Known Subclasses:
CmsUserDriver, CmsUserDriver, CmsUserDriver, CmsUserDriver, CmsUserDriver

public class CmsUserDriver
extends java.lang.Object
implements I_CmsDriver, I_CmsUserDriver

Generic (ANSI-SQL) database server implementation of the user driver methods.

Since:
6.0.0
Version:
$Revision: 1.110 $
Author:
Thomas Weckert, Carsten Weinholz, Michael Emmerich

Field Summary
protected  java.lang.String m_adminUserName
          The name of the admin user.
protected  java.security.MessageDigest m_digest
          A digest to encrypt the passwords.
protected  java.lang.String m_digestAlgorithm
          The algorithm used to encode passwords.
protected  java.lang.String m_digestFileEncoding
          The file.encoding to code passwords after encryption with digest.
protected  CmsDriverManager m_driverManager
          The driver manager.
protected  CmsSqlManager m_sqlManager
          The SQL manager.
 
Fields inherited from interface org.opencms.db.I_CmsUserDriver
DRIVER_TYPE_ID
 
Constructor Summary
CmsUserDriver()
           
 
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.
protected  void finalize()
           
 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.
 void init(CmsDbContext dbc, CmsConfigurationManager configurationManager, java.util.List successiveDrivers, CmsDriverManager driverManager)
          Initializes the driver.
 CmsSqlManager initSqlManager(java.lang.String classname)
          Initializes the SQL manager for this driver.
protected  CmsGroup internalCreateGroup(java.sql.ResultSet res)
          Semi-constructor to create a CmsGroup instance from a JDBC result set.
protected  CmsUser internalCreateUser(java.sql.ResultSet res)
          Semi-constructor to create a CmsUser instance from a JDBC result set.
protected  byte[] internalSerializeAdditionalUserInfo(java.util.Map additionalUserInfo)
          Serialize additional user information to write it as byte array in the database.
 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 class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opencms.db.I_CmsDriver
toString
 

Field Detail

m_adminUserName

protected java.lang.String m_adminUserName
The name of the admin user.


m_digest

protected java.security.MessageDigest m_digest
A digest to encrypt the passwords.


m_digestAlgorithm

protected java.lang.String m_digestAlgorithm
The algorithm used to encode passwords.


m_digestFileEncoding

protected java.lang.String m_digestFileEncoding
The file.encoding to code passwords after encryption with digest.


m_driverManager

protected CmsDriverManager m_driverManager
The driver manager.


m_sqlManager

protected CmsSqlManager m_sqlManager
The SQL manager.

Constructor Detail

CmsUserDriver

public CmsUserDriver()
Method Detail

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 interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.createAccessControlEntry(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.util.CmsUUID, org.opencms.util.CmsUUID, int, int, int)

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
Description copied from interface: I_CmsUserDriver
Creates a new group.

Specified by:
createGroup in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.createGroup(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID, java.lang.String, java.lang.String, int, java.lang.String, java.lang.Object)

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
Description copied from interface: I_CmsUserDriver
Creates a new user.

Specified by:
createUser in interface I_CmsUserDriver
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:
CmsPasswordEncryptionException - if the user password could not be encrypted
CmsDataAccessException - if something goes wrong
See Also:
I_CmsUserDriver.createUser(org.opencms.db.CmsDbContext, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, long, int, java.util.Map, java.lang.String, int)

createUserInGroup

public void createUserInGroup(CmsDbContext dbc,
                              CmsUUID userid,
                              CmsUUID groupid,
                              java.lang.Object reservedParam)
                       throws CmsDataAccessException
Description copied from interface: I_CmsUserDriver
Adds a user to a group.

Specified by:
createUserInGroup in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.createUserInGroup(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID, org.opencms.util.CmsUUID, java.lang.Object)

deleteAccessControlEntries

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

Specified by:
deleteAccessControlEntries in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.deleteAccessControlEntries(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.util.CmsUUID)

deleteGroup

public void deleteGroup(CmsDbContext dbc,
                        java.lang.String name)
                 throws CmsDataAccessException
Description copied from interface: I_CmsUserDriver
Deletes a group.

Only groups that contain no subgroups can be deleted.

Specified by:
deleteGroup in interface I_CmsUserDriver
Parameters:
dbc - the current database context
name - the name of the group that is to be deleted
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsUserDriver.deleteGroup(org.opencms.db.CmsDbContext, java.lang.String)

deleteUser

public void deleteUser(CmsDbContext dbc,
                       java.lang.String userName)
                throws CmsDataAccessException
Description copied from interface: I_CmsUserDriver
Deletes a user.

Specified by:
deleteUser in interface I_CmsUserDriver
Parameters:
dbc - the current database context
userName - the name of the user to delete
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsUserDriver.deleteUser(org.opencms.db.CmsDbContext, java.lang.String)

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 interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.deleteUserInGroup(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID, org.opencms.util.CmsUUID)

destroy

public void destroy()
             throws java.lang.Throwable
Description copied from interface: I_CmsUserDriver
Destroys this driver.

Specified by:
destroy in interface I_CmsUserDriver
Throws:
java.lang.Throwable - if something goes wrong
See Also:
I_CmsUserDriver.destroy()

existsGroup

public boolean existsGroup(CmsDbContext dbc,
                           java.lang.String groupName,
                           java.lang.Object reservedParam)
                    throws CmsDataAccessException
Description copied from interface: I_CmsUserDriver
Tests if a group with the specified name exists.

Specified by:
existsGroup in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.existsGroup(org.opencms.db.CmsDbContext, java.lang.String, java.lang.Object)

existsUser

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

Specified by:
existsUser in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.existsUser(org.opencms.db.CmsDbContext, java.lang.String, int, java.lang.Object)

getSqlManager

public CmsSqlManager getSqlManager()
Description copied from interface: I_CmsUserDriver
Returns the SqlManager of this driver.

Specified by:
getSqlManager in interface I_CmsUserDriver
Returns:
the SqlManager of this driver
See Also:
I_CmsUserDriver.getSqlManager()

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
Description copied from interface: I_CmsUserDriver
Creates a new user by import.

Specified by:
importUser in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.importUser(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, long, int, java.util.Map, java.lang.String, int, java.lang.Object)

init

public void init(CmsDbContext dbc,
                 CmsConfigurationManager configurationManager,
                 java.util.List successiveDrivers,
                 CmsDriverManager driverManager)
Description copied from interface: I_CmsDriver
Initializes the driver.

Specified by:
init in interface I_CmsDriver
Parameters:
dbc - the current database context
configurationManager - the configuration manager
successiveDrivers - a list of successive drivers to be initialized
driverManager - the initialized OpenCms driver manager
See Also:
I_CmsDriver.init(org.opencms.db.CmsDbContext, org.opencms.configuration.CmsConfigurationManager, java.util.List, org.opencms.db.CmsDriverManager)

initSqlManager

public CmsSqlManager initSqlManager(java.lang.String classname)
Description copied from interface: I_CmsUserDriver
Initializes the SQL manager for this driver.

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

Specified by:
initSqlManager in interface I_CmsUserDriver
Parameters:
classname - the classname of the SQL manager
Returns:
the SQL manager for this driver
See Also:
I_CmsUserDriver.initSqlManager(String)

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 interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.publishAccessControlEntries(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.file.CmsProject, org.opencms.util.CmsUUID, org.opencms.util.CmsUUID)

readAccessControlEntries

public java.util.List 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 interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.readAccessControlEntries(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.util.CmsUUID, boolean)

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 interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.readAccessControlEntry(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.util.CmsUUID, org.opencms.util.CmsUUID)

readChildGroups

public java.util.List readChildGroups(CmsDbContext dbc,
                                      java.lang.String groupname)
                               throws CmsDataAccessException
Description copied from interface: I_CmsUserDriver
Reads all child groups of a group.

Specified by:
readChildGroups in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.readChildGroups(org.opencms.db.CmsDbContext, java.lang.String)

readGroup

public CmsGroup readGroup(CmsDbContext dbc,
                          CmsUUID groupId)
                   throws CmsDataAccessException
Description copied from interface: I_CmsUserDriver
Reads a group based on the group id.

Specified by:
readGroup in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.readGroup(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID)

readGroup

public CmsGroup readGroup(CmsDbContext dbc,
                          java.lang.String groupName)
                   throws CmsDataAccessException
Description copied from interface: I_CmsUserDriver
Reads a group based on the group name.

Specified by:
readGroup in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.readGroup(org.opencms.db.CmsDbContext, java.lang.String)

readGroups

public java.util.List readGroups(CmsDbContext dbc)
                          throws CmsDataAccessException
Description copied from interface: I_CmsUserDriver
Reads all existing groups.

Specified by:
readGroups in interface I_CmsUserDriver
Parameters:
dbc - the current database context
Returns:
a list of all CmsGroup objects
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsUserDriver.readGroups(org.opencms.db.CmsDbContext)

readGroupsOfUser

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

Specified by:
readGroupsOfUser in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.readGroupsOfUser(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID, java.lang.String)

readUser

public CmsUser readUser(CmsDbContext dbc,
                        CmsUUID id)
                 throws CmsDataAccessException
Description copied from interface: I_CmsUserDriver
Reads a user based on the user id.

Specified by:
readUser in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.readUser(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID)

readUser

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

Specified by:
readUser in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.readUser(org.opencms.db.CmsDbContext, java.lang.String, int)

readUser

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

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

Specified by:
readUser in interface I_CmsUserDriver
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:
CmsPasswordEncryptionException - if the password of the user could not be encrypted
CmsDataAccessException - if something goes wrong
See Also:
I_CmsUserDriver.readUser(org.opencms.db.CmsDbContext, java.lang.String, java.lang.String, int)

readUser

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

Specified by:
readUser in interface I_CmsUserDriver
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:
CmsPasswordEncryptionException - if the password of the user could not be encrypted
CmsDataAccessException - if something goes wrong
See Also:
I_CmsUserDriver.readUser(org.opencms.db.CmsDbContext, java.lang.String, java.lang.String, java.lang.String, int)

readUsers

public java.util.List readUsers(CmsDbContext dbc,
                                int type)
                         throws CmsDataAccessException
Description copied from interface: I_CmsUserDriver
Reads all existing users of the given type.

Specified by:
readUsers in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.readUsers(org.opencms.db.CmsDbContext, int)

readUsersOfGroup

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

Specified by:
readUsersOfGroup in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.readUsersOfGroup(org.opencms.db.CmsDbContext, java.lang.String, int)

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 interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.removeAccessControlEntries(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.util.CmsUUID)

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 interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.removeAccessControlEntriesForPrincipal(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.file.CmsProject, org.opencms.util.CmsUUID)

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 interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.removeAccessControlEntry(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.util.CmsUUID, org.opencms.util.CmsUUID)

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 interface I_CmsUserDriver
Parameters:
dbc - the current database context
project - the project to write the entry
acEntry - the entry to write
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsUserDriver.writeAccessControlEntry(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.security.CmsAccessControlEntry)

writeGroup

public void writeGroup(CmsDbContext dbc,
                       CmsGroup group)
                throws CmsDataAccessException
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 interface I_CmsUserDriver
Parameters:
dbc - the current database context
group - the group to update
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsUserDriver.writeGroup(org.opencms.db.CmsDbContext, org.opencms.file.CmsGroup)

writePassword

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

Specified by:
writePassword in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.writePassword(org.opencms.db.CmsDbContext, java.lang.String, int, java.lang.String, java.lang.String)

writeUser

public void writeUser(CmsDbContext dbc,
                      CmsUser user)
               throws CmsDataAccessException
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 interface I_CmsUserDriver
Parameters:
dbc - the current database context
user - the user to update
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsUserDriver.writeUser(org.opencms.db.CmsDbContext, org.opencms.file.CmsUser)

writeUserType

public void writeUserType(CmsDbContext dbc,
                          CmsUUID userId,
                          int userType)
                   throws CmsDataAccessException
Description copied from interface: I_CmsUserDriver
Changes the user type of the given user.

Specified by:
writeUserType in interface I_CmsUserDriver
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
See Also:
I_CmsUserDriver.writeUserType(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID, int)

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable
See Also:
Object.finalize()

internalCreateGroup

protected CmsGroup internalCreateGroup(java.sql.ResultSet res)
                                throws java.sql.SQLException
Semi-constructor to create a CmsGroup instance from a JDBC result set.

Parameters:
res - the JDBC ResultSet
Returns:
CmsGroup the new CmsGroup object
Throws:
java.sql.SQLException - in case the result set does not include a requested table attribute

internalCreateUser

protected CmsUser internalCreateUser(java.sql.ResultSet res)
                              throws java.sql.SQLException,
                                     java.io.IOException,
                                     java.lang.ClassNotFoundException
Semi-constructor to create a CmsUser instance from a JDBC result set.

Parameters:
res - the JDBC ResultSet
Returns:
CmsUser the new CmsUser object
Throws:
java.sql.SQLException - in case the result set does not include a requested table attribute
java.io.IOException - if there is an error in deserializing the user info
java.lang.ClassNotFoundException - if there is an error in deserializing the user info

internalSerializeAdditionalUserInfo

protected byte[] internalSerializeAdditionalUserInfo(java.util.Map additionalUserInfo)
                                              throws java.io.IOException
Serialize additional user information to write it as byte array in the database.

Parameters:
additionalUserInfo - the HashTable with additional information
Returns:
byte[] the byte array which is written to the db
Throws:
java.io.IOException - if something goes wrong