Posts

Showing posts with the label Design

Web Security

CSRF(Cross site request forgery) Attacker crafts a request to a website that the victim has access to. Victim is tricked to submit the request which he doesn't intend to. Victim tricked to changing  his personal information with attackers mobile/email. How To Fix: This attack can be protected by including csrf token in web forms which keeps changing for every request and every user. Referrer header is another option. Session fixation Attacker creates a session by accessing a malicious site. Persuades victim to login to the site with the same session id.  Attacker uses the same session and impersonate victim How To Fix: This attack can be prevented by creating a new session whenever user logs in. HSTS(HTTP Strict transport security) If the https protocol is omitted in the url, victim will be allowed to access the un-secured site. Since, the communication is not secured via http, victim will potentially be vulnerable to man in the middle attacks. Attacker can view the netw...

UML Class Diagram Relations

Image
CLASS RELATIONS Aggregation (COMPOSITION related) Represents a has-A relation between 2 objects Composition (COMPOSITION related) Represents a has-A relation. But, the object being referred cannot exist without the parent. Generalization (INHERITANCE related) Is-A relation between 2 classes (Represented as 'Inheritance' in diagram. But called as Generalization) Realization (INHERITANCE  related ) Is-A relation between a class and an interface. Association 1. Represents 1-1/1-Many/Many-1 relation between 2 classes. Bi-directional* 2. Represented as an arrow with role and multiplicity of the relation at the ends of the arrow.                          Dependency Same as Association. But, changes made to the dependent class impact the source.

Creational Patterns

NEED++++ Optimal way of creating the object for a given problem 1.Singleton: Creating an unique object for a class and give a global pointer/method for accessing the object 2.Factory method: Creating an object of a class from a group of classes.  Using this pattern,  we defer the object creation logic of a group of classes from client to Factory class . Here, creation logic involves picking out the right class from the group of classes for a given i/p , creating an object and returning it. 3.Abstract Factory: It overcomes the problems existing in Factory method pattern. In Factory pattern, objects creational logic is tightly coupled to the factory method in factory class. So, adding new product/sub products to the group demands code change in Factory Class.(Less maintainable) With Abstract factory, we push the object creation logic of every product/Sub product to an associated factory class . so, whenever a new product is added to the group.A new factory class h...