Docsity

Mail: Elaboration 1 - Lecture Notes | CS 616, Study notes of Software Engineering

Partial preview of the text

Download Mail: Elaboration 1 - Lecture Notes | CS 616 and more Study notes Software Engineering in PDF only on Docsity!

(mail)

n

Elaboration 1

CS

Fall 2004

Dr. Marchese

November 10, 2004

Elias Rosero

Jwalant Dholakia

Joseph Aulisi

Domain Model

Conceptual Class Category Examples

physical or tangible objects Physical Network, Internet Access

Terminals, and Server

specifications, designs, or

descriptions of things

System Documentation, Prototypes,

and Interface Design

Places Company Offices, and Physical Server

Location

roles of people Administrator, and User

containers of other things Server Storage Drives

things in a container Data (e-mails, contact information etc)

other computer or electro-mechanical

systems external to the system

Internet, Web Servers, and Browsers

abstract noun concepts Workaholic, and Technical

organizations End User Company

events Mail Sent, Mail Received, Mail

Deleted etc

processes

(often not represented as a concept,

but may be)

New user account Created

rules and policies Terms and Conditions of E-mail

Service use, Certificate of Liability

records of finance, work, contracts,

legal matters

Contract signed with Customer

Company

Catalogs Special Features of (mail)n listed for

access to potential buyer companies

manuals, documents, reference

papers, books

User Guide/Manual, Documentation,

Troubleshooting Manual, FAQ’s

Finding Conceptual Classes using Main Success Scenario

The following Conceptual Classes have been identified from Main Success Scenario

(Basic Flow) and other alternative scenarios for (mail)

n

specified in the Inception

Document

  • User
  • Internet
  • (mail)

n

website

  • Username / password
  • Database system
  • Inbox
  • Options
  • Reply, CC
  • Subject
  • Body
  • Send
    • Logout

Is-associated

-with

can-create

Fig: Domain Model

User

User-Id

Name

Add

Mail

Mail-Id

Administrators

To / Cc / Bcc

Email Add

Subject

Text

Body

Text

Web Mail Server

(mail)

n

website

Username/pwd

Username

Password

Internet

Inbox

Mails

Tasks

Date

Time

Contacts

Name

Add

Reply/Send Msg

Options

Is-associated-with

can-create

can-have

can-create

1

has-access-to

consists-of

contains

is-connected-to

is-connected-to

Interfaces-with

logs-on-to

Use-Case Model

System Sequence Diagram

The system sequence diagrams presented in this section are graphical

representations of the use-case scenarios presented in earlier documentation.

The system is presented as a “black box”, and the diagram has a

chronological order where time increases downward.

The following is a system sequence diagram for the “happy path” used in the

Inception document presented earlier.

Viewing Inbox Scenario

:User :(mail)n

login()

inbox(e-id, mail-id)

Display message(s)

logout()

system message

As stated in the use-case scenario, the above sequence diagram

represents a simple path of a user entering the system, and simply

viewing the contents of the inbox. After viewing the email messages,

the user logs out.

:User :(mail)n

login()

inbox()

read()

reply()

compose()

send()

System boundary

The SSDs are used to clarify the major operations that the system is designed to handle.

Therefore, SSDs are not necessary for every path through the system. We have chosen

the most common paths that (mail)n is going to be used for. The system events listed

above will be used in the following section of this elaboration document to provide

Operation Contracts.

Use-Case Model: Adding Detail with Operation Contracts

Operation contracts are used to describe the system behavior in terms of state changes to

objects in the Domain Model, after a system operation has been executed. In other

words, we use the system events in the previous section in order to identify a system

operation, and from there we elaborate on the contract. The contract specifies what the

system is required to do, and ties the relationships between the system and the domain

model (the real world).

Operation Contracts will be used only on those system operations that are deemed to be

of the most importance in (mail)n. Our domain model and design model are very similar

to each other, because an email system takes place in a cyber space where email

messages are sent electronically. Thus, the operation contracts will reflect this similarity

and use factors such as the mail server and web server to be our “real world” domain

