THINK FIRST·CODE LATER

← All labs

Access matrix: ACLs and capability lists

Problem

Maintain an access matrix (domains × objects; rights are single letters, o = owner).

Commands:

  • create D O — domain D creates object O and gets rights o, r, w. Print D creates O (owner).
  • grant BY TO O rights — only a domain with o on O may grant: print BY grants rights on O to TO, or DENIED: BY is not owner of O.
  • revoke BY FROM O rights — same ownership rule: BY revokes rights on O from FROM.
  • check D O r — print check D r O: ALLOWED or DENIED.

At the end print Capability lists: with one line per domain (alphabetical) bob -> data:orw, report:r (objects alphabetical, rights sorted, empty cells omitted, none if empty), then Access control lists: with one line per object (alphabetical) report -> alice:orw, bob:r.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.