Package com.iizix.server.user
Class UserAuthentication
- java.lang.Object
-
- com.iizix.server.user.UserAuthentication
-
- All Implemented Interfaces:
IAuthenticatedUserProvider
public class UserAuthentication extends java.lang.Object implements IAuthenticatedUserProvider
Helper class to perform user authentication. This class concentrates the calls to one location: here. It enabled implementation to external authentication systems such as JNDI or custom in-house through a Java API, etc.- Author:
- Christopher Mindus
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
createNewPasswordHash(java.lang.String userName, java.lang.String password)
Creates a new password hash to store in the database.static UserAuthentication
getInstance()
Gets the user authentication instance.AuthenticatedUser
getUser(long id)
Gets the basic user info for a user from its unique user ID.AuthenticatedUser
getUser(java.lang.String userName)
Gets the instance of a user with its information.AuthenticatedUser
getUser(java.sql.Connection conn, long id)
Gets the basic user info for a user from its unique user ID.AuthenticatedUser
getUser(java.sql.Connection conn, java.lang.String userName)
Gets the instance of a user with its information.java.util.List<UserLocation>
getUserLocations()
Finds locations of all users.boolean
isOldPasswordMatching(java.lang.Object... params)
Verifies that the old password matches before changing to a new one.UserAuthenticationInfo
validateUser(UserIdentifier userIdentifier, java.lang.String appID, java.lang.String validatePassword)
Authenticates a user ID and password.
-
-
-
Method Detail
-
getInstance
public static UserAuthentication getInstance()
Gets the user authentication instance.
-
getUserLocations
public java.util.List<UserLocation> getUserLocations()
Finds locations of all users.- Specified by:
getUserLocations
in interfaceIAuthenticatedUserProvider
-
getUser
public AuthenticatedUser getUser(java.lang.String userName)
Gets the instance of a user with its information.- Specified by:
getUser
in interfaceIAuthenticatedUserProvider
- Parameters:
userName
- The user name.- Returns:
- The instance holding the potentially authenticated user, or null if the user does not exist in the server's database.
- Throws:
java.lang.NullPointerException
- If theuserName
isnull
.
-
getUser
public AuthenticatedUser getUser(java.sql.Connection conn, java.lang.String userName)
Gets the instance of a user with its information.- Parameters:
conn
- The connection.userName
- The user name.- Returns:
- The instance holding the potentially authenticated user, or null if the user does not exist in the server's database.
-
getUser
public AuthenticatedUser getUser(long id)
Gets the basic user info for a user from its unique user ID. The value comes from
.UserInfoBase.id
- Specified by:
getUser
in interfaceIAuthenticatedUserProvider
- Parameters:
id
- The unique user ID.- Returns:
- The user information, or null if not found.
-
getUser
public AuthenticatedUser getUser(java.sql.Connection conn, long id)
Gets the basic user info for a user from its unique user ID. The value comes from
.UserInfoBase.id
- Parameters:
conn
- The connection.id
- The unique user ID.- Returns:
- The user information, or null if not found.
-
validateUser
public UserAuthenticationInfo validateUser(UserIdentifier userIdentifier, java.lang.String appID, java.lang.String validatePassword)
Authenticates a user ID and password.- Parameters:
userIdentifier
- The user identifier.appID
- The app ID to validate.validatePassword
- The password to validate. If the password is empty, the user is authenticated as pre-validation used e.g. by the iiziRun Developer listing possible sessions, etc. When this parameter is null, the real password is not validated.- Returns:
- The user authentication result.
-
createNewPasswordHash
public java.lang.String createNewPasswordHash(java.lang.String userName, java.lang.String password)
Creates a new password hash to store in the database. The password is not decryptable.- Parameters:
userName
- The basic user information.password
- The new password.- Returns:
- The new password hash.
-
isOldPasswordMatching
public boolean isOldPasswordMatching(java.lang.Object... params)
Verifies that the old password matches before changing to a new one.- Parameters:
params
- Parameters.- Returns:
- true for success, false if not matching.
-
-