model.

Contract C1: send

Operation: send(message-id, e-id, recipients)

Cross References: Use Case UC1: Processing Messages

Pre-Conditions: at least the “To” field is filled with a valid email address.

Post-Conditions: - a unique message id, was created

  • the message id was associated with the current e-id
  • a connection with SMPT was made
  • the database was updated to reflect the message sent

action

Contract C2: fetch

Operation: fetch(message-id, e-id, recipients, authenticator)

Cross References: Use Case UC1: Processing Messages

Pre-Conditions: there is an email(s) underway

Post-Conditions: - the message was stored in the inbox folder

  • a connection with IMAP was made
  • an authentication was made associated with creating a

session

The operation contracts are useful in that a clear association between the domain model

and the system operation is made, without the details of how it’s done. The domain

model attributes are changed, formed or broken from the system operations. And the

“post-conditions” are used to narrate those changes using plain English.

Software Architecture Document

Architectural Representation

The architecture of (mail)

n

will be described using technical memos and architectural

views.

Architectural Factors and Decisions

In the Supplementary Specification, we touched upon the factors which must be complete

when (mail)

n

is finally released. It outlines the FURPS considered during the Inception

phase. A series of technical memos follow, further detailing our original intentions.

Technical Memo

Issue: Functionality

Solution Summary: Email is saved in a database to provide permanence and accessibility.

Factors

  • (mail)n must store all email messages for individuals of a company, but must also be

able to send messages, and to save contact and task information.

Solution

Email messages are downloaded from a mail server, chopped into component parts, then

each message part is saved to the mail database. Messages are sent via an SMTP agent,

which checks the sending credentials of a user with SMTP Authorization. Each user of

(mail)

n

can store contact information and tasks to the database by issuing insert

statements.

Motivation

Email users want to be able to save the messages they have received. As a user receives

more messages, it becomes difficult to manage all this received mail. The database

provides an easy way to retrieve these messages.

Technical Memo

Issue: Security

Solution Summary: Security is provided by a mandatory login, and via SSL.

Factors

  • Users of (mail)

n

must be shielded from those who would try to gain unauthorized access

to the system.

  • Users must be reassured that their system passwords cannot be discovered by potential

intruders.

Solution

Security is provided through a call to the database, to check the provided username and

password against the database. If a match is found, a session variable is created to hold

these values. If no match is found, the intruder is locked out of the system, and shown

only the initial login page. Each page of the system must check the session variable for

proper credentials, to avoid any back-door entry into the system.

The system must be accessed via SSL to ensure that passwords are protected, and sent

over the internet as plain text.

Motivation

Corporate email is sensitive information. If (mail)

n

were easily cracked, it would never be

considered as a viable email option.

Unresolved Issues

Purchase and installation of an SSL Certificate

Technical Memo

Issue: Usability

Solution Summary: Ease of use and a comfortable web-based interface are provided.

Factors

  • Users must be comfortable working with the system.

Solution

Since (mail)

n

is web-based, it uses an interface that most people already know how to

use. The interface is friendly, and uses a color palette that is easy on the eyes.

Motivation

Email must be available to corporate users from anywhere in the world. By making

(mail)

n

a web-based application, users can easily access new messages, but also have

access to all archived messages.

Technical Memo

Issue: Reliability–Recovery from Failure

Solution Summary: Email is held offsite in case of network failure, and backed up

regularly.

Factors

The most important classes in the system are Fetch and Send. Fetch iterates through all

ids in the login table, using the id and password, makes a call to the mail server and

downloads all the mail for each user. Messages are parsed on the spot, and written to the

database. Send works a bit differently, as it takes data from an HTML form, writes each

field to the mail database, creates a singular mail message, which is then sent via

JavaMail, using SMTP Authentication.

Process View

When a new message appears on the mail server, JavaMail takes the steps necessary to

communicate with the remote mail server, supplying it with the proper user name and

password. Once the connection is made, each part of the message is easily retrieved by

JavaMail methods, finally resulting in an insert into the Mail table.

