SOURCECODE

How to... use the UserManager


Description:
The UserManager is an administration tool with a huge functionality.
First of all you can store Users in it with all necessary information, even their own passwords,
which you can garble (make unreadable).
By assigning them certain Capabilities you can protect any possible Action of your application
from unauthorized access and thereby have customers and employees administered by one UserManager.

ToDo's:
  1. Add an instance of UserManager to the attributes of your Shop.
  2. Instantiate it in the constructor of the Shop

Now you can use the UserManager to manage all your customers and your personel with their capabilities and DataBaskets and so on.

Uses:
Shop  UserManager  User  



SourceCode

//The sourcecode is taken from a Shop instance

//imports
import users.*;
//...


public class VideoMachine extends Shop {

     1
    //attributes of the Shop
    private static UserManager usermanager;

    public VideoMachine() {
        super();
        
         2
        // constructor of the Shop ->instantiate the usermanager
        usermanager = new UserManager();
        
        //set usermanager the GlobalUM so it can be reached by calling UserManager.getGlobalUM()
        UserManager.setGlobalUM(usermanager);
    }

    //a method to initialize the users of the Shop
    public static void init() {
        // create a simple User as an example, calling him MasterUser
        Customer mu = new Customer("MasterUser");

        //...
        // add the MasterUser to the UserManager
        usermanager.addUser(mu);