Multiuser Protection and the Mediator Pattern

Slides:



Advertisements
Similar presentations
Creational Patterns (2) CS350/SE310 Fall, Lower the Cost of Maintenance Economic Goal Coupling-Cohesion, Open-Close, Information-Hiding, Dependency.
Advertisements

Creational Patterns, Abstract Factory, Builder Billy Bennett June 11, 2009.
UMBC Some Additional Patterns CMSC 432. UMBC More Patterns2 Introduction Over the next few lectures we’ll have an introduction to a number of patterns.
More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott.
Iterators T.J. Niglio Computer & Systems Engineering Fall 2003 Software Design & Documentation Object Behavioral.
Design Pattern Course Builder Pattern 1 Mahdieh Monzavi AmirKabir University of Technology, Department of Computer Engineering & Information Technology.
Design Patterns CS is not simply about programming
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
Singleton Christopher Chiaverini Software Design & Documentation September 18, 2003.
BDP Behavioral Pattern. BDP-2 Behavioral Patters Concerned with algorithms & assignment of responsibilities Patterns of Communication between Objects.
02 - Behavioral Design Patterns – 2 Moshe Fresko Bar-Ilan University תשס"ח 2008.
1 GoF Template Method (pp ) GoF Strategy (pp ) PH Single User Protection (pp ) Presentation by Julie Betlach 6/08/2009.
Case Studies on Design Patterns Design Refinements Examples.
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
Mediator Pattern and Multiuser Protection Billy Bennett June 8 th, 2009.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
Computing IV Singleton Pattern Xinwen Fu.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
CS 4233 Review Feb February Review2 Outline  Previous Business – My.wpi.edu contains all grades to date for course – Review and contact.
CSE 332: Design Patterns Review: Design Pattern Structure A design pattern has a name –So when someone says “Adapter” you know what they mean –So you can.
Proxy, Observer, Symbolic Links Rebecca Chernoff.
08 - StructuralCSC4071 Structural Patterns concerned with how classes and objects are composed to form larger structures –Adapter interface converter Bridge.
Behavioural Design Patterns Quote du jour: ECE450S – Software Engineering II I have not failed. I've just found 10,000 ways that won't work. - Thomas Edison.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Billy Bennett June 22,  Intent Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
Design Patterns Introduction
The Mediator Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another using Arrays. How does one work with these.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Singleton Pattern. Problem Want to ensure a single instance of a class, shared by all uses throughout a program Context Need to address initialization.
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
1 Lecture Material Design Patterns Visitor Client-Server Factory Singleton.
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Copyright © Jim Fawcett Spring 2017
Mediator Design Pattern
Abstract Factory Pattern
Design Patterns Spring 2017.
Chapter 10 Design Patterns.
Chapter 5:Design Patterns
Software Design Patterns
MPCS – Advanced java Programming
Design Patterns Lecture part 2.
Introduction to Design Patterns
Behavioral Design Patterns
Observer Design Pattern
Design Patterns Based on slides provided by Abbie Jarrett
More Interfaces, Dynamic Binding, and Polymorphism
Chapter 3: Using Methods, Classes, and Objects
How to be a Good Developer
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
object oriented Principles of software design
Abstract Factory Pattern
Intent (Thanks to Jim Fawcett for the slides)
Software Engineering Lecture 7 - Design Patterns
Jim Fawcett CSE776 – Design Patterns Summer 2003
Mediator Design Pattern (Behavioral)
Advanced Java Programming
Dr. Bhargavi Dept of CS CHRIST
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
Strategy and Template Method Patterns, Single User Protection
Structural Patterns: Adapter and Bridge
Strategy Design Pattern
Outline Anatomy of a Class Encapsulation Anatomy of a Method
Informatics 122 Software Design II
Presentation transcript:

Multiuser Protection and the Mediator Pattern CSE432 02/22/2006 Matt Brenneke

Multiuser Protection Follow Unix design, user and other Users must have a login name Basic authentication, user must provide login name and password Follow unix design (again) 2 types of permissions for any node, those for the user, and those for other. We will address group later Treat User and login name the same, one to one mapping So how to we model a User? Using an object of course!

