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.String DEFAULT_LOGIN_PROMPT
    The default prompt for the login name ("Login: ").
    static java.lang.String DEFAULT_PASSWORD_PROMPT
    The default prompt for the password ("Password: ").
  • Constructor Summary

    Constructors 
    Constructor Description
    CommandLineAuthorizationCallback()
    Default Constructor.
  • Method Summary

    Modifier and Type Method Description
    void configure​(org.apache.commons.configuration.Configuration config)
    Configures the name callback.
    java.lang.String getLoginPrompt()
    Returns the login prompt text.
    java.lang.String getName()
    Asks the user on command line for name if no default name was set.
    java.lang.String getPassword()
    Asks the user on command line for a password.
    java.lang.String getPasswordPrompt()
    Returns the password prompt text.
    void setLoginPrompt​(java.lang.String loginPrompt)
    Sets a text for the login prompt.
    void setPasswordPrompt​(java.lang.String passwordPrompt)
    Sets a text for the password prompt.

    Methods inherited from class rs.baselib.security.AbstractAuthorizationCallback

    setName, setPassword

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • configure

      public void configure​(org.apache.commons.configuration.Configuration config) throws org.apache.commons.configuration.ConfigurationException
      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
      Please note, that a login-prompt definition is useless when you configured a default login name.
      Specified by:
      configure in interface IConfigurable
      Parameters:
      config - - configuration object
      Throws:
      org.apache.commons.configuration.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:
      getName in interface AuthorizationCallback
      Overrides:
      getName in class AbstractAuthorizationCallback
      Returns:
      default name or input from user.
    • getPassword

      public java.lang.String getPassword()
      Asks the user on command line for a password.
      Specified by:
      getPassword in interface AuthorizationCallback
      Overrides:
      getPassword in class AbstractAuthorizationCallback
      Returns:
      password from user