Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not...

49
Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So for example if you select an item from one part of an online catalog and request another page for another item, the item selected previously is not remembered. There are different approaches to remember the previous state. One of them is to use cookies. A cookie is a data file that is written on the user’s machine by some program on a web server/client. It contains information that is stored by a web server on a web-site-visitor’s computer. It can have information like: How many times a visitor has visited a

Transcript of Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not...

Page 1: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

CookiesHTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So for example if you select an item from one part of an online catalog and request another page for another item, the item selected previously is not remembered. There are different approaches to remember the previous state. One of them is to use cookies.

A cookie is a data file that is written on the user’s machine by some program on a web server/client. It contains information that is stored by a web server on a web-site-visitor’s computer.

It can have information like:

How many times a visitor has visited a site. What information the user has entered during past visits.Shopping carts can be implemented by using cookies.

Page 2: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Types of cookies

Temporary:

They are stored in the main memory of user’s computer and the information is available only during a session of the browser. As soon as the user exits the browser, the information is lost.

Persistent:

They are stored as text files on the hard disk of user’s computer and must have an expiration date. The information contained in such cookies is available even after the user exits the browser. The information can, however be accessed by the same web site domain name or IP address that created the cookie.

Not all browsers support creating and maintaining cookies. As a result cookies are not always a reliable way to save information.

Page 3: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Storing information in Cookies

Information in cookies is stored as name/values pairs separated by semicolon.

Document.cookie = “userid=“ &

Document.myForm.myInput.value & ”;”

for persistent coolies:

document.cookie = [cookie variable name = value];

expires= [date];

the date attribute must be written in the following format:

day, dd-mm-yy hh:mm:ss GMT like:

Tuesday, 31-Dec-2002 12:00:00 GMT

Page 4: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

System Development

Methodology

Models

Process

Strategy

Page 5: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

System Development Methodology

A methodology is a set of recommendations or steps which must be followed sequentially for a Software project.

In order to streamline the development activities a number of methodologies have been developed.

Communication is a fundamental part of the process.

Basic workflows are:

1. Project Management - responsible for

- Project glossary

- Configuration and change management

- Project Plan

- Vision

- Iteration plan

- Iteration evaluation.

Page 6: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

System Development Methodology

2. Requirement Gathering:

The goal is to unambiguously express what the proposed system should do. (Not how to do it)

3. Analysis:

Is the process of examining requirements and making conceptual model of the system to be built.

4. Design:

Applies architecture to the conceptual model obtained in the analysis stage.

5. Implementation:

Decision about programming languages, technologies to be used and tools to be employed.

Page 7: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

System Development Methodology

6. Test:

Involves evaluation of executable artifacts.

Unit test - individual components

Integration test - working together of components

System test - all requirements satisfied.

Acceptance test - formal tests performed by client.

7. Deployment:

What part goes on server and what on client.

8. Configuration and change management:

Introduce and monitor change in a controlled way.

Page 8: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

The waterfall model is a simplistic sequential model. It assumes that development can follow a step-by-step process.

You never go back to previous steps.

Requirement Gathering

Analysis and Design

Code Generation

Testing

Maintenance

Phases

Water Fall Model

Page 9: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Advantage:

•Allows for departmentalization and managerial control.

•A schedule can be set with deadlines for each stage of development

•A product can proceed through the development process like a car in a carwash, and theoretically, be delivered on time

•Development moves from concept, through design, implementation, testing, installation, troubleshooting, and ends up at operation and maintenance. Each phase of development proceeds in strict order, without any overlapping Disadvantage: •Does not allow for much reflection or revision.

•Once an application is in the testing stage, it is very difficult to go back and change something that was not well-thought out in the concept stage.

Page 10: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Initial Planning

Requirements

Analysis

Design

Implementation

Testing

Evaluation

Deployment

Iterative Modelwhere the analysis, design, code, and test sequence is executed multiple times throughout each phase of development

Page 11: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Roles of Software Development Process

Provide guidance about order of a team’s activities.

Specify what artifacts are developed.

Direct the tasks of individual developers and the team.

Offers criteria for monitoring and measuring the project’s products and activities.

(Grady Booch, RUP)

A process defines workflows, which are sets of activities that produce tangible results.

An artifact is any piece of information produced by workers in a process.

E.g. Steps in requirement gathering is a workflow and documents produced by this workflow is an artifact.

Page 12: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

The processes discussed are basically abstract processes. They must be modified and adjusted according to specific needs of a project and the organization handling it.