The class responsible for downloading mail, Fetch, must be run often, to ensure that

email reaches the users in a timely manner. To achieve this, it will be necessary to create

a cron job that runs the Fetch class once per minute. The Send class, on the other hand,

only has to be run when it is invoked by a user sending mail.

Use-Case View

The most architecturally significant use case is that of UC-1 Processing Messages. This

use case illustrates how an employee logs into (mail)

n

, reads the messages that have been

saved to the database, then sends a new message. This use case covers all the

architecture, as it shows the employee logging into the system via the web server. The

Fetch class, which works in the background, retrieves messages from the mail server and

saves them to the database. The web server in turn displays these messages to the

employee.

Deployment View

This deployment diagram shows the three distinct networking components, namely, the

web server, mail server and database server. The diagram shows how the Fetch process

independently POPs mail off of the mail server, and inserts it into the database. The

processes named JSP and Send are connected to the Employee. These processes are only

executed when an employee is actively using the system. When a message is sent, the

employee fills in a JSP form. The form calls the Send class as an action. The Send class

logs into the mail server using SMTP Authorization, and sends the message. The Send

process will also record this transaction to the database.

:Web Server

:Employee

:DBServer :Mail Server

<> <>

:JSP

<>

:Fetch

<>

:Send

HTTP

S

SQL

POP

SMTP

<>

Mail:postgresql

Fig: Architecture Model

<>

Employee

<> eid : varchar(12)

fname : varchar(20)

lname : varchar(20)

…

<>

Contacts

<> eid : varchar(12)

fname : varchar(20)

lname : varchar(20)

…

<>

Tasks

<> eid : varchar(12)

task : varchar(200)

time : timestamp

…

<>

Login

<> eid : varchar(12)

password : varchar(8)

isadmin : boolean

…

<>

Mail

<> mailid : text

sentby : text

sentto : text

…

<>

Sent

<> eid : varchar(12)

<> mailid : text

<>

Erase

<> eid : varchar(12)

<> mailid : text

<>

Inbox

<> eid : varchar(12)

<> mailid : text

<>

New_Folder

<> eid : varchar(12)

<> mailid : text

The Fetch class is responsible for downloading all mail into the database. It is built

around Javamail.

import java.io.*;

import java.util.Properties;

import javax.mail.*;

import javax.mail.internet.*;

public class Fetch {

public static void main (String args[])

throws Exception {

String host = "mailhost";

// Get system properties

Properties props = System.getProperties();

props.put("mail.imap.host", host);

// Setup authentication, get session

Authenticator auth = new ourOwnAuthenticator("username", "password");

Session session =

Session.getDefaultInstance(props, auth);

// Get the store

Store store = session.getStore("imap");

store.connect();

// Get folder

Folder folder = store.getFolder("INBOX");

folder.open(Folder.READ_ONLY);

// Get directory

Message message[] = folder.getMessages();

for (int i=0, n=message.length; i 200) {

content = content.substring(0, 200);

System.out.print(content)

// Close connection

folder.close(false);

store.close();

System.exit(0);

The Send class differs greatly from Fetch. Send is invoked as a servlet from compose.jsp.

Compose.jsp holds a form with the fields of an email message. Send takes these fields

and builds a message, which gets sent through JavaMail.

import java.io.IOException;

import java.io.PrintWriter;

import java.util.Properties;

import javax.mail.*;

import javax.mail.internet.*;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.servlet.RequestDispatcher;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public class send extends HttpServlet {

public void doPost(HttpServletRequest request,

HttpServletResponse response)

throws IOException, ServletException

PrintWriter writer = response.getWriter();

response.setContentType("text/html");

writer.println("");

writer.println("Mail Example");

///////// set this variable to be your SMTP host

String SMTP_HOST_NAME = "mail.ourhost.com";

String username = "username";

String password = "password";

//get the fields from the html form

String to = request.getParameter("to"); //modified Jd

String cc = request.getParameter("cc");

String bcc = request.getParameter("bcc");

String subject = request.getParameter("subject");

String body = request.getParameter("body");

try {

//Get system properties