Class AuthenticatedUser
- java.lang.Object
- com.iizix.server.user.AuthenticatedUser
 
- All Implemented Interfaces:
- IAuthenticatedUser,- IBasicUserInfoDetailNames
 - public class AuthenticatedUser extends java.lang.Object implements IBasicUserInfoDetailNames, IAuthenticatedUser Instance holding data for the "authenticated" user. This instance can be retrieved also for non-authenticated users in the system, but the user information is available in the server's users database.- Author:
- Christopher Mindus
 
- Field Summary- Fields - Modifier and Type - Field - Description - static java.lang.String- ADMIN_BACKUP_PROFILE_IMAGEThe file name for the undefined user profile image in huge format.- static java.lang.String- ADMIN_PROFILE_IMAGEThe file name for the undefined user profile image in huge format.- static java.lang.String- PROFILE_IMAGE_FILE_NAME_BASEThe base name of the file name for profile images of a certain size.- static java.lang.String- UNDEFINED_USER_PROFILE_IMAGEThe file name for the undefined user profile image in huge format.- java.lang.String- userNameThe 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- All Methods Static Methods Instance Methods Concrete Methods - Modifier and Type - Method - Description - boolean- equals(java.lang.Object o)Checks for equality.- BasicUserInfo- getBasicUserInfo()Gets the basic user information that was last refreshed from the database.- long- getLastAccessedTime()Gets the last access time for the user.- UserLocationHistory- getLocationHistory()Gets the user's location history.- RuntimeImageDefinition- getProfileImage(int width, int height, int quality, boolean createDefault)Gets the profile image for the user scaled to the requested size.- RuntimeImageDefinition- getProfileImage(int width, int height, int quality, boolean createDefault, int rounded)Gets the profile image for the user scaled to the requested size.- RuntimeImageDefinition- getProfileImage(IAppSessionGyro appGyro, int width, int height, int quality, boolean createDefault)Gets the profile image for the user scaled to the requested size.- RuntimeImageDefinition- 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.- RuntimeImageDefinition- getProfileImage(IClientSessionGyro clientGyro, int width, int height, int quality)Gets the profile image for the user scaled to the requested size.- RuntimeImageDefinition- getProfileImage(IClientSessionGyro clientGyro, int width, int height, int quality, int rounded)Gets the profile image for the user scaled to the requested size.- java.lang.String- getProfileImageName(int width, int height, int quality)Gets the name of the profile image for this particular user.- java.lang.String- getProfileImageName(int width, int height, int quality, int rounded)Gets the name of the profile image for this particular user.- java.io.File- getProfilePictureFile()Gets the File for the full profile picture, or any lower resolution(s) if the full profile picture is not found.- java.io.File- getProfilePictureFile(java.lang.String detail)Gets the File for the full profile picture, or any lower resolution(s) if the full profile picture is not found.- java.io.File- getProfilePictureFile(java.lang.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- getUndefinedUser()Gets the undefined "authenticated" user.- static java.io.File- getUndefinedUserProfileImage()Gets the file for the undefined profile image that can be used to create the requested sizes.- static java.io.File- getUndefinedUserProfileImage(java.io.File webServerRoot)Gets the file for the undefined profile image that can be used to create the requested sizes.- WSFileProvider- getUserFileProvider()Gets the user file provider for private user files such as images.- WSFileProvider- getUserFileProvider(WSFileProviderEngine engine)Gets the user file provider for database backup up user files such as images.- int- hashCode()Gets the hash code of this instance.- boolean- isUndefined()Checks if this user is the "undefined" user that is used for external login.- java.util.Map<java.lang.String,IWSFile>- loadAllUserFiles()Loads the directory of all user files that are currently present and reserves the names in the- WSFileProvider- void- markAccessed()Marks the user as accessed and updates the "last access" time.- boolean- removeAccount(java.sql.Connection conn)Removes the user from the database.- IWSFile- setProfileImage(WSFileProviderEngine engine, java.sql.Connection conn, java.lang.String detail, java.io.File imageFile)Sets a new profile image for the user.- IWSFile- setProfileImage(java.sql.Connection conn, java.lang.String detail, java.io.File imageFile)Sets a new profile image for the user.- java.lang.String- toString()String representation of the class.
 