Project Needs:

• Human-critical applications (medical, nuclear, airplanes etc.)

need more involvement of quality assurance.• Commerce applications have architectural and security

implications.• E-commerce applications have greater emphasis on graphic

design and largely anonymous users.

System Development Strategy

Page 13: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

System Development Strategy

Organization/company needs:

Large companies with big development teams need strict process as communication between individuals performing different functions is critical.

Small teams may prefer a more relaxed process, e. g. formal meetings may not be required.

Skill Level of team members:

Relatively inexperienced teams need more defined processes in which peer reviews are more prominent.

Priorities:

Time to delivery, acceptable defect count.

Page 14: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Roll of Visual Models in Software Analysis and Design • We are not able to comprehend a complex system in its

entirety.

• Blueprints required before construction of a building.

• Different perspectives will be useful.

• Different models independent from each other required.

Good Models:• Make complex systems more understandable.

• Enhance communication among project team/customers.

• Help visualizing the complex systems.

• Ensure architectural soundness.

Page 15: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

What is UML?• A modeling language for the specification, construction, visualization and documentation of the artifacts of a software system by construction of different kinds of models.

• Provides users with ready to use core concepts.

UML Diagrams• Use Case Diagrams.

• Class Diagrams.

• Sequence Diagrams.

• Collaboration Diagrams.

• State Chart Diagrams.

• Activity Diagrams.

• Component Diagrams.

• Deployment Diagrams.

Page 16: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Sub-class

Super-Class

Sub-class

Actor

Use case

Association

Class Diagrams

Page 17: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Security Privacy and Legal Issues

Page 18: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

The essence of the problem

•Software and business processes often do things that we don’t want them to do. Hackers that may get even a limited access to your system will take advantage of any loop holes and may get valuable information or destroy / modify data.

• Executable content or mobile code.

•Allowing untrusted programs access to certain system

resources may provide a malicious program with the ability to

do mischief.• Unauthorized access to the system by insiders e.g. a

disgruntled current or previous employee.

Page 19: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Types of security attacks

Integrity Attacks Deletion/Modification of files making data

invalid. Modification of memory currently in use. Killing processes/threads.

Availability Attacks (Denial of service - DOS)Allocating large amounts of memory. Creating thousands of windows. Creating high priority processes/threads.

Disclosure Attacks Mailing information about your machine,

for example, /etc/passwd. Sending personal or company files to an

adversary or competitor over the network. Annoyance Attacks

Displaying obscene pictures on your screen. Playing unwanted sounds over your computer.

Page 20: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Examples of known security breaches

