Synergy Home Page

au.edu.swin.synergy.plugin.userman
Class BUserManCLTools

java.lang.Object
  |
  +--au.edu.swin.synergy.plugin.userman.BUserManCLTools

public class BUserManCLTools
extends Object

This provides command tools for reading user and group information from the command line

Author:
Tristan Austin

Constructor Summary
BUserManCLTools(BUserMan userManager)
          Creates a new tools object with the user maanger to communicate with.
 
Method Summary
protected  boolean doAdminCheck(boolean displayMessage)
          This method will check to see if the currently logged in user is an administrator and if not display a message indicating that they do not have the required permission to perform the current operation.
protected  boolean doConfirm(String question, InputStream in, PrintStream out)
          This will prompt the user for confirmation as to whether they wish to go through with the current operation and return true or false depending on their response.
protected  int doGetInt(String prompt, InputStream in, PrintStream out, boolean nonNull, int lowerLimit, int upperLimit)
          This will read an integer from user and make sure that the value they type is a valid integer.
protected  String doGetString(String prompt, boolean nonNull, InputStream in, PrintStream out)
          This will prompt the user with the given message and return their response.
protected  void doInitialisation()
          This will make sure that the users and groups have been set initially.
protected  void doMessageSend(String message, int messageType)
          Provides a means of sending a message to standard out in a common place rather than re-writing everything.
protected  boolean doOwnerCheck(String userName, boolean displayMessage)
          This method will check to see whether the current user is the owner of the given user name
protected  void doShowAll(Vector items, PrintStream out)
          This will run through and display the names of all the BPrivileged items in the given Vector
protected  Vector getMembers(Vector members, InputStream in, PrintStream out)
          This method will prompt the user to select the groups this new user should be a member of by displaying the options and reading in the users responses.
protected  String getPrivilege(BPrivileged item)
          This will get the privilege from the given privileged item and return a String representing it in human readable format.
protected  BPrivileged getPrivileged(String name, Vector list)
          This will find the privileged item in the given list with the name provided and return it.
protected  void setInitialised(boolean initialised)
          Allows the other plugins to indicate when they have been initialised.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BUserManCLTools

public BUserManCLTools(BUserMan userManager)
Creates a new tools object with the user maanger to communicate with.
Parameters:
userManager - The user manager to query
Method Detail

doShowAll

protected void doShowAll(Vector items,
                         PrintStream out)
This will run through and display the names of all the BPrivileged items in the given Vector
Parameters:
items - A list of BPrivileged items to be displayed

getPrivileged

protected BPrivileged getPrivileged(String name,
                                    Vector list)
This will find the privileged item in the given list with the name provided and return it.
Parameters:
name - The name of the item to return
list - The list to search through
Returns:
The privileged item found in the list

doInitialisation

protected void doInitialisation()
This will make sure that the users and groups have been set initially. If it has already it will do nothing, otherwise it will tell the user manager to refresh the lists.

setInitialised

protected void setInitialised(boolean initialised)
Allows the other plugins to indicate when they have been initialised.
Parameters:
initialised - True to indicate initialised, false otherwise

getMembers

protected Vector getMembers(Vector members,
                            InputStream in,
                            PrintStream out)
                     throws IOException
This method will prompt the user to select the groups this new user should be a member of by displaying the options and reading in the users responses.
Parameters:
members - The available members to select from
in - The input stream to read from
out - The output stream to write to

doGetString

protected String doGetString(String prompt,
                             boolean nonNull,
                             InputStream in,
                             PrintStream out)
                      throws IOException
This will prompt the user with the given message and return their response. The response is defined as everything they type up until they press the enter key.

If the user presses enter without giving a value, it will re-prompt them

Parameters:
prompt -  

doGetInt

protected int doGetInt(String prompt,
                       InputStream in,
                       PrintStream out,
                       boolean nonNull,
                       int lowerLimit,
                       int upperLimit)
                throws IOException
This will read an integer from user and make sure that the value they type is a valid integer. It will re-prompt until they enter a valid argument.
Parameters:
prompt - The text to display to the user
in - The input stream to read from
out - The output stream to write to
nonNull - Indicates whether the response can be nothing
lowerLimit - The minimum value the user can enter
upperLimit - The maximum value the user can enter
Returns:
The value the user enters or -1 if they enter nothing

doConfirm

protected boolean doConfirm(String question,
                            InputStream in,
                            PrintStream out)
                     throws IOException
This will prompt the user for confirmation as to whether they wish to go through with the current operation and return true or false depending on their response.
Parameters:
in - The input stream to read from
out - The output stream to write to
Returns:
True to confirm, false to deny

doMessageSend

protected void doMessageSend(String message,
                             int messageType)
Provides a means of sending a message to standard out in a common place rather than re-writing everything.
Parameters:
message - The message to send
messageType - The message type BStandardOutCE.kWarning, BStandardOutCE.kError, BStandardOutCE.kInfo, BStandardOutCE.kDefaultOption

doAdminCheck

protected boolean doAdminCheck(boolean displayMessage)
This method will check to see if the currently logged in user is an administrator and if not display a message indicating that they do not have the required permission to perform the current operation.
Parameters:
out - Indicates whether to display an error message or not
Returns:
True if they are, false otherwise

doOwnerCheck

protected boolean doOwnerCheck(String userName,
                               boolean displayMessage)
This method will check to see whether the current user is the owner of the given user name
Parameters:
username - The user to check
displayMessage - Indicates whether or not to display the error
Returns:
True if they are the owner, false otherwise

getPrivilege

protected String getPrivilege(BPrivileged item)
This will get the privilege from the given privileged item and return a String representing it in human readable format.
Parameters:
item - The privileged item to get the privilege of
Returns:
The privilege as a String

Synergy Home Page