You are on page 1of 21

Assignment 2:

Adapter Pattern for Unzip Operation


Presented by:
Ekansh Garg (2020HS11509)
Abhinav Gaba (2020HS11505)
BITS Pilani
Pilani | Dubai | Goa | Hyderabad
Shubham Kumar (2020HS11502)
Adapter P attern
Broader View:

• It is one of the type of Structural patterns.

• Structural patterns are concerned with how classes and objects are composed
to form larger structures.

• These patterns follow the principle of “Code to an Interface”

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 2 BITS-Pilani
Adapter P attern
What problem does it solve:

• A Software system serves various requirements of the client.


• Some of the requirements may require processing through different kind of interfaces.
• Client can also request to add a new requirement which cannot be met with the existing
interface and may require the inclusion of an added toolkit/library.

The interfaces for different kinds of processing are sometimes incompatible and the client
may need a stable common interface for similar components being processed underneath.

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 3 BITS-Pilani
Adapter P attern

• A Software system serves various requirements of the client.


• Some of the requirements may require processing through different kind of interfaces.
• Client can also request to add a new requirement which cannot be met with the existing
interface and may require the inclusion of an added toolkit/library.

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 4 BITS-Pilani
package com.bits.ooad;

public interface SevenZipExtractor {


public void unzipFile(String zipFile);
}

public class ZipFileExtractor implements SevenZipExtractor {


@Override
public void unzipFile(String unzipFile) {
System.out.println("Unzip " + unzipFile + " using 7Zip");
}
}

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 5 BITS-Pilani
package com.bits.ooad;

public interface AlzipExtractor {


public void unzipEggFile(String eggFile);
}

public class EggFileExtractor implements AlzipExtractor{


@Override
public void unzipEggFile(String eggFile) {
System.out.println("Unzip " + eggFile + " using Alzip");
}
}

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 6 BITS-Pilani
package com.bits.ooad;

public class UnzipAdapter implements SevenZipExtractor {


AlzipExtractor zipExtractor;

public UnzipAdapter(String file) {


if(file.contains("egg")) {
zipExtractor = new EggFileExtractor();
}
}
@Override
public void unzipFile(String unzipFile) {
zipExtractor.unzipEggFile(unzipFile);
}
}

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 7 BITS-Pilani
package com.bits.ooad;

public class ZipFileExtractor implements SevenZipExtractor {


UnzipAdapter unzipAdapter;

@Override
public void unzipFile(String unzipFile) {
if(unzipFile.contains("egg")) {
unzipAdapter = new UnzipAdapter(unzipFile);
unzipAdapter.unzipFile(unzipFile);
} else {
System.out.println("Unzip " + unzipFile + " using 7Zip");
}
}
}

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 8 BITS-Pilani
package com.bits.ooad;

public class Main {


OUTPUT

public static void main(String[] args) {


// write your code here
ZipFileExtractor zipFileExtractor = new ZipFileExtractor();
zipFileExtractor.unzipFile("Abhinav.zip");
zipFileExtractor.unzipFile("Ekansh.egg");
zipFileExtractor.unzipFile("Shubham.egg");
}
}

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 9 BITS-Pilani
Need

• UML is the de facto industry standard for modelling, but standard UML diagrams are
ambiguous for domains such as IOT Security.

• There are some Modelling extensions available such as SysML and UMLsec, but they do
not address IOT Security particularly.

• So, there is need of UML modelling extension for IOT Security which the researchers
try to address through this research.

Link: https://ieeexplore.ieee.org/abstract/document/8241333?
casa_token=cvRK0yRZoNsAAAAA:8o9Fnd9mo97ULJYC7Duyo16ycWpBWAO10erwGcjFSgfpk6

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 10 BITS-Pilani
IoTsec: N omenclature
• IoTsec proposes a nomenclature with security concerns within each element. It
comprises 15 elements:
1.) N: Authentication 9.) KM: Key Management
2.) Z: Authorization 10.) IM: Identity Management
3.) C: Cypher 11.) Ps: Pseudonym
4.) D: Decipher 12.) CA: Certification Authority
5.) SS: Secure Storage 13.) RA: Registration Authority
6.) SC: Secure Communication 14.) TP: Tampering Protection
7.) B&B: IoT Broker or Bridge 15.) CC: Custom Control
8.) T&R: Trust and Reputation

