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 Detail

      • initialize

        int initialize​(IClientSessionGyro clientGyro,
                       VSField user,
                       VSField password,
                       VSField rememberMe,
                       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.
        user - The user name field (String).
        password - The password field (String).
        rememberMe - The "Remember Me" 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 value is set to 0 (zero) if auto-login is not supported, 1 (one) if supported, or 2 (two) if biometric authentication is required before proceeding to login. The value of 2 (two) for biometric authentication is generally only available for internal login.
        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:
        java.lang.NullPointerException - If server is not started.
      • isUserNameFree

        boolean isUserNameFree​(IClientSessionGyro clientGyro,
                               java.lang.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,
                         java.lang.String user,
                         java.lang.String password,
                         boolean rememberMe,
                         int 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 - 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:
        true for success, false for failure. In case of failure, an error is logged in the server.
      • performExternalLogin

        void performExternalLogin​(IClientSessionGyro clientGyro,
                                  AuthenticationProvider provider,
                                  boolean rememberProvider,
                                  java.util.function.BiConsumer<LoginResult,​UserInfoBase> 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 LoginResult as first parameter, and the second parameter is the UserInfoBase user information base if the login was successful.
        Throws:
        java.lang.IllegalArgumentException - If the provider is the internal login provider.
      • performInternalLogin

        UserInfoBase performInternalLogin​(IClientSessionGyro clientGyro,
                                          java.lang.String user,
                                          java.lang.String password,
                                          boolean rememberProvider)
                                   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.
        rememberProvider - The flag to remember the internal authentication provider in case of successful login for the user's current device.
        Returns:
        The 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,
                                           java.lang.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,
                                              java.lang.String user,
                                              java.lang.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

        LoginResult changePassword​(IClientSessionGyro clientGyro,
                                   java.lang.String user,
                                   java.lang.String oldPassword,
                                   java.lang.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:
        java.lang.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:
        java.lang.IllegalStateException - If the user is not successfully logged in, or the session does not belong to the currently logged in user.