org.mycore.frontend.cli
Class MCRUserCommands

java.lang.Object
  extended by org.mycore.frontend.cli.MCRAbstractCommands
      extended by org.mycore.frontend.cli.MCRUserCommands
All Implemented Interfaces:
MCRExternalCommandInterface

public class MCRUserCommands
extends MCRAbstractCommands

This class provides a set of commands for the org.mycore.user management which can be used by the command line interface.

Version:
$Revision: 15270 $ $Date: 2007-12-19 17:31:52 +0100 (Mi, 19 Dez 2007) $
Author:
Detlev Degenhardt, Frank Lützenkirchen, Jens Kupferschmidt

Field Summary
 
Fields inherited from class org.mycore.frontend.cli.MCRAbstractCommands
command, CONFIG
 
Constructor Summary
MCRUserCommands()
          The constructor.
 
Method Summary
static void addMemberUserToGroup(String mbrUserID, String groupID)
          This method adds a user as a member to a group
static void checkConsistency()
          This method checks the data consistency of the user management and should be called after a system crash or after importing data from files, respectively.
static void createGroupFromFile(String filename)
          This method invokes MCRUserMgr.createGroup() with data from a file.
static void createUserFromFile(String filename)
          This method invokes MCRUserMgr.createUser() with data from a file.
static void deleteGroup(String groupID)
          This method invokes MCRUserMgr.deleteGroup() and permanently removes a group from the system.
static void deleteUser(String userID)
          This method invokes MCRUserMgr.deleteUser() and permanently removes a user from the system.
static void disableUser(String userID)
          This method invokes MCRUserMgr.disableUser() that disables a user
static void enableUser(String userID)
          This method invokes MCRUserMgr.enableUser() that enables a user
static void encryptPasswordsInXMLFile(String oldFile, String newFile)
          A given XML file containing user data with cleartext passwords must be converted prior to loading the user data into the system.
static void exportAllGroupsToFile(String filename)
          This command takes a file name as a parameter, retrieves all groups from MCRUserMgr as JDOM document and export this to the given file.
static void exportAllUsersToFile(String filename)
          This command takes a file name as a parameter, retrieves all users from MCRUserMgr as JDOM document and export this to the given file.
static void exportGroupToFile(String groupID, String filename)
          This command takes a groupID and file name as a parameter, retrieves the group from MCRUserMgr as JDOM document and export this to the given file.
static void exportUserToFile(String userID, String filename)
          This command takes a userID and file name as a parameter, retrieves the user from MCRUserMgr as JDOM document and export this to the given file.
static void importUserSystemFromFiles(String groupFileName, String userFileName)
          This method imports groups and user data from XML files.
static void initSuperuser()
          This method initializes the user and group system an creates a superuser with values set in mycore.properties.private As 'super' default, if no properties were set, mcradmin with password mycore will be used.
static void listAllGroups()
          This method invokes MCRUserMgr.getAllGroupIDs() and retrieves a ArrayList of all groups stored in the persistent datastore.
static void listAllUsers()
          This method invokes MCRUserMgr.getAllUserIDs() and retrieves a ArrayList of all users stored in the persistent datastore.
static void listGroup(String groupID)
          This method invokes MCRUserMgr.retrieveGroup() and then works with the retrieved group object to get an XML-Representation.
static void listUser(String userID)
          This method invokes MCRUserMgr.retrieveUser() and then works with the retrieved user object to get an XML-Representation.
static void removeMemberUserFromGroup(String mbrUserID, String groupID)
          This method removes a member user from a group
static void setLock()
          This method sets the user management component to read only mode
static void setPassword(String userID, String password)
          This method invokes MCRUserMgr.retrieveUser() and then works with the retrieved user object to change the password.
static void unLock()
          This method sets the user management component to read/write access mode
static void updateUserFromFile(String filename)
          This method invokes MCRUserMgr.updateUser() with data from a file.
 
Methods inherited from class org.mycore.frontend.cli.MCRAbstractCommands
getPossibleCommands
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MCRUserCommands

public MCRUserCommands()
The constructor.

Method Detail

initSuperuser

public static void initSuperuser()
                          throws MCRException
This method initializes the user and group system an creates a superuser with values set in mycore.properties.private As 'super' default, if no properties were set, mcradmin with password mycore will be used.

Throws:
MCRException

checkConsistency

public static void checkConsistency()
                             throws Exception
This method checks the data consistency of the user management and should be called after a system crash or after importing data from files, respectively.

Throws:
Exception

deleteGroup

public static void deleteGroup(String groupID)
                        throws Exception
This method invokes MCRUserMgr.deleteGroup() and permanently removes a group from the system.

Parameters:
groupID - the ID of the group which will be deleted
Throws:
Exception

deleteUser

public static void deleteUser(String userID)
                       throws Exception
This method invokes MCRUserMgr.deleteUser() and permanently removes a user from the system.

Parameters:
userID - the ID of the user which will be deleted
Throws:
Exception

enableUser

public static void enableUser(String userID)
                       throws Exception
This method invokes MCRUserMgr.enableUser() that enables a user