• These elements are used inside of the extended UML diagrams because they are high
level abstraction of security requirements.
SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 11 BITS-Pilani
IoTsec: Actors Extension

• IoT has common actors in almost every domain.


• Researchers identified 4 actor’s categories: Sensor, Actuator, Human and IoTdevice.
• Depicting the actor with a category makes it easier for developers about the purpose of
every actor.
• Every actor is mentioned with its stereotype in the guillemets e.g. <<IoTdevice>>

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 12 BITS-Pilani
IoTsec: U se C ase Di agram Extension

• Actor’s extension are incorporated in use case diagrams.


• Nomenclature can be applied as use case if the security requirement requests it.

• Use case diagram showing an IoT Device which


has to authenticate, authorize, and cipher data
• Use cases apply nomenclature N, Z, C.
• Stereotype <<IoTdevice>> is also applied to
actor.
• Other use cases such as D, KM, IM can also be
modelled.

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 13 BITS-Pilani
IoTsec: C lass Diagram Extension

• Elements of nomenclature such N, Z, C, D can be modelled as classes.


• Actor’s stereotypes are applied along with constraints such as SS, SC, TP.

• Class diagram showing IoT Device named


RaspberryPi3 authenticates a temperature sensor
using relational class N.
• RaspberryPi3 actor is shown with stereotype
<<IoTdevice>> and restrictions TP(Tampering
protection and SS (Secure storage). Attributes and
functions are also included.
• Temperature1 shown with stereotype <<sensor>>
along with attributes and functions.
• Class N attributes are not specified but it can follow
any authentication protocol.

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 14 BITS-Pilani
IoTsec: S equence Diagram Extension

• Chronological depiction of interactions between objects.


• Messages between objects are included constraints at the end such as SC.

• Sequence Diagram showing authentication protocol


between sensor and IOT device using T&R object.
• Each actor or service is represented with object such
as sensor1:, Rpi:
• Message between each object requires secure
communication constraint. Hence [SC] is appended.
• Researchers have also included nomenclature such as
[N_Rpi] for better understanding of developers

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 15 BITS-Pilani
IoTsec: S wimlane Class Diagram

• Researchers present a Swimlane class diagram for architectural design.


• Layered architecture is followed.
• IOT security system is represented in four Swimlanes:
1. Sensing 2. Network 3. Service 4. Application

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 16 BITS-Pilani
IoTsec: S tate Di agram E xtensi on

• State diagram depicts the behaviour of an object by specifying every stage in its life.
• Example shows stages of authentication mechanism.
• Nomenclature constraints such as SS and SC are incorporated.
• Stages of N from Created till Authenticated are drawn.

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 17 BITS-Pilani
IoTsec: C ommuni cati on Di agram Extension

• Communication Diagram also depicts nomenclature elements such as SC.


• It also includes the multiplicity between different entities.

• This is a diagram of certificate emission.


• IoT Device is requesting a certificate signing.
• CA (Certification Authority) receives the request invokes
other entities KM (Key Management), IM (Identity
Management and RA (Registration Authority).
• A Valid certificate is issued to IoT Device.
• Signing process requires secure communication. SC is
achieved using TLS/SSL protocol.
• Multiplicity is correctly depicted. e.g. 0..* IOT Device to 1
CA

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 18 BITS-Pilani
IoTsec: Activi ty Diagram Extension

• In the activity diagram, nomenclature elements and


constraints are included.

• The activity diagram depicts processing of a smart lamp.


• If the sensor needs to send information in a secure
manner, [SC] is added in the process.
• For secure storage of data, [SS] is appended.

Note:
Other diagram such as deployment diagrams and component diagrams
which are out of the scope of our course, are not explained.

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 19 BITS-Pilani
IoTsec: C oncl us ion

• Security of IOT systems is a major challenge and a UML modelling extension can enhance
the design of security for a better implementation.
• IoTsec, which is a UML/SysML extension, tries encapsulate security knowledge to model
IoT systems and can prove to be a helpful tool during the designing phase.
• The security nomenclature and constraints defined by IoTsec can further be incorporated
in more real-world problems such as automation of the notation verification, exporting
XMI files,

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 20 BITS-Pilani
THANK YOU

SO OOAD
FTWARE ARC HI TE CTUR ES
- Assignment 21 BITS-Pilani

You might also like