public class CSUser extends CSItem
ACCESS_GRANTED, DOES_NOT_EXIST, EMPTY, EXISTS, SECURE_ACCESS_DENIED, SECURE_ACCESS_GRANTED, UPDATE_ACTION_INSERTED, UPDATE_ACTION_UPDATED
LEVEL_ALL, LEVEL_ALL_PLUS_RELATED, LEVEL_DETAIL, LEVEL_ID, LEVEL_SUMMARY
Constructor and Description |
---|
CSUser()
Creates an empty
CSUser object. |
CSUser(java.lang.String strPropertyFile)
Creates an empty
CSUser object, specifying a property file that
contains all of the database connection details. |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
addIgnoredEmail(int userID,
java.lang.String email) |
static java.lang.String |
baseGetSQL(boolean loginUser,
int zoneId,
double databaseVersion,
boolean dbIsPostgres)
returns the basic sql string to query user details from the several joined
tables. when adding a where clause to these queries be sure to use the
appropriate table alias u = users ul and ul2 = users_login for account users
ul contains aggregate values, ul2 contains the last used values ua =
users_auth uz = users_subsitezone
|
boolean |
checkPassword(int userID,
java.lang.String strPassword)
Check a password against what is stored on the database by userID.
|
boolean |
checkPassword(java.lang.String strUsername,
java.lang.String strPassword)
Check a password against what is stored on the database by userName.
|
void |
clearIgnoredEmail(int userID,
java.lang.String email)
Clear an email from the ignored list
|
void |
delete()
Removes a user from the database.
|
boolean |
exist()
Checks to see whether a user exists on the database.
|
void |
get()
Retrieves the details of a user from the database.
|
boolean |
getAcceptMailings()
Gets the flag that indicates whether the user would like to receive mailings.
|
int |
getAccountUserID()
Gets the user's account ID (only set for login users).
|
java.util.Date |
getCreated()
Get the date the user was created.
|
java.lang.String |
getDescription()
Gets the user's description.
|
boolean |
getDisabled()
Flag that indicates whether the site user account is disabled or not.
|
java.lang.String |
getDisplayUserName()
Gets the user's display user name.
|
java.lang.String |
getEmail()
Gets the user's email.
|
int |
getFailedLinkAttempts()
Get the number of times the user has tried to link a new login to an account.
|
int |
getFailedLoginAttempts()
Returns the number of failed login attempts since the last successful login.
|
int |
getGroupID()
Gets the ID of the group currently specified as key information.
|
java.lang.String |
getGroupList()
Gets the list of group IDs currently specified as key information.
|
java.lang.String |
getHint()
Deprecated.
password hints are not supported from 10.0.7.0.
|
java.util.Date |
getLastFailedLink()
Get the Date and Time of the Last failed attempt to link a new login to an
account.
|
java.util.Date |
getLastFailedLogin()
Returns the date time when the user last failed to log in (incorrect
password, etc).
|
java.util.Date |
getLastSuccessfulLogin()
Returns the date time when the user last successfully logged in.
|
java.lang.Boolean |
getLoginUsers()
Returns true if the query operates on login users false if only account users
are to be returned/processed
|
boolean |
getPasswordCaseSensitive()
Returns a flag that indicates whether the site user's password was hashed in
a case sensitive manner, false otherwise
|
java.lang.String |
getPrefUserName()
Gets the user's preferred user name
|
java.lang.String |
getProviderName()
Gets the name of the provider used to create the user.
|
java.lang.String |
getProviderType()
Gets the type of provider used to create the user.
|
int |
getSubsiteID()
Get the SubsiteId used to discover the ZoneID.
|
CSDelimList |
getSubsiteZones()
Get the list of subsite zones the user has access to.
|
int |
getUserID()
Gets the ID of the user.
|
java.lang.String |
getUserName()
Gets the name of the user.
|
CSUserProfile |
getUserProfile()
Returns a
CSUserProfile instance corresponding to the user's user
profile object if the detail level is set to ALL_PLUS_RELATED and the user
had a user profile. |
java.lang.String |
getUserProfileType()
Gets the object type that is used to store user profile information.
|
int |
getZoneID()
Get the zone used to filter users
|
boolean |
isIgnoredEmail(int userID,
java.lang.String email)
compares the submited email against the users current email and any emails
that have been stored previously
|
void |
setAcceptMailings(boolean bAcceptMailings)
Specifies whether the user would like to receive mailings.
|
void |
setAccountUserID(int accountUserID)
Sets the user's account ID (only set for login users).
|
void |
setCreated(java.util.Date created)
Set the date the user was created.
|
void |
setDescription(java.lang.String strDescription)
Sets the description for the user.
|
void |
setDetailLevel(int nDetailLevel)
Sets the level of detail to be handled by the
get method. |
void |
setDisabled(boolean disabled)
Specifies whether the site user account is disabled or not.
|
void |
setFailedLinkAttempts(int failedLinkAttempts)
Set the number of times the user has tried to link a new login to an account
|
void |
setFailedLoginAttempts(int failedLoginAttempts)
Sets the number of failed login attempts since the last successful login.
|
void |
setGroupID(int nGroupID)
Sets the group ID to be used as key information.
|
void |
setGroupList(java.lang.String strGroupList)
Specifies a list of group IDs to be used as key information.
|
void |
setHint(java.lang.String strHint)
Deprecated.
password hints are not supported from 10.0.7.0.
|
void |
setLastFailedLink(java.util.Date lastFailedLink)
Set the Date and Time of the Last failed attempt to link a new login to an
account.
|
void |
setLastFailedLogin(java.util.Date lastFailedLogin)
Sets the date time when the user last failed to log in (incorrect password,
etc).
|
void |
setLastSuccessfulLogin(java.util.Date lastSuccessfulLogin)
Sets the date time when the user last successfully logged in.
|
void |
setLoginUsers(java.lang.Boolean loginUsers)
Specifies a value for whether or not the query will operation on users or
users_login users
|
void |
setPassword(java.lang.String strTextPassword)
Sets the user's password.
|
void |
setProviderName(java.lang.String strProviderName)
Sets the name of the provider used to create the user.
|
void |
setProviderType(java.lang.String providerType)
Sets the type of provider used to create the user.
|
void |
setSubsiteID(int subsiteID)
Set the SubsiteId used to discover the ZoneID.
|
void |
setSubsiteZones(java.lang.String subsiteZones)
Set the list of subsite zones the user has access to.
|
void |
setUserID(int nUserID)
Sets the ID of the user.
|
void |
setUserName(java.lang.String strUserName)
Sets the name of the user.
|
void |
setUserProfile(CSUserProfile userProfile)
Sets the CSUserProfile object.
|
void |
setUserProfileType(java.lang.String userProfileType)
Sets the object type that is used to store user profile information.
|
void |
setZoneID(int zoneID)
Set the zone used to filter users
|
java.lang.String |
toString()
Outputs the contents of this
CSUser object to a
String object in a user-friendly format. |
void |
update()
Updates a user on the database.
|
equals, getID, getStatus, hashCode, jsonString, serialiseWithTypes, setID, setStatus, unset
clearRecordedGatewayMessages, clone, count, getCache, getCachingEnabled, getDatabaseVersion, getDatabaseVersion, getDebugOutput, getDetailLevel, getPreview, getPropertyFile, getPropertyFileExtension, getPropertyFilePathname, getRecordedGatewayMessages, getRecordGatewayMessages, getSendGatewayMessages, getUseCache, setDebugOutput, setPreview, setPropertyFile, setRecordGatewayMessages, setSendGatewayMessages, setUseCache
public CSUser()
CSUser
object.
Use the various set methods provided to initialise the CSUser
object prior to invoking any of its query methods.
public CSUser(java.lang.String strPropertyFile)
CSUser
object, specifying a property file that
contains all of the database connection details.
Use the various set methods provided to initialise the CSUser
object prior to invoking any of its query methods.
strPropertyFile
- the name of the property file from which the database connection
details are to be read.public static java.lang.String baseGetSQL(boolean loginUser, int zoneId, double databaseVersion, boolean dbIsPostgres)
loginUser
- boolean true if the query is for login users false if account
userszoneId
- values other than 0 will join the query to users_subsitezones and
filter by the valuedatabaseVersion
- Pass in database version to support a fallback for display names
on older databasespublic void setDetailLevel(int nDetailLevel) throws CSParameterException
get
method.
Valid detail levels for a user are :
LEVEL_ID - the user ID
.
LEVEL_ALL - the user name, description, password and hint
.
Each detail level processes the information specified alongside it in addition to the information specified for all detail levels listed above it. The default detail level is LEVEL_ALL.
setDetailLevel
in class CSDatabaseItem
nDetailLevel
- the detail level to be used.CSParameterException
- if an invalid detail level is specified.public void setGroupID(int nGroupID)
setGroupID
followed by a call to exist
will
determine whether this user exists within the group identified by the
supplied ID. Use setUserID
or
setUserName
in conjunction with
setGroupID
to identify the group whose members are to be
checked.
nGroupID
- the numeric identifier of the group.public int getGroupID()
public void setGroupList(java.lang.String strGroupList)
setGroupList
followed by a call to update
will
add this user as a member of each of the listed groups.
setGroupList
followed by a call to delete
will
remove the this user from being a member of each of the listed groups.
In both instances, either the ID (setUserID
) or the
Name (setUserName
) of the user to be added as a
member should also be supplied.
strGroupList
- a String
object containing a comma-separated list of
group IDs.public java.lang.String getGroupList()
String
object containing a comma-separated list of
group IDs.public void setUserID(int nUserID)
setUserID
followed by a call to exist
will
determine whether a user with that ID exists on the database.
setUserID
followed by a call to get
will populate
this CSUser
object with that user's details.
If a user ID is specified, the update
method will update,
using the contents of this CSUser
object, the user on the
database whose ID matches.
setUserID
followed by a call to delete
will
remove the user with that ID from the database.
nUserID
- the numeric identifier of the user.public int getUserID()
public void setUserName(java.lang.String strUserName)
New users are not allowed to have any ',' characters in their name.
setUserName
followed by a call to exist
will
determine whether a user with that name exists on the database. If the user
ID is known, it will be used in preference to the name.
setUserName
followed by a call to get
will
populate this CSUser
object with details of the user with the
specified name. If the user ID is known, it will be used in preference to the
name.
If no user ID is specified, the update
method will use the
user name to update, using the contents of this CSUser
object,
the user on the database whose name matches. If none exists, a new one will
be created.
setUserName
followed by a call to delete
will
remove the user with that name from the database. If the user ID is known, it
will be used in preference to the name.
strUserName
- the user's name.public java.lang.String getUserName()
public void setUserProfileType(java.lang.String userProfileType)
As with CSUserProfile
the static default can be set via
CSObject.setDefaultUserProfileType(String)
.
userProfileType
- The user profile typepublic java.lang.String getUserProfileType()
As with CSUserProfile
the static default can be set via
CSObject.setDefaultUserProfileType(String)
.
public void setDescription(java.lang.String strDescription)
strDescription
- the user's description.public java.lang.String getDescription()
public java.util.Date getCreated()
public void setCreated(java.util.Date created)
created
- the date the user was createdpublic void setDisabled(boolean disabled)
A disabled site user cannot log in.
disabled
- true if the site user account should be disabled, false otherwise.public boolean getDisabled()
A disabled site user cannot log in.
public void setFailedLoginAttempts(int failedLoginAttempts)
This count is reset upon a successful login.
failedLoginAttempts
- The number of failed login attempts since the last successful
login.public int getFailedLoginAttempts()
This count is reset upon a successful login.
public void setLastFailedLogin(java.util.Date lastFailedLogin)
lastFailedLogin
- The date time when the user last failed to log inpublic java.util.Date getLastFailedLogin()
public void setLastSuccessfulLogin(java.util.Date lastSuccessfulLogin)
lastSuccessfulLogin
- The date time when the user last successfully logged in.public java.util.Date getLastSuccessfulLogin()
public java.util.Date getLastFailedLink()
public void setLastFailedLink(java.util.Date lastFailedLink)
lastFailedLink
- the m_lastFailedLink to setpublic int getFailedLinkAttempts()
public void setFailedLinkAttempts(int failedLinkAttempts)
failedLinkAttempts
- the m_failedLinkAttempts to setpublic void setPassword(java.lang.String strTextPassword) throws CSException
strTextPassword
- the user's password.CSException
public boolean checkPassword(java.lang.String strUsername, java.lang.String strPassword) throws CSException
strUsername
- the username of the login userstrPassword
- the plain text password to testCSException
public boolean checkPassword(int userID, java.lang.String strPassword) throws CSException
userID
- the ID of the login userstrPassword
- the plain text password to testCSException
public int getZoneID()
public void setZoneID(int zoneID)
zoneID
- the zoneId to setpublic int getSubsiteID()
public void setSubsiteID(int subsiteID)
subsiteID
- the SubsiteID to setpublic void setSubsiteZones(java.lang.String subsiteZones)
subsiteZones
- public CSDelimList getSubsiteZones()
public java.lang.String addIgnoredEmail(int userID, java.lang.String email) throws CSException, java.sql.SQLException
CSException
java.sql.SQLException
public boolean isIgnoredEmail(int userID, java.lang.String email) throws CSException, java.sql.SQLException
userID
- the id of the account in questionemail
- the email to checkCSException
- if the call is incorrectjava.sql.SQLException
- if there is a database problempublic void clearIgnoredEmail(int userID, java.lang.String email) throws CSException, java.sql.SQLException
userID
- the userID to clearemail
- the email address to removeCSException
- if something goes wrongjava.sql.SQLException
- if there is a problem with the underlying querypublic void setHint(java.lang.String strHint)
strHint
- the user's password hint.public java.lang.String getHint()
public java.lang.String getProviderName()
public void setProviderName(java.lang.String strProviderName)
strProviderName
- The name of the provider used to create the user.public void setProviderType(java.lang.String providerType)
providerType
- The type of provider used to create the user.public java.lang.String getProviderType()
public java.lang.String getEmail()
public void setAccountUserID(int accountUserID)
accountUserID
- The user's account IDpublic int getAccountUserID()
public java.lang.String getPrefUserName()
public java.lang.String getDisplayUserName()
public void setLoginUsers(java.lang.Boolean loginUsers)
loginUsers
- true if login users will be returned/processed false if only
account users will be returned/processedpublic java.lang.Boolean getLoginUsers()
public void setAcceptMailings(boolean bAcceptMailings)
bAcceptMailings
- true
if the user wants to receive mailings,
false
otherwise.public boolean getAcceptMailings()
true
if the user would like to receive mailings,
false
otherwise.public void setUserProfile(CSUserProfile userProfile)
userProfile
- The CSUserProfile object to set.public CSUserProfile getUserProfile()
CSUserProfile
instance corresponding to the user's user
profile object if the detail level is set to ALL_PLUS_RELATED and the user
had a user profile. Detail level must be set to
CSDatabaseItem.LEVEL_ALL_PLUS_RELATED
.
Returns null if the detail level is set to ALL_PLUS_RELATED and the user did not have a UserProfile.
CSUserProfile
object loaded if the detail level is set to
ALL_PLUS_RELATED and the user had a user profile.public boolean getPasswordCaseSensitive()
public boolean exist() throws CSException
Use setUserID
followed by exist
to
determine whether a user with the specified ID exists on the database.
Use setUserName
followed by exist
to determine whether a user with the specified name exists on the database.
Use setGroupID
followed by exist
to
determine whether a user is a member of the specified group. The user's ID or
name will also need to be specified via the setUserID
or setUserName
method respectively.
exist
in class CSItem
true
if the user exists on the database.CSParameterException
- if an invalid combination of key information has been supplied.CSDatabaseException
- if there are problems accessing the database.CSException
- the base class for exceptions thrown by this method.public void get() throws CSException
Use setUserID
followed by get
to
populate this CSUser
object with the details of the user
identified by the specified ID.
Use setUserName
followed by get
to
populate this CSUser
object with the details of the user
identified by the specified name.
get
in class CSItem
CSParameterException
- if an invalid combination of key information has been supplied.CSDatabaseException
- if there are problems accessing the database.CSNotFoundException
- if the specified user cannot be found on the database.CSSecurityException
- if security has been breached.CSException
- the base class for exceptions thrown by this method.public void update() throws CSException
Use update
to store the current contents of this
CSUser
object to the database. If a user with the current
ID/Name already exists, that user's details will be updated. Otherwise, a new
user will be created on the database.
Also use update
to add a user as a member of one or more groups.
Supply the groups IDs via the setGroupList
method, and the user (that is to be added as a member) via the
setUserID
or setUserName
methods prior to calling update
.
update
in class CSItem
CSParameterException
- if an invalid combination of key information has been supplied.CSDatabaseException
- if there are problems accessing the database.CSNotFoundException
- if the specified user cannot be found on the database.CSException
- the base class for exceptions thrown by this method.public void delete() throws CSException
Use setUserID
followed by delete
to
remove the user with that ID from the database.
Use setUserName
followed by delete
to remove the user with that name from the database.
Also use delete
to remove a user from being a member of one or
more groups. Supply the group IDs via the setGroupList
method, and the user (that is to be removed from the groups)
via the setUserID
or setUserName
methods prior to calling delete
.
delete
in class CSItem
CSParameterException
- if an invalid combination of key information has been supplied.CSDatabaseException
- if there are problems accessing the database.CSNotFoundException
- if the specified user cannot be found on the database.CSException
- the base class for exceptions thrown by this method.Copyright © 2022 Goss Interactive Ltd. All Rights Reserved.