STLDD – Software Top Level Design Document: BaseBlockSystem

Responsible: MH
Date: 2012-12-14
Doc. number: PUSS12004
Version: 1.0
STLDD – Software Top Level Design Document:
BaseBlockSystem
SERG
Contents
1 Introduction
2
2 Reference documents
2
3 Overview
2
4 Class diagram
3
5 Database
3
6 Information stored in sessions
4
7 Sequence diagrams
7.1 class LogIn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.2 class Administration . . . . . . . . . . . . . . . . . . . . . . . . .
4
4
4
1
Document history
Ver.
1.0
1
Date
2012-12-14
Resp.
MH
Description
First baseline version
Introduction
This document describes the design of the “BaseBlockSystem”, which is a system with log-in functionality on a web-server solution. The intention is that
the system should be used as a basic functionality for authentication and further developed into a system with useful functionality, such as a time-reporting
system.
The system is developed by the the Department of Computer Science and
the Software Engineering Research Group (SERG).
2
Reference documents
1. SRS – Software Requirements Specification, v. 1.0
2. Javadoc for BaseBlockSystem.
3
Overview
The system is implemented in a Tomcat server through the following classes
and HTML files:
class servletBase This class is the superclass for all servlets in the application.
It includes basic functionality required by many servlets, like for example
a page head written by all servlets and the connection to the database.
This application requires a database. For username and password, see the
constructor in this class.
class LogIn This servlet extends the servletBase and presents a log-in page.
The first thing that happens when a user reaches this page is that he/she
is logged out if he/she is logged in. Then the user is asked for a user
name and password. If the user is logged in he/she is directed to the
functionality selection page.
class Administration This servlet extents the servletBase and constructs a
page for administration purposes. It checks first if the user is logged in
and then if it is the administrator. If that is case it displays all users and
a form for adding new users. It is also possible to delete users through
URL:s in the table.
file functionality.html This html file presents a number of functions that the
user can select.
2
HttpServlet
Connection
1
Tomcat
jdbc
Base Block System
ServletBase
# conn: Connection
# servletBase():
# loggedIn(…): boolean
# formElement(String par): String
# getPageIntro(): String
LogIn
Administration
- logInRequestForm(): String
- checkUser(name: String, password:
String): boolean
# doGet(request: HttpServletRequest,
response: HttpServletResponse)
# doPost(request: HttpServletRequest,
response: HttpServletResponse)
- addUserForm(): String
- checkNewName(name: String): String
- createPassword(): String
- addUser(name: String): boolean
- deleteUser(name: String):
# doGet(request: HttpServletRequest,
response: HttpServletResponse)
Figure 1: Class diagram
The classes are further described in the javadoc, which is part of the SDDD,
see Ref. 2. The system also includes a database with one table as described in
Ref. 1 and Section 5.
4
Class diagram
A class diagram, with the most important classes, is displayed in Figure 1.
5
Database
There is one database, base, with one table users:
+----------+-------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| name
| varchar(10) | NO
| PRI |
|
|
| password | varchar(10) | YES |
| NULL
|
|
+----------+-------------+------+-----+---------+-------+
3
The database can be constructed from scratch with the following SQL commands:
mysql>
mysql>
mysql>
->
mysql>
->
6
create database base;
use base;
create table users(name varchar(10), password varchar(10),
primary key (name));
insert into users (name, password)
values(’admin’, ’adminpw’);
Information stored in sessions
During each session the following attributes are stored in the session:
Integer state: used to describe if the user is logged in or not. The following
two states have been defined:
0 logged out
1 logged in
String name: The user name, e.g. ’admin’.
7
7.1
Sequence diagrams
class LogIn
Figure 2 displays how a successful login request is handled in servlet LogIn, and
Figure 3 displays how an un-successful login request is handled in servlet LogIn.
7.2
class Administration
Figure 4 displays what happens in class Administration when an administrator
adds a new user.
4
:LogIn
:PrintWriter
:HttpSession
:HttpServletRe
quest
:Statement
:HttpServletRe
sponse
doPost()
println(getPageIntro())
getAttribute("state")
getParameter("user")
getParameter("password")
executeQuarry("select * from users")
setAttribute("state", LOGIN_TRUE)
sendRedirect("functionality.html")
Figure 2: Sequence diagram for handling of successful login request in class
LogIn. (Notice that all messages are not displayed; only the messages that are
important for the understanding of the sequence are displayed.)
:LogIn
:PrintWriter
:HttpSession
:HttpServletRe
quest
:Statement
:HttpServletRe
sponse
doPost()
println(getPageIntro())
getAttribute("state")
getParameter("user")
getParameter("password")
executeQuarry("select * from users")
println("That was not a valid...")
println(logInRequestForm())
Figure 3: Sequence diagram for handling of un-successful login request in class
LogIn. (Notice that all messages are not displayed; only the messages that are
important for the understanding of the sequence are displayed.)
5
:Administ
ration
:PrintWriter
:HttpSession
:HttpServletRe
quest
:Statement
doGet()
println(getPageIntro())
getAttribute("name")
getAttribute("state")
println("<h1> Administration page </h1>")
getParameter("addname")
executeUpdate("inset into users...")
getParameter("deletename")
executeQuarry("select * from users...")
println([Table])
Figure 4: Sequence diagram describing the addition of a new user in class Administration. (Notice that all messages are not displayed; only the messages
that are important for the understanding of the sequence are displayed.)
6