Escolar Documentos
Profissional Documentos
Cultura Documentos
By James Collett
Overview Of System
The purpose of the program is to simulate a networked Banking System or Bank Account Management System. The primary facilities and capabilities which the program offers include:
Creating new accounts Accessing existing accounts Depositing and withdrawing money Setting overdraft limits
The program simulates, and allows for the manipulation of three types of bank account:
Current Accounts do not support an overdraft limit. Platinum and Student Accounts do support an overdraft limit. The program does not facilitate interest rates and does not calculate interest. The program does not implement any account security (such as a PIN number) to prevent access to existing accounts. The program allows access to accounts, given a valid and existing account number.
(A detailed description and specification of the system is included in the Technical Documentation.)
The Server program represents a central banking system, and the Client program represents a terminal or teller machine at an individual (or peripheral) branch. The system requires both the Server and the Client to be running concurrently one cannot be used without the other. The primary objective of the simulator is to demonstrate a communication system between the Client and the Server, and not to demonstrate a complete range of facilities which a Bank may offer (such as PIN numbers or interest rates). The Server should be launched first, and will wait for the Client. The Client should be launched second, and will establish a connection with the Server. The Client and Server may both be run on the same computer. Alternatively, they may run on two networked computers. If the Client is to run on a different computer to the Server, then the Client must have security permission (authorisation) to connect to the Server computer.
Above: Client Configuration Tab Account number: Account name: Account created on: Transaction amount: Present balance: Overdraft limit: Above: Client Operation Tab The Configuration Tab must be completed first by entering the correct Server IP address, correct Server TCP port, and an arbitrary client nick name. The Client does not attempt to connect to the Server until a account number has been entered, and only attempts to connect when an account number is entered. If the connection is NOT successful, then the Client will display an error message. If the connection is successful, then the Client will prompt the user to create the first new account (current account, platinum account, or student account). After creating the account, the Client will display the information for that account. This information includes the present balance, and overdraft limit, (except for current accounts which do not support an overdraft limit). Withdraw Deposit
The account number field (cell) is a lookup field and controls which bank accounts information is displayed on screen.
The Client remains connected to the Server until the account number field is cleared, and only disconnects when the account number field is cleared.
Key Features
When a new account is created (as described on previous page), the new account name defaults to the account number; the opening balance defaults to zero; and the overdraft limit defaults to zero, (except for current accounts which do not support an overdraft limit). The account name, opening balance and overdraft limit may be set individually after the new account has been created. The account number must be an integer. The transaction amount and overdraft limit must both be decimal numbers. Any invalid input will result in an error message, and the program will roll back to the previous value. The transaction amount should be positive (or zero), and the overdraft limit should be a negative (or zero), however the program will automatically correct badly-signed values, without an error message.
System Security
The system consists of two programs: Bank Server program Bank Client program
The Client and Server may both be run on the same computer. Alternatively, they may be run on two networked computers. IF the Client is to be run on a different computer to the Server, then the Client must have security permission (authorisation) to connect to the Server computer. By default, clients do not have permission to connect to servers, (except for servers running on the same computer). To add permission, it is necessary to modify the .java.policy file located on the CLIENT machine. This file is located in the USER.HOME directory, which is normally c:\windows on a single-user Windows 95 computer. It is necessary to add a line to this file, similar to
permission java.net.SocketPermission "foo.bar.net:1024-", "connect,resolve";
(where foo.bar.net is the server IP address.) If a Client attempts to connect to a Server without permission, then a security error (Access Control Exception) will occur.
Bank Account Class Structure Server Class Structure Server / Database Interface Client Class Structure Test Strategy and Test Results
Program Description
The purpose of the program is to simulate a networked Banking System or Bank Account Management System. The primary functions and capabilities which the program offers are:
Create new account Access existing account Change account name Deposit and withdraw money Set overdraft limit
The program provides a Graphical User Interface (GUI), to allow these functions to be carried out, and provides a Bank Account Database to store account information. The GUI and the Database are suited and intended to be run remotely, on separate connected computers. To facilitate this, a communication mechanism has been established between the GUI and the Database. The communication mechanism consists of a client, a server, and a protocol:
GUI
Client
Server
Database
Account number Account name Account created on date Present balance Overdraft limit Account status Overdraft status
Transmitted as integer (32 bit) String (UTF) String (UTF) double (64 bit) double (64 bit) String (UTF) String (UTF)
The account status contains a description of the account type (platinum, etc) and a description of whether the account is new or existing. For example New Current Account or Existing Student Account. The overdraft status provides a description of the overdraft situation. For example Balance is presently 100.00 above overdraft limit.
(A detailed description of the Bankaccount Universal Retrieval Protocol is included over page.)
1)
2) 3) 4) 5) 6)
Create (& lock) new account (current, platinum, student) Change account name Pre-requisite: account locked Withdraw or Deposit Pre-requisite: account locked Change overdraft limit Pre-requisite: account locked TEST (Are you there?)
Account number * Type (current, student, etc) New account name Transaction amount * New overdraft limit *
* Client is responsible for validating numerical items (account numbers, transaction amounts, overdraft limits) before sending to server.
BaseAccount
The BaseAccount class contains the member variables and methods that will be common to all types of bank account: int getAccountNumber() String getAccountName() double getBalance() String getCreatedDate() void setAccountName(String newName) void deposit(double amount) void withdraw(double amount) The OverdraftAccount class extends the BaseAccount by adding additional variables and methods that will be common to all accounts with an overdraft facility: double getOverdraft() boolean isWithinLimit() void setOverdraft(double newOverdraft) The CurrentAccount class does not support an overdraft facility, and is derived from the BaseAccount. The PlatinumAccount and StudentAccount classes do have overdraft facilities, and these two classes are descendants of the OverdraftAccount class. Any changes made to the BaseAccount class will affect the inherited behaviour of all the types of bank account. Any changes made to the OverdraftAccount will affect the behaviour of all accounts with an overdraft facility. The reasons why the bank account classes have been set up like this, is so that a variable of type BaseAccount can refer to (or point to) an object of any type of bank account (that has been derived from the BaseAccount parent class).
BankServer
HAS-A HAS A HAS-A
BankServer Slave
(THREAD) HAS-A
BankServer Database
(COMMUNAL)
HAS-A
BankServer Slave
(THREAD)
HAS A
HashMap
The BankServer object runs in its own thread context, and is responsible for listening for and accepting new TCP/IP connections by using the ServerSocket.accept() method. The server is designed to support multiple clients, and spawns a new ServerSlave for EACH connection. The server is suited to be run from the MS-DOS prompt. The default TCP port used is 1333. This can be configured by supplying a valid port as a command-line argument.
Each BankServerSlave object runs in its own thread context, and is responsible for managing (i.e. conversing with) one client Socket. The BankServerSlave implements both SIP (Security Identification Protocol) and BURP (Bankaccount Universal Retrieval Protocol). The BackServerSlave is responsible for unlocking any presently locked account if the remote client requests another account. The BackServerSlave is responsible for unlocking any presently locked account if the remote client disconnects or terminates.
The BankServerDatabase object is instantiated once only, is communal, and is shared by all BankServerSlave threads. The BankServerDatabases HashMap stores Account objects (as defined on previous page). The BankServerDatabase is responsible for handling requests for existing accounts and requests for new accounts. The BankServerDatabase is responsible for locking successfully requested accounts. The BankServerDatabase GUARANTEES that if two BankServerSlaves request the same account at the same time, than one BankServerSlave will be successful and the other BankServerSlave will not. An algorithm showing the interfacing between BankServerSlave and BankServerDatabase is shown over page.
If NO exist:
Database creates and locks account Database returns account to ServerSlave (ServerSlave uses account) (ServerSlave unlocks account when finished)
Or, fail:
BankClient
HAS-A IS-A HAS A
BankClientSlave
HAS A ClientSocket
AlertBox
The BankClientGUI class defines the Graphical User Interface (i.e. the Configuration Panel and the Operation Panel). The BankClientGUI makes use of a UJTextField (or "Undo-able" JTextField) class. This class extends JTextField, by adding a rollback facility. This enables the JTextFields contents to be rolled back to the previous contents, if the current contents are invalid (in the context of the application).
The BankClient class extends BankClientGUI. It is responsible for responding to user events as they occur and in the order in which they occur. The BankClient is responsible for validating all user requests (and for invoking rollback in cases of invalid user requests). The BankClient is also responsible for informing the user if a problem occurs with the connection to the server. The GUI makes use of a general-purpose, configurable, Alert Box dialog in order to display error messages and confirmation prompts to the user.
The BankClientSlave class is responsible for managing (i.e. conversing with) the servers Socket. The BankClientSlave implements both SIP (Security Identification Protocol) and BURP (Bankaccount Universal Retrieval Protocol). The BankClientSlave encapsulates the Socket safety mechanisms away from the GUI safety mechanisms. That is, the BankClientSlave class is responsible for dealing with problems which may occur with the connection, whereas the BankClient class is responsible for dealing with problems which may result due to user events.
The client-side run-time tests are listed below, along with the expected results of each test: (1) (2) (3) (4) (5) (6) Empty Server IP address, and enter account number Client reports Please choose Server IP address Empty Server TCP port, and enter account number Client reports Please choose Server TCP port Empty Client nickname, and enter account number Client reports Please choose Client nickname Invalid Server TCP port (non-numerical, <1, >65535) and enter account number Client reports Invalid TCP port Invalid or nonsense Server IP address, and enter account number Client reports Unknown Host and problem connecting to server Wrong Server TCP port, and enter account number Client reports problem connecting to server Invalid account number (non-numerical, <1) Client reports Invalid Account Number First new account number, then cancel Client temporarily connects to server, then DISCONNECTS First new account number, then create Client connects to server, and displays default account information Change account number Client displays account information Change account name (Account name changes) Invalid transaction amount (non-numerical) Client reports Invalid Transaction Amount Invalid transaction amount (negative) Client automatically converts negative value to positive value
The client-side run-time tests are continued below, along with the expected results of each test: (14) (15) (16) (17) Withdraw/Deposit with empty transaction amount Client ignores request Withdraw/Deposit with non-empty transaction amount Present balance changes, and overdraft status changes (if application) Invalid overdraft limit (non-numerical) Client reports Invalid Overdraft Limit Invalid overdraft limit (positive) Client automatically converts positive to negative, and overdraft status changes
SERVER CONNECTION FAILS WHILE ATTEMPTING TO
change account number (to existing account) Client detects, reports Connection with server has been lost, and clears connection change account number (to non-existing account) Client detects, reports Connection with server has been lost, and clears connection create new account Client detects, reports Connection with server has been lost, and clears connection change account name Client detects, reports Connection with server has been lost, and clears connection Withdraw/Deposit Client detects, reports Connection with server has been lost, and clears connection change overdraft limit Client detects, reports Connection with server has been lost, and clears connection CONCURRENCY: Attempt to access account which is presently locked Client reports Account presently locked by another client Attempt to access account which has been unlocked Client displays account information Attempt to create same account twice First client succeeds and displays default account information Second client fails and reports Account has been created by another client