Interface IUserAuthenticationUI


public interface IUserAuthenticationUI
User authentication interface used for the login panel UI.

It enables saving the user authentication settings on a specific device and restoring them from previous states if the application enables it.

Automatic login is also supported.

Author:
Christopher Mindus
  • Method Details

    • initialize

      SignInPermissions initialize(IClientSessionGyro clientGyro, SignInPermissions initialPermissions, VSField user, VSField password, VSField rememberMe, VSField autoLogin, VSField authProvider) throws ValueConversionException
      Initializes the user ID, password, "Remember Me" enabled and auto-login settings.
      Parameters:
      clientGyro - The Client Session Gyro that is the cause of this initialization.
      initialPermissions - The initial permissions.
      user - The user name field (String).
      password - The password field (String).
      rememberMe - The "Remember Me" check box (Boolean).
      autoLogin - The "auto-login" check box (Boolean).
      authProvider - The previous authentication provider String, or empty String if none exists or has not been chosen on the client device. If non-empty if the user had previously chosen "Remember My Choice" for the authentication provider, i.e. the panel to choose authentication provider should be skipped.
      Returns:
      The auto-login permission.
      Throws:
      ValueConversionException - In case of value conversion errors.
    • getPasswordPolicy

      PasswordPolicy getPasswordPolicy()
      Gets the password policy property used for password validation.
      Returns:
      The password policy.
      Throws:
      NullPointerException - If server is not started.
    • isUserNameFree

      boolean isUserNameFree(IClientSessionGyro clientGyro, String user) throws UserException
      Checks if the user name is free to use, i.e. has not yet been signed up.
      Parameters:
      clientGyro - The Client Session Gyro that is the cause of this verification.
      user - The user name.
      Returns:
      true if free, false if already taken.
      Throws:
      UserException - If the user name is invalid.
    • saveUser

      boolean saveUser(IClientSessionGyro clientGyro, AuthenticationProvider provider, String user, String password, boolean rememberMe, SignInPermissions autoLogin)
      Saves the user ID, password and "Remember Me" enabled settings. This is method should be called after successful login, and PRIOR to potentially changing to an active session.

      If the application does not support saving settings, the method does nothing.

      Parameters:
      clientGyro - The Client Session Gyro that is the cause of this user data saving.
      provider - The authentication provider, or null to remove the provider for next time.
      user - The user name.
      password - The password, null when external authentication provider is used.
      rememberMe - The "Remember Me" flag, only useful for internal authentication.
      autoLogin - The permission to perform an auto-login next time also requires user, password and "Remember Me" flag. The permission
      invalid reference
      SignInPermissions#BIOMETRIC
      is generally not possible with external authentication providers, so if the authentication provider is not "Internal", then autoLogin will be set to
      invalid reference
      SignInPermissions#NOT_ALLOWED
      .
      Returns:
      true for success, false for failure. In case of failure, an error is logged in the server.
    • performExternalLogin

      SigninResult performExternalLogin(IClientSessionGyro clientGyro, AuthenticationProvider provider, boolean rememberProvider, BiConsumer<SigninResult,IAuthenticatedUser> callback)
      Performs the login for any external login authentication provider.
      Parameters:
      clientGyro - The Client Session Gyro that is the cause of this login.
      provider - The provider.
      rememberProvider - The flag to remember the external authentication provider in case of successful login for the user's current device.
      callback - The callback with SigninResult as first parameter, and the second parameter is the IAuthenticatedUser if the login was successful, null for unsuccessful logins.
      Returns:
      A SigninResult in case of error and the operation is not completed, null indicating the operation will proceed.
      Throws:
      IllegalArgumentException - If the provider is the internal login provider.
    • performInternalLogin

      IUserAuthenticationInfo performInternalLogin(IClientSessionGyro clientGyro, String user, String password) throws UserException
      Performs the login for the internal login provider.
      Parameters:
      clientGyro - The Client Session Gyro that is the cause of this login.
      user - The user name.
      password - The password.
      Returns:
      The authenticated user information.
      Throws:
      UserException - If the user login failed. Please note that the exception is NOT thrown if the user needs to change password, that must be checked using UserInfoBase.mustChangePassword().
    • performExternalSignup

      UserInfoBase performExternalSignup(IClientSessionGyro clientGyro, UserProfileInfo userProfile, AuthenticationProvider provider, boolean rememberProvider) throws UserException
      Performs a sign-up using the external authentication provider. If the user already exists matching the authentication provider, this method will only return the existing user information.
      Parameters:
      clientGyro - The Client Session Gyro that is the cause of this sign-up.
      userProfile - The user profile data.
      provider - The external authentication provider.
      rememberProvider - The flag to remember the external authentication provider in case of successful login for the user's current device.
      Returns:
      The user information.
      Throws:
      UserException - If the user sign-up failed.
    • performInternalSignup

      UserInfoBase performInternalSignup(IClientSessionGyro clientGyro, UserProfileInfo userProfile, String password, int autoLogin) throws UserException, PasswordPolicyException
      Performs a sign-up using the internal login provider. If the user already exists with matching password, this method will only return the existing user information.
      Parameters:
      clientGyro - The Client Session Gyro that is the cause of this sign-up.
      userProfile - The user profile data.
      password - The password.
      autoLogin - Perform an auto-login next time (requires user, password and "Remember Me" flag). The application or server settings may override this choice. The value can be 0 (zero) for no auto-login, 1 (one) for auto-login next time, or 2 (two) for auto-login next time with biometric authentication. The last option is generally not possible with external authentication providers, so if the authentication provider is "Internal", then the autoLogin value will be set to zero. If this value is not in range or 0 to 2, it will be set to zero.
      Returns:
      The user information.
      Throws:
      UserException - If the user sign-up failed.
      PasswordPolicyException - If the password (for internal login) does not match the password policy.
    • validatePassword

      PasswordPolicyResult validatePassword(IClientSessionGyro clientGyro, String user, String password)
      Validates the password against a password policy that would apply to the user in question.
      Parameters:
      clientGyro - The Client Session Gyro that is the cause of this validation.
      user - The user name.
      password - The password.
      Returns:
      The password policy result.
    • changePassword

      SigninResult changePassword(IClientSessionGyro clientGyro, String user, String oldPassword, String newPassword) throws PasswordPolicyException
      Changes the password for the user.
      Parameters:
      clientGyro - The Client Session Gyro that is the cause of this change.
      user - The user name.
      oldPassword - The old password.
      newPassword - The new password.
      Returns:
      The login result.
      Throws:
      PasswordPolicyException - If the new password does not match the current password policy.
    • getActiveUserSessions

      IAppSessionGyro[] getActiveUserSessions(IClientSessionGyro clientGyro)
      Gets the current user sessions that can be switched to, i.e. sessions that have been started by the logged in user.
      Parameters:
      clientGyro - The Client Session Gyro that is the cause of this change.
      Returns:
      The sessions that are started by the user. The array may be empty, indicating that no session is available to switch to.
      Throws:
      IllegalStateException - If the user is not successfully logged in.
    • switchTo

      boolean switchTo(IClientSessionGyro clientGyro, IAppSessionGyro session)
      Switches to the specified active application session. No further processing should be done after calling this method in case it returns true.
      Parameters:
      clientGyro - The Client Session Gyro that is the cause of this change.
      session - The application session to switch to.
      Returns:
      true for success, false if the session has been disposed of and that the switch never occurred.
      Throws:
      IllegalStateException - If the user is not successfully logged in, or the session does not belong to the currently logged in user.