Package adams.core
Class PasswordHelper
- java.lang.Object
-
- adams.core.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 Summary
Constructors Constructor Description PasswordHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends EnvironmentPasswordSupporter>
StringfromEnvVar(T context)Obtains the password from the specified environment variable.static <T extends InteractiveActor & PasswordPrompter>
Stringinteract(T context)Performs the interaction with the user.static <T extends InteractiveActor & PasswordPrompter>
StringinteractHeadless(T context)Performs the interaction with the user in a headless environment.static <T extends InteractiveActor & PasswordPrompter>
Stringprompt(T context)Performs the prompting, if necessary.static BasePasswordpromptPassword(Actor context)Performs the interaction with the user.static BasePasswordpromptPassword(Actor context, String labelText, String comments)Performs the interaction with the user.
-
-
-
Method Detail
-
fromEnvVar
public static <T extends EnvironmentPasswordSupporter> String 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 & PasswordPrompter> String 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 & PasswordPrompter> String 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 & PasswordPrompter> String 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 uselabelText- the text for the label, uses default if nullcomments- the comments to display, ignored if null- Returns:
- null if successfully interacted, otherwise error message
-
-