User Object Restrictions Clients can’t create User objects at will User object must always have a valid login name Client can’t instantiate a user w/o name and password These requirements push us towards a creational pattern at a minimum for the User object. We need a secure way to create the object, without exposing the Constructor to a client.

Creation Abstract Factory? No, Families of Objects Builder? No, different representation Factory Method? No, similar to Abstract Fact. Prototype? No, What, not How Singleton? Bingo! So lets look at the creational patterns. Abstract Factory focuses on families of objects, which we don’t have. Builder focuses on creating complex objects with the same interface and different representations Factory Method is to similar to Abstract Factory, without the focus on families Prototype focuses on what gets instantiated, now how it gets instantiated Singleton protects how the object gets created, and insures only one object is created at any given time.

Singleton - modified Authentication Multiple User objects Call Intantiate() logIn(), and add user and password parameters. Can return 0 if user or password is invalid Client can’t change logIn() by subclassing User Multiple User objects Keeps a hash of User objects Only one User object per username Patterns aren’t meant to domineer your design, just assist in it’s construction. We can change it! We need to add authentication to verify only valid users are created. Unlike a Constructor, logIn can return 0 if there is an invalid user or password By keeping our constructor private, a client can’t change the logIn process by just subclassing User. But the basic singleton pattern only allows one Instantiation of the object period. What about more than one user being given at a time?

Reading a file Before Now streamOut(ostream&); streamOut(ostream&, User*); Now when we read a file, we need to pass a user so the node can verify that the client has permission to read it Since creating a User object is protected, the Node can trust that any User object passed in is authentic. But having a client pass in the same User every time it accesses the filesystem can be a nuisance if the application is working on behalf of only one user.

Common case Give the user parameter a default value void streamOut(ostream&, const User* = 0); Add setUser and getUser functions to the User class static const User* User::getUser(); static void User::setUser(const User*); The login process for a user should call setUser once it has obtained a valid User object.

streamOut() changes Check for User* == 0 Call User::getUser() if true isReadable() -> isReadableBy(user) isReadableBy checks User->getLoginName against the Node’s owner. Node functions now must be modified to check if a User object was passed in. If one was passed in, use it, otherwise call the getUser function.

Groups? Groups have zero or more users. A user can be a member of zero or more groups. Glossed over the UNIX concept of groups earlier. Now it’s time to address them. Second item implies reference but not aggregation: Deleting a group does not delete its constituents.

Group Object Representation Composite? No Groups aren’t recursive A user might belong to several groups Don’t want to treat groups and users the same Mediator! Relationship between groups and nodes is complex and variable Needs loose coupling No groups of groups Not strictly hierachial Can’t log in as a group, don’t want to pass group objects around What can we use then? Mediator!

Mediator Overview Intent Encapsulate how a set of objects interact Promote loose coupling Allows you to vary interaction independently

Mediator Participants Interface for communicating with Colleagues ConcreteMediator (optional) Implements coordination between Colleagues Knows and maintains its Colleagues Colleague classes Knows its mediator class Communicates with Mediator only When colleagues work with only one mediator there is no reason to abstract the mediator class

Mediator Consequences Limits Subclassing Decouples Colleagues Simplifies object protocols Abstracts how objects cooperate Centralizes control May become monolithic itself Meidator pitfall is that it has a tendency towards monolithic Mediator classes.

Applied to Groups Users Groups Mediator Grouping Instead of a bunch of calls directly between users and groups, all interaction goes through the mediator Why user and not node?

Group Class members static getGrouping() static setGrouping(Grouping*, User*); register(User*,Group*,User*); unregister(User*, Group*, User*); getGroup(string, index); getUser(Group, index); Get and set groupings are static to allow mappings to be gloabally accessible and settable By replacing the Grouping object at run-time it’s possible to change the mapping in one move. setGrouping, register, and unregister are protected operations, so they must be called with an authorized User as their final argument Finally, getGroup and getUser identify associated groups and users.

Wrapping Up Chapter 2 Composite provides structure Proxy provides symlinks Visitor allows new, type specific functionality Template Method provided basic protection Singleton and Mediator combine to allow full Multi-user protection