The Princeton Secure Internet Programming team (http://www.cs.princeton.edu/sip/) and others found five flaws in Java applet security in 96. It was possible for malicious scripts to disclose: All of the user's directories. Disclose all web sites that the user had visited. Report on web sites visited in the future. Forge email from the user, using Netscape Navigator. It was possible to intercept, monitor and alter on-the-fly everything that a user sees when surfing the web. Launching the personal financial software, Quicken on the user's computer and issuing a funds transfer transaction without the user's knowledge or consent. (Germany 1997)

A hacker’s attack before Christmas causing denial of service can ruin an on line distributor. Functioning of auction site can be damaged by selling at low prices. Feb 2000 DOS attack on Yahoo, eBay etc caused a lot of problems.

Page 21: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

How to achieve security?

A complete security is possible only if the system is not switched on!! Preventive security measures include:

Administrative security - consists of policies, procedures, training and staff accountability. Use of password for different levels of access to system resources.

Virus protection - A number of products have been developed for detection, protection and eradication of viruses, however new viruses are released frequently. Virus scanning defense will always lag behind the skills of some hackers. Recovery policies may provide additional protection.

Backup and Recovery - Organizations must have clear procedures for backup and recovery from attacks of hackers or hardware failures.

Page 22: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

How to achieve security?

Firewall: (in buildings, in cars, in networks)

In a computing environment a firewall is a set of related programs located at the boundary of a network that protects the resources of this network from the users of other networks. The goals of firewalls are:

To control network traffic from inside to the outside and vice versa. All traffic must pass through the firewall.

Implement a local security policy to allow only authorized traffic to pass through the firewall.

Checks all incoming and outgoing packets. Packets from specific sites can be rejected or packets from specific sites only allowed depending upon security policy.

Page 23: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

How to achieve security?

Proxy Server:

A proxy server sits between a user’s computer and the Internet to ensure security, administrative control and cashing service. It can improve performance and enhance security. All requests from users of a local area network to outside servers pass through proxy server. The proxy server hides the address of user and makes a request as if it was coming from proxy server machine. If a web page is requested that is already in the cache of proxy server, it can promptly provide it to a number of users thus improving performance. If the page is not available then the request is passed on to real server.

It works in association or is a part of the server implementing firewall. It is possible to limit access to certain servers that are not trust worthy.

Page 24: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Cryptography

• What is cryptography?• Greek words kryptus meaning hidden and graphein meaning to write.• It can also be used to support:

IntegrityAuthentication and nonrepudiation.

• Message Digests, Digital Signatures, Digital Certificates, Secret Key and Public Key security systems are based on it.

Page 25: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Caesar Cipher

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

B C D E F G H I J K L M N O P Q R S T U V W X Y Z A

Page 26: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

How Large is large?

• An n-bit key will have 2^n different keys.

• A 32 bit keys means 4,294,967,296 different keys.(large?)

• A fast computer can search through 4 billion keys in a day.

• The US government considers an algorithm using 40-bit key

space as “safe to export”. • US Data Encryption Standard (DES) uses a 56-bit key. This results in a key space of 72,057,594,037,927,936 possible keys.

• The Advance Encryption Standard (AES). (Rijndael 10/2/2000)

• Some algorithms use 128-bit keys. • The RC5 cipher of Data Security Inc. uses key sizes up to 2048 bits.

Page 27: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Encryption algorithms

• Secret-key, private-key or symmetric algorithms. DES (Data

Encryption Standard).

• Asymmetrical or public key cryptography. RSA( Rivest,

Shamir, Adleman)

• Message Digests.

• Digital Signatures.

• Digital Certificates.

• SSL.

Page 28: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Symmetric Key Cryptography

CiphertextClear text

Crypto Engine

ENCODE

Secret Key

Crypto Engine

DECODE

Secret Key

Clear text

Page 29: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

DES Encryption

Key

Plaintext CipherTextDES Encrypt

56 key bits and 8 parity bits

Page 30: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

DES Decryption

Key

Ciphertext PlainTextDES Decrypt

Same key used for decryption

Page 31: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Triple DES

Key 1

DES Encrypt

Plaintext

64 bits

CipherText

64 bits

Key 2

DES Encrypt

Key 3

DES Encrypt

Page 32: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Asymmetric Key Cryptography

Receiver’s Public Key

EncryptionPlaintext PlainText

Receiver’s Private Key

DecryptionCiphertext

Page 33: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Message Digests

Symmetric and asymmetric encryption provides secrecy of messages but not the integrity. We need to verify that the message is unchanged and uncorrupted.

The sender of a message uses a special algorithm “One Way Hash” that creates a unique identification for the message called “message digest” or “fingerprint”. It is computationally infeasible that two documents will result in the same message digest. It is also not possible to get the message back if you know the message digest. The one way hash algorithms are publicly available and anybody can use them.

If you have a message along with its message digest and the one way hash algorithm used to create the message digest, then you can recreate the message digest and compare it with one you received to verify the integrity of the message.

Page 34: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Message Digests

(Fingerprint for message)

Message Message Digest Function Message Digest

One Way

Page 35: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Message Digests

If compare then data OK

Cleartext

Message Digest

Compare

Crypto Engine Cleartext

Crypto Engine

Message Digest

Cleartext

Sender Receiver

Page 36: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Digital Signatures

Message digests ensure integrity of a message but anybody can send a message along with a message digest. How to authenticate that the message is from a particular person or organization?Nonrepudiation is a proof that a message was sent or received. It is important for secure completion of on line transaction. It protects against any attempt by originator of a message to deny sending it. It is essential for on line auctions.The above requirements are met by digital signatures.1. The sender composes the message.2. Creates a message digest using a one way hash algorithm.3. Uses his/her private key that is part of a public key encryption system to encrypt the message digest. This encrypted message digest is called the “digital signature”.4. The message is sent along with digital signature.

Page 37: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Digital Signatures

On the receiving end the receiver:

1. Separates the document from its signature.

2. Decrypts the digital signature using sender’s public key. If the digital signature is decoded the authenticity of the document is established.

3. Creates a new message digest using the one way hash algorithm with the received message. If this digest matches the digest obtained after decryption above in step 2, then integrity of the message is also confirmed.

4. The sender cannot deny sending the message as his/her private key has been used and nobody else has access to it. (Nonrepudiation)

Page 38: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Digital signatures

Digital Signature

Original Data

One Way Hash

ENCODE

Private Key

One Way Hash

ENCODE

Public Key

Original Data

Network

Digital Signature

Message Digest

Message digest

Message Digest

Identical digests validate data integrity

Page 39: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Digital Certificate

Is a unique digital ID that can be used to verify the identity of a person/ organization. The person or organization that wants to use a digital certificate must apply to a certificate authority (CA) that issues a digital certificate after verifying the identity of the applicant. This certificate has CA’s digital signature that can be checked by a user with CA’s public key.

Page 40: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Using Certificate

Certification Authority’s Digital Signature on

Name of CA

Developer’s ID

Developer’s Public Key

Expiration Date

Serial Number

Developer

Developers’ Code

Developers’ Private Key

Signature Algorithm

UserCode Signed By Developer

Verified Code

CA’s Public key

Page 41: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Secure Socket Layer (SSL)A security protocol created by Netscape for managing security of message transmissions in a network.

Works by creating a temporary shared key that is used by computers at two ends of a transmission to scramble and unscramble information.

When a client browser hits a secure web page, the server hosting that page and the browser requesting the page exchange messages to identify each other using digital signatures of the server.

The browser then uses the information in the digital certificate to create a “Master Key” that is used to encrypt the messages sent by it to the server. Thus sensitive information like credit card number etc can be exchanged.

The key becomes invalid when the customer quits a secure site and is useless for any further transactions.

Page 42: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Electronic Money

Cost of Billing

Credit Cards handle 80% electronic transactions.

CyberCash:

It works similar to SSL but in this case the merchant does not know the credit card details. It involves the following steps:

The buyer has decided to purchase an item, knows cost.

The customer’s browser sends order and credit card number in an encrypted format using public key of CyberCash.

The merchant forwards the payment information to CyberCash along with its own digital signatures.

The transaction amount is forwarded to merchant’s bank.

The bank gets payment approval from the issuer bank.

If approved the transaction is completed otherwise aborted.

Page 43: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Electronic Money

VeriFone:

Verifone have special terminals called Omni terminals that accept credit card and debit card information as well as paper checks and convert the information to electronic checks. They have agreements with a couple of banks that assure payment to the merchant electronically. All transactions are carried out in a secure way.

The advantage is that even smaller amounts are accepted for a very nominal fee unlike credit card companies.

Payment Services from VeriSign:

A merchant can put a “Payment Flow” link from Verisign and can conduct secure transactions on the internet. Very attractive for small businesses.

Page 44: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Internet and the right to privacy

Tracking devices (web bugs or clear GIFs)

Cookies

Keystroke Cops for monitoring employees.

Jurisdiction

Defamation, how to prove?

On line auctions (not qualified persons)

Intellectual property: Patents and copyrights

Social Issues.

Page 45: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Active Server Pages (ASP)

Page 46: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

Active Server Pages (ASP)

Review SSI

ASP is a text file that has a .asp extension. It contains text, html, xml and scripting commands that are interpreted by the server (by passing the file to ASP engine ) These commands can perform a number of tasks like retrieving, inserting and updating records of a database. The information generated by these commands is inserted by the server into HTML tags and the formatted page is sent to browser for display.

ASP is a Microsoft specific technology.

VBScript is the default scripting language for ASPs but Jscript or PerlScript is also accepted.

ASP commands are placed within <% …….%> script delimiter tags.

Page 47: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

ASP is simpler and faster compared to Perl and CGI.

CGI program has to be executed every time the server receives a request from a browser. ASP engine (DLL) can reside in memory and is more efficient.

ASP code cannot be viewed in the browser. This provides a degree of security.

ASP files return HTML code to the browser, therefore can be viewed in any browser.

Can make use of COM objects. Reduction in code.

If you have a personal web server (PWS) or IIS on your PC, you can run ASP on your machine without an external server.

Active Server Pages (ASP)

Page 48: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

ASP Continued

ASP Objects:

Request - QueryString, Form ...

Response - write, flush, clear, end, redirect ...

Server - CreateObject, Execute ...

Session - SessionId, onStart, onEnd ...

Application - onStart , onEnd, lock, unlock ...

Error - source, line, column, file ...

ASP components and support of ADO.

Page 49: Cookies HTTP is stateless protocol. Once the server responds to a request from browser, it does not remember what was requested and what was replied. So.

ASP Examples

Writing simple text

Calling procedures

Request and Response objects.

AdRotator