Parameters:
userID - the ID of the user which will be enabled
Throws:
Exception

encryptPasswordsInXMLFile

public static final void encryptPasswordsInXMLFile(String oldFile,
                                                   String newFile)
                                            throws MCRException
A given XML file containing user data with cleartext passwords must be converted prior to loading the user data into the system. This method reads all user objects in the given XML file, encrypts the passwords and writes them back to a file with name original-file-name_encrypted.xml.

Parameters:
oldFile - the filename of the user data input
newFile - the filename of the user data output (encrypted passwords)
Throws:
MCRException

disableUser

public static void disableUser(String userID)
                        throws Exception
This method invokes MCRUserMgr.disableUser() that disables a user

Parameters:
userID - the ID of the user which will be enabled
Throws:
Exception

listAllUsers

public static void listAllUsers()
                         throws Exception
This method invokes MCRUserMgr.getAllUserIDs() and retrieves a ArrayList of all users stored in the persistent datastore.

Throws:
Exception

listAllGroups

public static void listAllGroups()
                          throws Exception
This method invokes MCRUserMgr.getAllGroupIDs() and retrieves a ArrayList of all groups stored in the persistent datastore.

Throws:
Exception

exportAllGroupsToFile

public static void exportAllGroupsToFile(String filename)
                                  throws MCRException
This command takes a file name as a parameter, retrieves all groups from MCRUserMgr as JDOM document and export this to the given file.

Parameters:
filename - Name of the file in this the groups will be exported
Throws:
MCRException

exportAllUsersToFile

public static void exportAllUsersToFile(String filename)
                                 throws MCRException
This command takes a file name as a parameter, retrieves all users from MCRUserMgr as JDOM document and export this to the given file.

Parameters:
filename - Name of the file in this the users will be exported
Throws:
MCRException

exportGroupToFile

public static void exportGroupToFile(String groupID,
                                     String filename)
                              throws Exception
This command takes a groupID and file name as a parameter, retrieves the group from MCRUserMgr as JDOM document and export this to the given file.

Parameters:
groupID - ID of the group to be saved
filename - Name of the file to store the exported group
Throws:
Exception

exportUserToFile

public static void exportUserToFile(String userID,
                                    String filename)
                             throws MCRException
This command takes a userID and file name as a parameter, retrieves the user from MCRUserMgr as JDOM document and export this to the given file.

Parameters:
userID - ID of the user to be saved
filename - Name of the file to store the exported user
Throws:
MCRException

setPassword

public static void setPassword(String userID,
                               String password)
                        throws MCRException
This method invokes MCRUserMgr.retrieveUser() and then works with the retrieved user object to change the password.

Parameters:
userID - the ID of the user for which the password will be set
Throws:
MCRException

setLock

public static void setLock()
                    throws MCRException
This method sets the user management component to read only mode

Throws:
MCRException

unLock

public static void unLock()
                   throws MCRException
This method sets the user management component to read/write access mode

Throws:
MCRException

listGroup

public static final void listGroup(String groupID)
                            throws MCRException
This method invokes MCRUserMgr.retrieveGroup() and then works with the retrieved group object to get an XML-Representation.

Parameters:
groupID - the ID of the group for which the XML-representation is needed
Throws:
MCRException

listUser

public static final void listUser(String userID)
                           throws MCRException
This method invokes MCRUserMgr.retrieveUser() and then works with the retrieved user object to get an XML-Representation.

Parameters:
userID - the ID of the user for which the XML-representation is needed
Throws:
MCRException

createUserFromFile

public static final void createUserFromFile(String filename)
This method invokes MCRUserMgr.createUser() with data from a file.

Parameters:
filename - the filename of the user data input

createGroupFromFile

public static final void createGroupFromFile(String filename)
                                      throws MCRException
This method invokes MCRUserMgr.createGroup() with data from a file.

Parameters:
filename - the filename of the user data input
Throws:
MCRException

importUserSystemFromFiles

public static final void importUserSystemFromFiles(String groupFileName,
                                                   String userFileName)
                                            throws MCRException
This method imports groups and user data from XML files. It simply call createGroupFromFile() of the MCRUserManager.

Parameters:
groupFileName - the filename of the group data input
userFileName - the filename of the user data input
Throws:
MCRException

updateUserFromFile

public static final void updateUserFromFile(String filename)
This method invokes MCRUserMgr.updateUser() with data from a file.

Parameters:
filename - the filename of the user data input

addMemberUserToGroup

public static final void addMemberUserToGroup(String mbrUserID,
                                              String groupID)
                                       throws MCRException
This method adds a user as a member to a group

Parameters:
mbrUserID - the ID of the user which will be a member of the group represented by groupID
groupID - the ID of the group to which the user with ID mbrUserID will be added
Throws:
MCRException

removeMemberUserFromGroup

public static final void removeMemberUserFromGroup(String mbrUserID,
                                                   String groupID)
                                            throws MCRException
This method removes a member user from a group

Parameters:
mbrUserID - the ID of the user which will be removed from the group represented by groupID
groupID - the ID of the group from which the user with ID mbrUserID will be removed
Throws:
MCRException