Package rs.baselib.security
Class CommandLineAuthorizationCallback
java.lang.Object
rs.baselib.security.AbstractAuthorizationCallback
rs.baselib.security.CommandLineAuthorizationCallback
- All Implemented Interfaces:
IConfigurable,AuthorizationCallback
public class CommandLineAuthorizationCallback extends AbstractAuthorizationCallback implements IConfigurable
Implements authorization information retrieval from command line.
This implementation prompts the user for name (if no default name
was given) and for the password.
Configuration:
<AuthorizationCallback class="rs.baselib.security.CommandLineAuthorizationCallback">
<!-- The default user name (optional). -->
<login>default-user-name</login>
<!-- The text to be used for user name prompt (optional). -->
<login-prompt>login-prompt-text</login-prompt>
<!-- The text to be used for password prompt (optional). -->
<password-prompt>password-prompt-text</password-prompt>
</AuthorizationCallback>
- Author:
- Ralph Schuster
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_LOGIN_PROMPTThe default prompt for the login name ("Login: ").static java.lang.StringDEFAULT_PASSWORD_PROMPTThe default prompt for the password ("Password: "). -
Constructor Summary
Constructors Constructor Description CommandLineAuthorizationCallback()Default Constructor. -
Method Summary
Modifier and Type Method Description voidconfigure(Configuration config)Configures the name callback.java.lang.StringgetLoginPrompt()Returns the login prompt text.java.lang.StringgetName()Asks the user on command line for name if no default name was set.java.lang.StringgetPassword()Asks the user on command line for a password.java.lang.StringgetPasswordPrompt()Returns the password prompt text.voidsetLoginPrompt(java.lang.String loginPrompt)Sets a text for the login prompt.voidsetPasswordPrompt(java.lang.String passwordPrompt)Sets a text for the password prompt.
-
Field Details
-
DEFAULT_LOGIN_PROMPT
public static final java.lang.String DEFAULT_LOGIN_PROMPTThe default prompt for the login name ("Login: ").- See Also:
- Constant Field Values
-
DEFAULT_PASSWORD_PROMPT
public static final java.lang.String DEFAULT_PASSWORD_PROMPTThe default prompt for the password ("Password: ").- See Also:
- Constant Field Values
-
-
Constructor Details
-
CommandLineAuthorizationCallback
public CommandLineAuthorizationCallback()Default Constructor.
-
-
Method Details
-
configure
Configures the name callback. Configuration can contain three elements:- <login> - the default user name
- <login-prompt> - the prompt text for login name
- <password-prompt> - the prompt text for password
- Specified by:
configurein interfaceIConfigurable- Parameters:
config- - configuration object- Throws:
ConfigurationException- - when configuration fails
-
getLoginPrompt
public java.lang.String getLoginPrompt()Returns the login prompt text.- Returns:
- the login prompt text.
-
setLoginPrompt
public void setLoginPrompt(java.lang.String loginPrompt)Sets a text for the login prompt.- Parameters:
loginPrompt- - the login prompt text to set
-
getPasswordPrompt
public java.lang.String getPasswordPrompt()Returns the password prompt text.- Returns:
- the password prompt text
-
setPasswordPrompt
public void setPasswordPrompt(java.lang.String passwordPrompt)Sets a text for the password prompt.- Parameters:
passwordPrompt- - the password prompt text to set
-
getName
public java.lang.String getName()Asks the user on command line for name if no default name was set.- Specified by:
getNamein interfaceAuthorizationCallback- Overrides:
getNamein classAbstractAuthorizationCallback- Returns:
- default name or input from user.
-
getPassword
public java.lang.String getPassword()Asks the user on command line for a password.- Specified by:
getPasswordin interfaceAuthorizationCallback- Overrides:
getPasswordin classAbstractAuthorizationCallback- Returns:
- password from user
-