public abstract class UserInterface extends Object
Modifier and Type | Field and Description |
---|---|
static UserInterface |
CLI
Command-line instance.
|
static UserInterface |
GUI
Instance that uses Swing popup dialogues.
|
static UserInterface |
NO_AUTH
Instance that will not authenticate.
|
static String |
PASSWORD_PROP
Name of password system property for headless UI instance ("auth.password").
|
static String |
USERNAME_PROP
Name of username system property for headless UI instance ("auth.username").
|
Constructor and Description |
---|
UserInterface() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
canRetry()
Indicates whether there is any point in repeated attempts to
acquire credentials from the user.
|
static JComponent |
createAuthPanel(String[] msgLines,
JTextField userField,
JPasswordField passField)
Places the components for acquiring username and password.
|
static UserInterface |
createFixed(String username,
String password)
Returns a headless implementation with a fixed user name and password
supplied as strings.
|
static UserInterface |
createFixed(UserPass userpass)
Returns a headless implementation with a fixed username+password object.
|
Component |
getParent()
Returns the GUI component to which this UI is subordinate.
|
static UserInterface |
getPropertiesUi()
Returns a headless UI that takes username and password from
the system properties
USERNAME_PROP and PASSWORD_PROP
respectively, if both properties are set. |
static UserInterface |
getPropertiesUi(String userProp,
String passProp)
Returns a headless UI that takes username and password from
two named System Properties.
|
abstract void |
message(String[] lines)
Sends a message to the user.
|
abstract UserPass |
readUserPassword(String[] msgLines)
Returns a username/password pair, or null if the user declines
to supply one.
|
void |
setParent(Component parent)
Sets a GUI component to which this UI is subordinate.
|
public static final UserInterface CLI
public static final UserInterface GUI
public static final UserInterface NO_AUTH
public static final String USERNAME_PROP
public static final String PASSWORD_PROP
public abstract UserPass readUserPassword(String[] msgLines)
msgLines
- message to output to the user firstpublic abstract void message(String[] lines)
lines
- message to pass to the userpublic abstract boolean canRetry()
public void setParent(Component parent)
parent
- new parent component, may be nullpublic Component getParent()
public static UserInterface createFixed(String username, String password)
username
- usernamepassword
- passwordpublic static UserInterface createFixed(UserPass userpass)
userpass
- credentials objectpublic static UserInterface getPropertiesUi()
USERNAME_PROP
and PASSWORD_PROP
respectively, if both properties are set.
If the first character of either property value is "@", the remainder is interpreted as a filename containing the value.
Use the result of this method with care, since it risks leaking credentials to sites for which they are not intended.
This is a shortcut for
getPropertiesUi
(USERNAME_PROP
,
PASSWORD_PROP
).
public static UserInterface getPropertiesUi(String userProp, String passProp)
If the first character of either property value is "@", the remainder is interpreted as a filename containing the value.
Use the result of this method with care, since it risks leaking credentials to sites for which they are not intended.
userProp
- system property name for acquiring usernamepassProp
- system property name for acquiring passwordpublic static JComponent createAuthPanel(String[] msgLines, JTextField userField, JPasswordField passField)
msgLines
- message to display to useruserField
- field for usernamepassField
- field for passwordCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.