Class AuthenticatedUser
- All Implemented Interfaces:
IAuthenticatedUser
,IBasicUserInfoDetailNames
- Author:
- Christopher Mindus
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The file name for the undefined user profile image in huge format.static final String
The file name for the undefined user profile image in huge format.static final String
The base name of the file name for profile images of a certain size.static final String
The file name for the undefined user profile image in huge format.final String
The user name.Fields inherited from interface com.iizix.user.IAuthenticatedUser
ADMIN_BACKUP_USER_NAME, ADMIN_USER_NAME, UNDEFINED_USER_NAME
Fields inherited from interface com.iizix.user.IBasicUserInfoDetailNames
DETAIL_AdditionalEmail, DETAIL_Address, DETAIL_Address_2, DETAIL_Address_3, DETAIL_City, DETAIL_CompanyDivision, DETAIL_CompanyName, DETAIL_Country, DETAIL_CroppedUploadedProfileImage, DETAIL_DBAdministrationUserName, DETAIL_DeveloperGroupID, DETAIL_DeveloperID, DETAIL_Email, DETAIL_EmailVerify, DETAIL_FirstName, DETAIL_FixedPassword, DETAIL_FullName, DETAIL_HomeFax, DETAIL_HomeMobile, DETAIL_HomePhone, DETAIL_JobTitle, DETAIL_LargeProfileImage, DETAIL_LastName, DETAIL_LocalizedFirstName, DETAIL_LocalizedFullName, DETAIL_LocalizedLastName, DETAIL_LocalizedMiddleName, DETAIL_LocalizedTitle, DETAIL_MiddleName, DETAIL_Phone, DETAIL_Phone_2, DETAIL_PinCode, DETAIL_RecoveryAnswer, DETAIL_RecoveryQuestion, DETAIL_StateProvince, DETAIL_ThumbnailProfileImage, DETAIL_Title, DETAIL_UploadedProfileImage, DETAIL_UploadedProfileImageCrop, DETAIL_WorkFax, DETAIL_WorkMobile, DETAIL_WorkPhone, DETAIL_ZipCode, detailsSet, profilePictureDetailsList
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks for equality.Gets the basic user information that was last refreshed from the database.long
Gets the last access time for the user.Gets the user's location history.getProfileImage
(int width, int height, int quality, boolean createDefault) Gets the profile image for the user scaled to the requested size.getProfileImage
(int width, int height, int quality, boolean createDefault, int rounded) Gets the profile image for the user scaled to the requested size.getProfileImage
(IAppSessionGyro appGyro, int width, int height, int quality, boolean createDefault) Gets the profile image for the user scaled to the requested size.getProfileImage
(IAppSessionGyro appGyro, int width, int height, int quality, boolean createDefault, int rounded) Gets the profile image for the user scaled to the requested size.getProfileImage
(IClientSessionGyro clientGyro, int width, int height, int quality) Gets the profile image for the user scaled to the requested size.getProfileImage
(IClientSessionGyro clientGyro, int width, int height, int quality, int rounded) Gets the profile image for the user scaled to the requested size.getProfileImageName
(int width, int height, int quality) Gets the name of the profile image for this particular user.getProfileImageName
(int width, int height, int quality, int rounded) Gets the name of the profile image for this particular user.Gets the File for the full profile picture, or any lower resolution(s) if the full profile picture is not found.getProfilePictureFile
(String detail) Gets the File for the full profile picture, or any lower resolution(s) if the full profile picture is not found.getProfilePictureFile
(String[] rcDetail) Gets the File for the full profile picture, or any lower resolution(s) if the full profile picture is not found.static AuthenticatedUser
Gets the undefined "authenticated" user.static File
Gets the file for the undefined profile image that can be used to create the requested sizes.static File
getUndefinedUserProfileImage
(File webServerRoot) Gets the file for the undefined profile image that can be used to create the requested sizes.Gets the user file provider for private user files such as images.Gets the user file provider for database backup up user files such as images.int
hashCode()
Gets the hash code of this instance.boolean
Checks if this user is the "undefined" user that is used for external login.Loads the directory of all user files that are currently present and reserves the names in the
of this user.WSFileProvider
void
Marks the user as accessed and updates the "last access" time.boolean
removeAccount
(Connection conn) Removes the user from the database.setProfileImage
(WSFileProviderEngine engine, Connection conn, String detail, File imageFile) Sets a new profile image for the user.setProfileImage
(Connection conn, String detail, File imageFile) Sets a new profile image for the user.toString()
String representation of the class.
Field Details
PROFILE_IMAGE_FILE_NAME_BASE
The base name of the file name for profile images of a certain size. The name is "profileImage-WWxHH[-quality].[png|jpg]" where HH is the height and WW the width. The quality only applies for JPG images.- See Also:
UNDEFINED_USER_PROFILE_IMAGE
The file name for the undefined user profile image in huge format.- See Also:
ADMIN_PROFILE_IMAGE
The file name for the undefined user profile image in huge format.- See Also:
ADMIN_BACKUP_PROFILE_IMAGE
The file name for the undefined user profile image in huge format.- See Also:
userName
The user name.
Method Details
getUndefinedUserProfileImage
Gets the file for the undefined profile image that can be used to create the requested sizes.- Returns:
- The file, null if not found.
- Throws:
FileNotFoundException
getUndefinedUserProfileImage
Gets the file for the undefined profile image that can be used to create the requested sizes.- Parameters:
webServerRoot
- The root of the web server.- Returns:
- The file, null if not found.
- Throws:
FileNotFoundException
getUndefinedUser
Gets the undefined "authenticated" user.- Returns:
- The instance of the undefined "authenticated" user with its file provider.
markAccessed
public void markAccessed()Marks the user as accessed and updates the "last access" time.getLastAccessedTime
public long getLastAccessedTime()Gets the last access time for the user.- Specified by:
getLastAccessedTime
in interfaceIAuthenticatedUser
- Returns:
- Time in millis since the epoch.
hashCode
public int hashCode()Gets the hash code of this instance.equals
Checks for equality.toString
String representation of the class.isUndefined
public boolean isUndefined()Checks if this user is the "undefined" user that is used for external login. Once the user is authenticated by the external framework, a real user is assigned for the session.- Specified by:
isUndefined
in interfaceIAuthenticatedUser
- Returns:
- true if user is "undefined" and false for normal users.
getBasicUserInfo
Gets the basic user information that was last refreshed from the database.- Specified by:
getBasicUserInfo
in interfaceIAuthenticatedUser
- Returns:
- The basic user information, or null if user is the "undefined" user.
removeAccount
Removes the user from the database. The "iiziAdmin" and "iiziAdmin Backup" users cannot be removed.- Parameters:
conn
- The connection.- Returns:
- true for success, false if not found.
- Throws:
SQLException
- For SQL errors.IllegalStateException
- If the basic user information is not present or if it's one of the admin users.
getLocationHistory
Gets the user's location history. The history is fed with locations from the background location service.- Specified by:
getLocationHistory
in interfaceIAuthenticatedUser
- Returns:
- An instance of the users locations history.
- Throws:
IllegalStateException
- If this call is done when the information of the user is undefined.
getUserFileProvider
Gets the user file provider for private user files such as images. The directory is created if required. Files placed in this directory can be published to the web for use in a user-local context by means of uniquely generated names to be used as URL's.- Returns:
- The WSFileProvider with files in a directory.
- Throws:
IOException
- If the user private directory failed to be created.IllegalStateException
- If the WSFileProvider is disposed (server has been stopped).
getUserFileProvider
Gets the user file provider for database backup up user files such as images. The cache directory is created if required. Files placed in this directory can be published to the web for use in a user-local context by means of uniquely generated names to be used as URL's.- Parameters:
engine
- The file provider engine (when Designer creates a profile image).- Returns:
- The WSFileProvider with files in a directory.
- Throws:
IOException
- If the user private directory failed to be created.IllegalStateException
- If the WSFileProvider is disposed (server has been stopped).
loadAllUserFiles
Loads the directory of all user files that are currently present and reserves the names in the
of this user.WSFileProvider
The key is the file name and the value is the IWSFile with a reserved name ready for publishing, but not yet published.
- Returns:
- A map of the user files, where the key string is the file name without path and the value is the
instance.IWSFile
- Throws:
IOException
- If the user private directory failed to be created or the directory failed to list its files.
setProfileImage
public IWSFile setProfileImage(Connection conn, String detail, File imageFile) throws IOException, SQLException Sets a new profile image for the user. A previous image file is upon success deleted and unpublished. The new image file is not published.- Parameters:
conn
- The connection.detail
- The image detail:
,IBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
orIBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage
.IBasicUserInfoDetailNames.DETAIL_LargeProfileImage
imageFile
- The new profile image located inside the files provider.- Returns:
- The IWSFile created.
- Throws:
IOException
- For I/O errors.SQLException
- For SQL errors.NotFoundException
- If the file doesn't exist.IllegalArgumentException
- If the file parent is not this providers root directory.IllegalArgumentException
- If the detail is not valid.IllegalStateException
- If the WSFileProvider is disposed (server has been stopped), or if the user is undefined.
setProfileImage
public IWSFile setProfileImage(WSFileProviderEngine engine, Connection conn, String detail, File imageFile) throws IOException, SQLException Sets a new profile image for the user. A previous image file is upon success deleted and unpublished. The new image file is not published. If you set thedetail
toIBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
, the two othersIBasicUserInfoDetailNames.DETAIL_LargeProfileImage
andIBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage
will be removed.- Parameters:
conn
- The connection.detail
- The image detail:
,IBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
orIBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage
.IBasicUserInfoDetailNames.DETAIL_LargeProfileImage
imageFile
- The new profile image located inside the files provider.- Returns:
- The IWSFile created.
- Throws:
IOException
- For I/O errors.SQLException
- For SQL errors.NotFoundException
- If the file doesn't exist.IllegalArgumentException
- If the file parent is not this providers root directory.IllegalArgumentException
- If the detail is not valid.IllegalStateException
- If the WSFileProvider is disposed (server has been stopped), or if the user is undefined.
getProfileImageName
Gets the name of the profile image for this particular user. This name is typically used in the AppSessionGyro instance to hold images for multiple users.- Parameters:
width
- The width requested (minimum 16, maximum 400).height
- The height requested (minimum 16, maximum 400).quality
- JPG quality 0-100, if zero a PNG is used. 100 means loss-less and 1 means really bad quality.- Returns:
- The image name.
getProfileImageName
Gets the name of the profile image for this particular user. This name is typically used in the AppSessionGyro instance to hold images for multiple users.- Parameters:
width
- The width requested (minimum 16, maximum 400).height
- The height requested (minimum 16, maximum 400).quality
- JPG quality 0-100, if zero a PNG is used. 100 means loss-less and 1 means really bad quality.rounded
- Rounded corners pixel value: if-1
half thewidth
andheight
is used as rounding values, otherwisezero
means no rounded corners (keep rectangular corners), or a pixel value ifgreater than zero
.- Returns:
- The image name.
getProfileImage
public RuntimeImageDefinition getProfileImage(IClientSessionGyro clientGyro, int width, int height, int quality) throws IOException Gets the profile image for the user scaled to the requested size. The image is created and cached in the requested size if not available. The Device Pixel Ratio is taken from the client session gyro.- Parameters:
clientGyro
- The client session gyro.width
- The width requested (minimum 16, maximum 400).height
- The height requested (minimum 16, maximum 400).quality
- JPG quality 0-100, if zero a PNG is used. 100 means loss-less and 1 means really bad quality.- Returns:
- The image definition, or
null
if a profile image is not available. - Throws:
IOException
- For file I/O errors.IllegalArgumentException
- If the width, height or quality is invalid, or if DPR=1 is not present.
getProfileImage
public RuntimeImageDefinition getProfileImage(IClientSessionGyro clientGyro, int width, int height, int quality, int rounded) throws IOException Gets the profile image for the user scaled to the requested size. The image is created and cached in the requested size if not available. The Device Pixel Ratio is taken from the client session gyro.- Parameters:
clientGyro
- The client session gyro.width
- The width requested (minimum 16, maximum 400).height
- The height requested (minimum 16, maximum 400).quality
- JPG quality 0-100, if zero a PNG is used. 100 means loss-less and 1 means really bad quality.rounded
- Value for rounded corners in pixels. Ifzero
, rectangular corners are used. The special value-1
will round the corners to half thewidth
andheight
. ifrounded
is greater than zero, it will be the rounding value in pixels of the corners. If a rounding value is used, it is multiplied with the DPR used for the created image.- Returns:
- The image definition, or
null
if a profile image is not available. - Throws:
IOException
- For file I/O errors.IllegalArgumentException
- If the width, height or quality is invalid, or if DPR=1 is not present.
getProfileImage
public RuntimeImageDefinition getProfileImage(IAppSessionGyro appGyro, int width, int height, int quality, boolean createDefault) throws IOException Gets the profile image for the user scaled to the requested size. The image is created and cached in the requested size if not available.This method will create images for the most common DPR's: 1, 1.5, 2, 3, and 4.
Profile images runtime definition is cached in the instance of the app session gyro.
- Parameters:
appGyro
- The application session gyro.width
- The width requested (minimum 16, maximum 400).height
- The height requested (minimum 16, maximum 400).quality
- JPG quality 0-100, if zero a PNG is used. 100 means loss-less and 1 means really bad quality.createDefault
- Flag indicating the image will be created from the undefined profile image if no image is present.- Returns:
- The image definition, or
null
if a profile image is not available. - Throws:
IOException
- For file I/O errors.IllegalArgumentException
- If the width, height or quality is invalid, or if DPR=1 is not present.
getProfileImage
public RuntimeImageDefinition getProfileImage(IAppSessionGyro appGyro, int width, int height, int quality, boolean createDefault, int rounded) throws IOException Gets the profile image for the user scaled to the requested size. The image is created and cached in the requested size if not available.This method will create images for the most common DPR's: 1, 1.5, 2, 3, and 4.
Profile images runtime definition is cached in the instance of the app session gyro.
- Parameters:
appGyro
- The application session gyro.width
- The width requested (minimum 16, maximum 400).height
- The height requested (minimum 16, maximum 400).quality
- JPG quality 0-100, if zero a PNG is used. 100 means loss-less and 1 means really bad quality.createDefault
- Flag indicating the image will be created from the undefined profile image if no image is present.rounded
- Value for rounded corners in pixels. Ifzero
, rectangular corners are used. The special value-1
will round the corners to half thewidth
andheight
. ifrounded
is greater than zero, it will be the rounding value in pixels of the corners. If a rounding value is used, it is multiplied with the DPR used for the created image.- Returns:
- The image definition, or
null
if a profile image is not available. - Throws:
IOException
- For file I/O errors.IllegalArgumentException
- If the width, height or quality is invalid, or if DPR=1 is not present.
getProfileImage
public RuntimeImageDefinition getProfileImage(int width, int height, int quality, boolean createDefault) throws IOException Gets the profile image for the user scaled to the requested size. The image is created and cached in the requested size if not available.This method will create images for the most common DPR's: 1, 1.5, 2, 3, and 4.
Profile images runtime definition is cached in this instance of the authenticated user.
- Parameters:
width
- The width requested (minimum 16, maximum 400).height
- The height requested (minimum 16, maximum 400).quality
- JPG quality 0-100, if zero a PNG is used. 100 means loss-less and 1 means really bad quality.createDefault
- Flag indicating the image will be created from the undefined profile image if no image is present.- Returns:
- The image definition, or
null
if a profile image is not available. - Throws:
IOException
- For file I/O errors.IllegalArgumentException
- If the width, height or quality is invalid, or if DPR=1 is not present.
getProfileImage
public RuntimeImageDefinition getProfileImage(int width, int height, int quality, boolean createDefault, int rounded) throws IOException Gets the profile image for the user scaled to the requested size. The image is created and cached in the requested size if not available.This method will create images for the most common DPR's: 1, 1.5, 2, 3, and 4.
Profile images runtime definition is cached in this instance of the authenticated user.
- Parameters:
width
- The width requested (minimum 16, maximum 400).height
- The height requested (minimum 16, maximum 400).quality
- JPG quality 0-100, if zero a PNG is used. 100 means loss-less and 1 means really bad quality.createDefault
- Flag indicating the image will be created from the undefined profile image if no image is present.rounded
- Value for rounded corners in pixels. Ifzero
, rectangular corners are used. The special value-1
will round the corners to half thewidth
andheight
. ifrounded
is greater than zero, it will be the rounding value in pixels of the corners. If a rounding value is used, it is multiplied with the DPR used for the created image.- Returns:
- The image definition, or
null
if a profile image is not available. - Throws:
IOException
- For file I/O errors.IllegalArgumentException
- If the width, height or quality is invalid, or if DPR=1 is not present.
getProfilePictureFile
Gets the File for the full profile picture, or any lower resolution(s) if the full profile picture is not found.- Returns:
- File The file for the profile picture, or null if it doesn't exist.
- Throws:
IOException
- If the file provider for the user or its root directory fails retrieving.
getProfilePictureFile
Gets the File for the full profile picture, or any lower resolution(s) if the full profile picture is not found.- Parameters:
rcDetail
- The detail of the file, must be an array of length 1, or null. Upon return and a file is found, the rcDetail[0] contains the valueIBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
,IBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
orIBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
. If a file is not found, it is set to null (if array is not null).- Returns:
- File The file for the profile picture, or null if it doesn't exist.
- Throws:
IOException
- If the file provider for the user or its root directory fails retrieving.
getProfilePictureFile
Gets the File for the full profile picture, or any lower resolution(s) if the full profile picture is not found.- Parameters:
detail
- The detail of the file, and beIBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
,IBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
orIBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
.- Returns:
- File The file for the profile picture, or null if it doesn't exist.
- Throws:
IOException
- If the file provider for the user or its root directory fails retrieving.