authenticate method

bool authenticate (
  1. int id,
  2. Role authority
)

Adds the id to the appropiate list (owners, controllers, executors) based on the given authority. Returns true if success, false otherwise.

Implementation

bool authenticate(int id, Role authority) {
  switch (authority) {
    case Role.user:
      executors.add(id);
      return true;

    case Role.securityOfficer:
      controllers.add(id);
      return true;

    case Role.administrator:
      owners.add(id);
      return true;
  }
  return false;
}