- Field Detail- PROFILE_IMAGE_FILE_NAME_BASE- public static final java.lang.String 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:
- Constant Field Values
 
 - UNDEFINED_USER_PROFILE_IMAGE- public static final java.lang.String UNDEFINED_USER_PROFILE_IMAGE The file name for the undefined user profile image in huge format.- See Also:
- Constant Field Values
 
 - ADMIN_PROFILE_IMAGE- public static final java.lang.String ADMIN_PROFILE_IMAGE The file name for the undefined user profile image in huge format.- See Also:
- Constant Field Values
 
 - ADMIN_BACKUP_PROFILE_IMAGE- public static final java.lang.String ADMIN_BACKUP_PROFILE_IMAGE The file name for the undefined user profile image in huge format.- See Also:
- Constant Field Values
 
 - userName- public final java.lang.String userName The user name.
 
 - Method Detail- getUndefinedUserProfileImage- public static java.io.File getUndefinedUserProfileImage() throws java.io.FileNotFoundExceptionGets the file for the undefined profile image that can be used to create the requested sizes.- Returns:
- The file, null if not found.
- Throws:
- java.io.FileNotFoundException
 
 - getUndefinedUserProfileImage- public static java.io.File getUndefinedUserProfileImage(java.io.File webServerRoot) throws java.io.FileNotFoundExceptionGets 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:
- java.io.FileNotFoundException
 
 - getUndefinedUser- public static AuthenticatedUser 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:
- getLastAccessedTimein interface- IAuthenticatedUser
- Returns:
- Time in millis since the epoch.
 
 - hashCode- public int hashCode() Gets the hash code of this instance.- Overrides:
- hashCodein class- java.lang.Object
- Returns:
- The hash code.
 
 - equals- public boolean equals(java.lang.Object o) Checks for equality.- Overrides:
- equalsin class- java.lang.Object
- Parameters:
- o- The object to compare with.
- Returns:
- When equals, false otherwise.
 
 - toString- public java.lang.String toString() String representation of the class.- Overrides:
- toStringin class- java.lang.Object
- Returns:
- A string with user and distance.
 
 - 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:
- isUndefinedin interface- IAuthenticatedUser
- Returns:
- true if user is "undefined" and false for normal users.
 
 - getBasicUserInfo- public BasicUserInfo getBasicUserInfo() Gets the basic user information that was last refreshed from the database.- Specified by:
- getBasicUserInfoin interface- IAuthenticatedUser
- Returns:
- The basic user information, or null if user is the "undefined" user.
 
 - removeAccount- public boolean removeAccount(java.sql.Connection conn) throws java.sql.SQLException, java.lang.IllegalStateExceptionRemoves 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:
- java.sql.SQLException- For SQL errors.
- java.lang.IllegalStateException- If the basic user information is not present or if it's one of the admin users.
 
 - getLocationHistory- public UserLocationHistory getLocationHistory() Gets the user's location history. The history is fed with locations from the background location service.- Specified by:
- getLocationHistoryin interface- IAuthenticatedUser
- Returns:
- An instance of the users locations history.
- Throws:
- java.lang.IllegalStateException- If this call is done when the information of the user is undefined.
 
 - getUserFileProvider- public WSFileProvider getUserFileProvider() throws java.io.IOException 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:
- java.io.IOException- If the user private directory failed to be created.
- java.lang.IllegalStateException- If the WSFileProvider is disposed (server has been stopped).
 
 - getUserFileProvider- public WSFileProvider getUserFileProvider(WSFileProviderEngine engine) throws java.io.IOException 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:
- java.io.IOException- If the user private directory failed to be created.
- java.lang.IllegalStateException- If the WSFileProvider is disposed (server has been stopped).
 
 - loadAllUserFiles- public java.util.Map<java.lang.String,IWSFile> loadAllUserFiles() throws java.io.IOException Loads the directory of all user files that are currently present and reserves the names in the- 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 IWSFile
- Throws:
- java.io.IOException- If the user private directory failed to be created or the directory failed to list its files.
 
 - setProfileImage- public IWSFile setProfileImage(java.sql.Connection conn, java.lang.String detail, java.io.File imageFile) throws java.io.IOException, java.sql.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- IBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage- IBasicUserInfoDetailNames.DETAIL_LargeProfileImage
