Package adams.core

Class PasswordHelper


  • public class PasswordHelper
    extends Object
    Helper methods for dealing with passwords (prompts, env vars).
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • PasswordHelper

        public PasswordHelper()
    • Method Detail

      • fromEnvVar

        public static <T extends EnvironmentPasswordSupporterString fromEnvVar​(T context)
        Obtains the password from the specified environment variable.
        Type Parameters:
        T - the type of context
        Parameters:
        context - the context for obtaining the env var name
        Returns:
        null if no env var specified or successfully obtained, otherwise error message
      • interact

        public static <T extends InteractiveActor & PasswordPrompterString interact​(T context)
        Performs the interaction with the user.
        Type Parameters:
        T - the type of actor
        Returns:
        null if successfully interacted, otherwise error message
      • interactHeadless

        public static <T extends InteractiveActor & PasswordPrompterString interactHeadless​(T context)
        Performs the interaction with the user in a headless environment.
        Type Parameters:
        T - the type of actor
        Returns:
        null if successfully interacted, otherwise error message
      • prompt

        public static <T extends InteractiveActor & PasswordPrompterString prompt​(T context)
        Performs the prompting, if necessary.
        Type Parameters:
        T - the type of actor
        Parameters:
        context - the actor that triggered the prompt
        Returns:
        null if successfully prompted, otherwise error message
      • promptPassword

        public static BasePassword promptPassword​(Actor context)
        Performs the interaction with the user.
        Parameters:
        context - the context to use
        Returns:
        null if successfully interacted, otherwise error message
      • promptPassword

        public static BasePassword promptPassword​(Actor context,
                                                  String labelText,
                                                  String comments)
        Performs the interaction with the user.
        Parameters:
        context - the context to use
        labelText - the text for the label, uses default if null
        comments - the comments to display, ignored if null
        Returns:
        null if successfully interacted, otherwise error message