- imageFile- The new profile image located inside the files provider.
- Returns:
- The IWSFile created.
- Throws:
- java.io.IOException- For I/O errors.
- java.sql.SQLException- For SQL errors.
- NotFoundException- If the file doesn't exist.
- java.lang.IllegalArgumentException- If the file parent is not this providers root directory.
- java.lang.IllegalArgumentException- If the detail is not valid.
- java.lang.IllegalStateException- If the WSFileProvider is disposed (server has been stopped), or if the user is undefined.
 
 - setProfileImage- public IWSFile setProfileImage(WSFileProviderEngine engine, java.sql.Connection conn, java.lang.String detail, java.io.File imageFile) throws java.io.IOException, java.sql.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 the- detailto- IBasicUserInfoDetailNames.DETAIL_UploadedProfileImage, the two others- IBasicUserInfoDetailNames.DETAIL_LargeProfileImageand- IBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImagewill be removed.- Parameters:
- conn- The connection.
- detail- The image detail:- IBasicUserInfoDetailNames.DETAIL_UploadedProfileImage- IBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage- IBasicUserInfoDetailNames.DETAIL_LargeProfileImage
- imageFile- The new profile image located inside the files provider.
- Returns:
- The IWSFile created.
- Throws:
- java.io.IOException- For I/O errors.
- java.sql.SQLException- For SQL errors.
- NotFoundException- If the file doesn't exist.
- java.lang.IllegalArgumentException- If the file parent is not this providers root directory.
- java.lang.IllegalArgumentException- If the detail is not valid.
- java.lang.IllegalStateException- If the WSFileProvider is disposed (server has been stopped), or if the user is undefined.
 
 - getProfileImageName- public java.lang.String getProfileImageName(int width, int height, int quality)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- public java.lang.String getProfileImageName(int width, int height, int quality, int rounded)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- -1half the- widthand- heightis used as rounding values, otherwise- zeromeans no rounded corners (keep rectangular corners), or a pixel value if- greater than zero.
- Returns:
- The image name.
 
 - getProfileImage- public RuntimeImageDefinition getProfileImage(IClientSessionGyro clientGyro, int width, int height, int quality) throws java.io.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 nullif a profile image is not available.
- Throws:
- java.io.IOException- For file I/O errors.
- java.lang.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 java.io.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. If- zero, rectangular corners are used. The special value- -1will round the corners to half the- widthand- height. if- roundedis 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 nullif a profile image is not available.
- Throws:
- java.io.IOException- For file I/O errors.
- java.lang.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 java.io.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 nullif a profile image is not available.
- Throws:
- java.io.IOException- For file I/O errors.
- java.lang.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 java.io.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. If- zero, rectangular corners are used. The special value- -1will round the corners to half the- widthand- height. if- roundedis 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 nullif a profile image is not available.
- Throws:
- java.io.IOException- For file I/O errors.
- java.lang.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 java.io.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 nullif a profile image is not available.
- Throws:
- java.io.IOException- For file I/O errors.
- java.lang.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 java.io.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. If- zero, rectangular corners are used. The special value- -1will round the corners to half the- widthand- height. if- roundedis 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 nullif a profile image is not available.
- Throws:
- java.io.IOException- For file I/O errors.
- java.lang.IllegalArgumentException- If the width, height or quality is invalid, or if DPR=1 is not present.
 
 - getProfilePictureFile- public java.io.File getProfilePictureFile() throws java.io.IOExceptionGets 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:
- java.io.IOException- If the file provider for the user or its root directory fails retrieving.
 
 - getProfilePictureFile- public java.io.File getProfilePictureFile(java.lang.String[] rcDetail) throws java.io.IOExceptionGets 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 value- IBasicUserInfoDetailNames.DETAIL_UploadedProfileImage,- IBasicUserInfoDetailNames.DETAIL_UploadedProfileImageor- IBasicUserInfoDetailNames.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:
- java.io.IOException- If the file provider for the user or its root directory fails retrieving.
 
 - getProfilePictureFile- public java.io.File getProfilePictureFile(java.lang.String detail) throws java.io.IOExceptionGets 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 be- IBasicUserInfoDetailNames.DETAIL_UploadedProfileImage,- IBasicUserInfoDetailNames.DETAIL_UploadedProfileImageor- IBasicUserInfoDetailNames.DETAIL_UploadedProfileImage.
- Returns:
- File The file for the profile picture, or null if it doesn't exist.
- Throws:
- java.io.IOException- If the file provider for the user or its root directory fails retrieving.