Online Voting System
Online Voting System
INTRODUCTION
In every democratic setting with persons of differing and inconsistent opinions, decisions
must be made between several options. This happens in business environment, educational
environment, social organizations, and mostly in governance. One of the ways of making
such a decision is through voting. Voting is a formal process of expressing individual
opinions for or against some motion. In the governance sector of many organization this
process is always used as a means of selecting or electing a leader. One of the key areas
where voting is applied is in election. Election is the formal process of selecting a person for
public office or of accepting or rejecting a political proposition by voting.
Online voting (Electronic Voting) as a term encompasses a broad range of voting systems
that apply electronic elements in one or more steps of the electoral cycle. There are many
levels to online voting in a broad sense which could be e-collation, e-verification and internet
voting, remote online voting etc. Following the definition of a system as anything that takes
an input and gives an output, an online voting system is any system that can offers both
electronic and online voting. It could also incorporate e- registration, e-verification, e-
collation, remote online voting and real-time result display. An Online voting system
generally comprises the following for it to work efficiently:
i. An interactive voting user interface on an electronic device which provides a
friendly environment for voters to authenticate and cast their votes, it also serves as a means
of collection of the individual votes and storing them in the local and central database.
ii. An administrative dashboard for voters’ registration, details update and elections
coordination and monitoring.
iii. A database management system for the storage of election, voting and voters data.
Online voting system serves to reduce the cumulative costs of running elections and increases
students voting participation in election system as it offers voters an easy and convenient way
to vote and most importantly, it is a panacea to the issue of ballot box snatching which is
rampart in the conventional election process in SUG’s.
1
A great technological improvement is observed in election process mostly in the areas of
result collation and transmission. Though the SUG electoral body has not fully implemented
the use of technologies for collation due to lack of legal framework. But, most elections
around the world use ICT in elections to some degree, at least to summarize and aggregate
the votes. This electronic adaptation is the result of a long period of evolution during which
not only the procedures but also the technological means for casting votes changed
considerably.
The present voting system applicable in the SUG electoral system has proved inefficient as
the voters’ registration process is slow, the manual collation of results takes time and gives
room for result manipulation, also the inaccessible nature of election venues which includes
the long distances to be covered by voters’ to their registered location increases voters’
apathy towards the election processes, and finally the issues of ballot box snatching and
damage, and other election violence and issues associated with the traditional ballot paper
voting all defiles the purpose of voting in election process as a formal process of expressing
individual opinions for or against some motion.
4. To simulate and compare the results of the designed online voting system and
other voting systems.
2
1.4 SIGNIFICANCE OF THE STUDY
In view of the rapid development of computer technology in virtually all fields of operation
and its use in relation to information management, the importance of the online voting system
are as follows:
1. To the Polytechnic
i. It will provide a means t o conduct a more or less stressful and fair elections at
different levels ( faculty, departments, school wide etc.) in the polytechnic.
ii. It will offer an in-depth knowledge of the practical approach to ICT education.
2. To the Society
The significance of an online voting system to the society and mostly to SUG are itemized as
follows:
iv. As it incorporates remote voting individuals can vote from their convenience.
v. It will enable INEC reduce the time wasted in collating and announcing election result.
vii. It will serve to eliminate invalid votes, curb election violence as votes are counted
immediately as they are cast.
3
1.5 SCOPE OF THE STUDY
This project work is mainly designed to enable the SUG electoral body to use electronic device to
capture voter’s information, and to allow voters to their cast votes easily and comfortably to promote a
more credible election which is efficient and less costly. The dynamic nature of the elections
application interface and database structure allows for different organizations set up and conduct
basic elections too. Its online interface enables real-time election monitoring and result collation.
iii. Data Base Management System (DBMS): It is a software system that is used to create,
maintain, and provide controlled access to user databases.
iv. Database: It is an organized collection of logically related data, usually designed to meet
the information needs of multiple users in an organization.
v. Data and database administrators: Data administrators are persons who are responsible
for the overall management of data resources in an organization.
vi. User interface: This includes languages, menus, and other facilities by which users interact
with various system components, such as CASE tools, application programs, the DBMS, and
the repository.
vii. System developers: They are persons such as systems analysts and programmers who
design new application programs.
4
viii. Network: A network consists of two or more computers that are linked in order to share
resources (such as printers and CDs), exchange files, or allow electronic communications.
The computers on a network may be linked through cables, telephone lines, radio waves,
satellites, or infrared light beams.
ix. Internet: The Internet is the global system of interconnected computer networks that uses
the Internet Protocol Suite (TCP/IP) to communicate between networks and devices.
x. Computer: A computer is a digital electronic machine that can be programmed to carry out
sequences of arithmetic or logical operations automatically.
xi. Web Dashboard: A web dashboard is an online interface, or page in your website, that
displays real-time data as insightful charts and reports.
xii. Website: A website is a collection of web pages and related content that is identified by a
common domain name and published on at least one web server. Examples of notable
websites are Google, Facebook, Amazon, and Wikipedia.
xiii. Webpage: A web page is a hypertext document on the World Wide Web. Web pages are
delivered by a web server to the user and displayed in a web browser.
xiv. Personal Website: Personal websites are for individuals who want to have an online
presence to voice their opinion, help with job prospects, or establish their own personal
brand. Most personal websites are fairly simple, with images and a lot of text.
xv. Blog Website: A blog website is regularly updated with relevant articles, videos, and photos
meant to inform, entertain, and educate your audience
xvi. Browser: A web browser (also referred to as an Internet browser or simply a browser) is
application software for accessing the World Wide Web or a local website.
xvii.HTTP: The abbreviation for Hypertext Transfer Protocol. It is the set of rules by which
Web pages are transferred across the Internet.
xviii. Homepage: It is the first page that is viewed when the browser starts. It is also the page of
a web site that provides the introduction or content with links
xix. TelNet: A terminal emulation protocol (or Internet program) used to connect a computer to
a remote host or server. Telnet is one of the oldest Internet activities and is primarily used to
access online databases or to read articles stored on university servers.
xx. Internet Protocol (IP): A terminal emulation protocol (or Internet program) used to connect
a computer to a remote host or server. Telnet is one of the oldest Internet activities and is
primarily used to access online databases or to read articles stored on university servers.
5
CHAPTER TWO
LITERATURE REVIEW
2.1 THEORY
Online voting (also known as e-voting) is voting that uses electronic means to either aid or take care
of casting and counting ballots. Depending on the particular implementation, e-voting may use
standalone electronic voting machines (also called EVM) or computers connected to the Internet. It
may encompass a range of Internet services, from basic transmission of tabulated results to full-
function online voting through common connectable household devices. The degree
of automation may be limited to marking a paper ballot, or may be a comprehensive system of vote
input, vote recording, data encryption and transmission to servers, and consolidation and tabulation
of election results. A worthy E-voting system must perform most of these tasks while complying
with a set of standards established by regulatory bodies, and must also be capable to deal
successfully with strong requirements associated with security, accuracy, integrity, swiftness,
privacy, auditability, accessibility, cost-effectiveness, scalability and ecological sustainability.
At the heart of every fully designed system are the collection, storage, aggregation, manipulation,
dissemination, and management of data. Data are raw facts. The word raw indicates that the facts have
not yet been processed to reveal their meaning. Information are data that have been processed in such
a way that the knowledge of the person who uses the data is increased. These facts are made available
for processing because they are stored at a place for future reference. The two main techniques for data
storage in computers are: file system and database.
6
A file system is a method for storing and organizing computer files and the data they contain to make it
easy to find and access them. File systems may use a storage device such as a hard disk or CD-ROM
and involve maintaining the physical location of the files. The file system can be used to store less
complex data, but in a case of an organizations’ data which includes employee details, financial records
and so on, a well-structured system is required for such task and such a system is referred to as a
database.
◆ End-user data, that is, raw facts of interest to the end user.
◆ Metadata, or data about data, through which the end-user data are integrated and managed.
The file systems became obsolete as their integration and use becomes difficult when the volume of
data stored increases. Its numerous disadvantages led to the development of database as an easier
means for data storage, but as the need for a good data manipulation system increased, there was need
to develop a management system for databases for quick access and control and that gave rise to the
Database Management System (DBMS).
The database operational environment is an integrated system of hardware, software, and people,
designed to facilitate the storage, retrieval, and control of the information-resource and to improve the
productivity of the organization. They include:
7
Figure 2.1: Components of the Database Environment.
Computer-aided software engineering (CASE) tools: CASE tools are automated tools used to design
databases and application programs.
Repository: A repository contains an extended set of metadata important for managing databases as
well as other components of an information system.
DBMS: It is a software system that is used to create, maintain, and provide controlled access to user
databases.
Database: It is an organized collection of logically related data, usually designed to meet the
information needs of multiple users in an organization. It is important to distinguish between the
database and the repository. The repository contains definitions of data, whereas the database contains
occurrences of data.
Application programs: Computer-based application programs are used to create and maintain the
database and provide information to users.
User interface: This includes languages, menus, and other facilities by which users interact with
various system components, such as CASE tools, application programs, the DBMS, and the repository.
Data and database administrators: Data administrators are persons who are responsible for the
overall management of data resources in an organization. Database administrators are responsible for
physical database design and for managing technical issues in the database environment.
System developers: They are persons such as systems analysts and programmers who design new
application programs. System developers often use CASE tools for system requirements analysis and
program design.
End users: These are persons throughout the organization who add, delete, and modify data in the
database and who request or receive information from it. All user interactions with the database must
be routed through the DBMS.
A database management system (DBMS) is a software system that enables the use of a database. The
primary purpose of a DBMS is to provide a systematic method of creating, updating, storing, and
retrieving the data stored in a database. It enables end users and application programmers to share data,
and it enables data to be shared among multiple applications rather than propagated and stored in new
files for every new application. A DBMS also provides facilities for controlling data access, enforcing
data integrity, managing concurrency control, and restoring a database.
8
There are many terms associated with the DBMS used to explain the different operations in a database
environment, they include terms like query -- a specific request issued to the DBMS for data
manipulation — for example, to read or update the data. Simply put, a query is a question.
The terms database and DBMS are most times used interchangeably to refer to the database technology
and as such we adopt such use here to us focus on the technological aspects of the database approach.
As a database is only as useful as its DBMS, the advantages of a DBMS are as follows:
1. Improved data sharing: The DBMS helps create an environment in which end users have
better access to more and better-managed data. Such access makes it possible for end users to
respond quickly to changes in their environment.
2. Improved data security: The more users access the data, the greater the risks of data security
breaches. Corporations invest considerable amounts of time, effort, and money to ensure that
corporate data are used properly. A DBMS provides a framework for better enforcement of data
privacy and security policies.
3. Better data integration: Wider access to well-managed data promotes an integrated view of
the organization’s operations and a clearer view of the big picture. It becomes much easier to
see how actions in one segment of the organization affect other segments.
4. Minimized data inconsistency: Data inconsistency exists when different versions of the same
data appear in different places. For example, data inconsistency exists when a company’s sales
department stores a sales representative’s name as “MaryJabe” and the company’s personnel
department stores that same person’s name as “Mary-Jane C.,” or when the company’s regional
sales office shows the price of a product as #4,500 and its national sales office shows the same
product’s price as #4,490. The probability of data inconsistency is greatly reduced in a properly
designed database.
5. Improved data access: The DBMS makes it possible to produce quick answers to ad hoc
queries - a spur-of-the-moment question. The DBMS sends back an answer (called the query result set)
to the application. For example, end users, when dealing with elections data, might want quick answers
to questions (ad hoc queries) such as:
◆ What was the total number of registered voters during the past six months?
9
◆ How many candidates are contesting for a particular election?
6. Improved decision making. Better-managed data and improved data access make it possible to
generate better-quality information, on which better decisions are based. The quality of the
information generated depends on the quality of the underlying data. Data quality is a
comprehensive approach to promoting the accuracy, validity, and timeliness of the data. While
the DBMS does not guarantee data quality, it provides a framework to facilitate data quality
initiatives.
7. Increased end-user productivity: The availability of data, combined with the tools that
transform data into usable information, empowers end users to make quick, informed decisions
that can make the difference between success and failure in the global economy.
8. Improved data independence: Application programs should be as independent as possible from
details of data representation and storage. The DBMS can provide an abstract view of the data
to insulate application code from such details.
The database approach entails some additional costs and risks that must be recognized and managed
when it is implemented.
1. Need for new, specialized personnel: Frequently, organizations that adopt the database
approach need to hire or train individuals to design and implement databases, provide database
administration services, and manage a staff of new people.
2. Installation and management cost and complexity: Installing such a system may also require
upgrades to the hardware and data communications systems in the organization. Substantial
training is normally required on an ongoing basis to keep up with new releases and upgrades.
Additional or more sophisticated and costly database software may be needed to provide
security and to ensure proper concurrent updating of shared data.
3. Conversion costs: The cost of converting these older systems to modern database technology
measured in terms of money, time, and organizational commitment may often seem prohibitive
to an organization.
4. Need for explicit backup and recovery: This requires that comprehensive procedures be
developed and used for providing backup copies of data and for restoring a database when
damage occurs.
5. Organizational conflict: Experience has shown that conflicts on data definitions, data formats
and coding, rights to update shared data, and associated issues are frequent and often difficult to
resolve.
10
11
2.1.4 TYPES OF DATABASE
Depending upon the usage requirements, there are following types of databases available:
1. Centralized database: The information (data) is stored at a centralized location and the
users from different locations can access this data. This type of database contains application
procedures that help the users to access the data even from a remote location. Various kinds of
authentication procedures are applied for the verification and validation of end users, likewise, a
registration number is provided by the application procedures which keeps a track and record of
data usage.
2 . Distributed database: The data is not at one place and is distributed at various sites of an
organization. These sites are connected to each other with the help of communication links
which helps them to access the distributed data easily.
There are two kinds of distributed database, viz. homogeneous and heterogeneous. The databases
which have same underlying hardware and run over same operating systems and application procedures
are known as homogeneous DDB. Whereas, the operating systems, underlying hardware as well as
application procedures can be different at various sites of a DDB which is known as heterogeneous
DDB.
3. Personal database: Data is collected and stored on personal computers which is small and
easily manageable. The data is generally used by the same department of an organization and is
accessed by a small group of people.
4. End-user database: The end user is usually not concerned about the transaction or operations
done at various levels and is only aware of the product which may be a software or an
application. Therefore, this is a shared database which is specifically designed for the end user,
just like different levels’ managers. Summary of whole information is collected in this database.
5. Commercial database: These are the paid versions of the huge databases designed uniquely
for the users who want to access the information for help. These databases are subject specific,
and one cannot afford to maintain such a huge information.
6. NoSQL database: These are used for large sets of distributed data. There are some big data
performance issues which are effectively handled by relational databases, such kind of issues
are easily managed by NoSQL databases. There are very efficient in analyzing large size
unstructured data that may be stored at multiple virtual servers of the cloud. An example of a
NoSQL database is MongoDB.
8. Relational database: These databases are categorized by a set of tables where data gets fit into
a predefined category. The table consists of rows and columns where the column has an entry
for data for a specific category and rows contains instance for that data defined according to the
category.
There are various simple operations that can be applied over the table which makes these databases
easier to extend, join two databases with a common relation and modify all existing applications.
9. Cloud database: Now a day, data has been specifically getting stored over clouds also known
as a virtual environment, either in a hybrid cloud, public or private cloud. A cloud database is a
database that has been optimized or built for such a virtualized environment.
There are various benefits of a cloud database, some of which are the ability to pay for storage
capacity and bandwidth on a per-user basis, and they provide scalability on demand, along with
high availability.
A cloud database also gives enterprises the opportunity to support business applications in a
software-as-a-service deployment.
An object-oriented database is organized around objects rather than actions, and data rather than
logic. For example, a multimedia record in a relational database can be a definable data object,
as opposed to an alphanumeric value.
11. Graph database: The graph is a collection of nodes and edges where each node is used to
represent an entity and each edge describes the relationship between entities. A graph-oriented
database, or graph database, is a type of NoSQL database that uses graph theory to store, map
and query relationships. Graph databases are basically used for analyzing interconnections. For
example, companies might use a graph database to mine data about customers from social
media.
MongoDB is not only a general-purpose database which can perform only insert, update and delete data
within it. Besides these, there are several important features which make the MongoDB one of the most
popular and enriched databases in the world of NoSQL databases. Some of the features are as below;
13
14
1. MongoDB supports JSON data models with dynamic schema.
2. In MongoDB, we can perform a search on any field or any range query and also can use a
regular expression for searching the data MongoDB supports secondary indexes which allow us
to search a variety of data in a very small time-span. It also provides us with different types of
indexes like unique index, compound index, geospatial index etc.
7. MongoDB can store any type of file which can be any size without affecting our stack.
9. MongoDB supports special collection type like TTL (Time-To-Live) for data storage which
expires at a certain time.
MongoDB supports all types of operating systems. MongoDB is available in two versions –
Community Server Edition (Perfect of Self Use or Developer Mode) and Enterprise Server Edition (For
Business Purpose Use with Proper Licensing). The MongoDB installer is available for all types of
operating systems like Windows, Linux or Mac OS. Installer for MongoDB can be downloaded from
the MongoDB sites.
All publicly accessible websites collectively constitute the World Wide Web. There are also private
websites that can only be accessed on a private network, such as a company's internal website for its
employees.
Websites are typically dedicated to a particular topic or purpose, such as news, education, commerce,
entertainment, or social networking. Hyperlinking between web pages guides the navigation of the
site, which often starts with a home page.
15
Users can access websites on a range of devices, including desktops, laptops, tablets,
and smartphones. The app used on these devices is called a web browser.
Webpage: A web page is a hypertext document on the World Wide Web. Web pages are delivered by
a web server to the user and displayed in a web browser. A website consists of many web
pages linked together under a common domain name. The name "web page" is a metaphor of paper
pages bound together into a book.
The core element of a web page is a text file written in the Hypertext Markup Language (HTML) that
describes the content of the web page and includes references to other web resources. A web page is
a structured document that primarily consists of hypertext, text with hyperlinks. Hyperlinks point the
user to other web resources, primarily other web pages, and to different sections of the same web
page. Multimedia content on the web, such as images, videos, and other web pages, can be directly
embedded in a web page to form a compound document.
1. E-commerce Websites: Ecommerce websites allow users to shop for and purchase products or
services online. Amazon, Bookshop, and other retailers that sell products through an online store
are great examples of ecommerce sites. These websites make it easy to drop items in your cart and
checkout using your credit card, a payment service like PayPal or an ecommerce platform like
Shopify.
2. Personal Websites: Personal websites are for individuals who want to have an online presence to
voice their opinion, help with job prospects, or establish their own personal brand. Most personal
websites are fairly simple, with images and a lot of text. Since personal websites are shared with
friends, family, and colleagues manually, they don't typically require any lead generation tools or
SEO. However, if you plan to use your own website to promote yourself as a professional, it
certainly doesn't hurt to optimize your content to appear in search engines.
3. Portfolio Websites: While similar to a personal site, this type of website is all about showcasing
your professional work with the goal of winning clients. A portfolio website is a canvas for
designers, writers, videographers, artists, and other creative professionals. These types of websites
exist to highlight specific skill sets and services that free lancers offer.
4. Business Website: A business website provides an online presence so people can learn about a
company, its employees, products, services, and culture. The goal of a small business website is to
provide information so customers can reach you directly. Examples include local accounting
firms, service providers (plumbers, HVAC, etc.), restaurants, and law offices.
16
6. Blog Website: A blog website is regularly updated with relevant articles, videos, and photos
meant to inform, entertain, and educate your audience. Blogs are sometimes platforms to voice
an individual's opinion, or a company may have one to offer valuable content to their
customers. These types of websites can either put the main focus on the blog itself — centering
the site around the regularly updated content — or be built into a larger website.
2.1.7 BROWSER
A web browser is not the same thing as a search engine, though the two are often confused. A search
engine is a website that provides links to other websites. However, to connect to a website's server and
display its web pages, a user must have a web browser installed.
The purpose of a web browser is to fetch content from the Web or from a local storage device and display
it on a user's device.
This process begins when the user inputs a Uniform Resource Locator (URL), such as
https://en.wikipedia.org/, into the browser. Virtually all URLs on the Web start with either http: or https:
which means the browser will retrieve them with the Hypertext Transfer Protocol (HTTP). In the case
of secure mode (HTTPS), the communication between the browser and the web server is encrypted for the
purposes of security and privacy.
Once a web page has been retrieved, the browser's rendering engine displays it on the user's device. This
includes image and video formats supported by the browser.
Web pages usually contain hyperlinks to other pages and resources. Each link contains a URL, and when it
is clicked or tapped, the browser navigates to the new resource. Thus the process of bringing content to the
user begins again.
Most browsers use an internal cache of web page resources to improve loading times for subsequent visits
to the same page. The cache can store many items, such as large images, so they do not need to be
downloaded from the server again. Cached items are usually only stored for as long as the web server
stipulates in its HTTP response messages.
17
2.1.7.1 TYPES OF BROWSER
1. Internet Explorer
2. Google Chrome
3. Mozilla Firefox
4. Safari
5. Opera
2.1.8 NETWORKING
Networking is the exchange of information and ideas among people with a common profession or special
interest, usually in an informal social setting. Networking often begins with a single point of common
ground. Professionals use networking to expand their circles of acquaintances, find out about job
opportunities in their fields, and increase their awareness of news and trends in their fields or the greater
world.
If multiple individuals use the same network within a residence, the network is sometimes referred
to as a home area network, or HAN. In a very typical setup, a residence will have a single wired
Internet connection connected to a modem. This modem then provides both wired and wireless
connections for multiple devices. The network is typically managed from a single computer but can
be accessed from any device. This type of network provides great flexibility. For example, it allows
you to:
Send a document to the printer in the office upstairs while you are sitting on the couch with your
laptop.
Upload a photo from your cell phone to your desktop computer.
Watch movies from an online streaming service to your TV.
If this sounds familiar to you, you likely have a PAN in your house without having called it by its
name
18
2. Local Area Network: A local area network, or LAN, consists of a computer network at a single
site, typically an individual office building. A LAN is very useful for sharing resources, such as
data storage and printers. LANs can be built with relatively inexpensive hardware, such as hubs,
network adapters and Ethernet cables. The smallest LAN may only use two computers, while larger
LANs can accommodate thousands of computers. A LAN typically relies mostly on wired
connections for increased speed and security, but wireless connections can also be part of a LAN.
High speed and relatively low cost are the defining characteristics of LANs.
LANs are typically used for single sites where people need to share resources among themselves
but not with the rest of the outside world. Think of an office building where everybody should be
able to access files on a central server or be able to print a document to one or more central
printers. Those tasks should be easy for everybody working in the same office, but you would not
want somebody just walking outside to be able to send a document to the printer from their cell
phone! If a local area network, or LAN, is entirely wireless, it is referred to as a wireless local area
network, or WLAN
3. Wide Area Network: A wide area network, or WAN, occupies a very large area, such as an entire
country or the entire world. A WAN can contain multiple smaller networks, such as LANs or
MANs. The Internet is the best-known example of a public WAN. A WAN can be setup both
physically and virtually. A WAN can connect multiple other LANs virtually, creating what is
called a VLAN. In this sense it is like a LAN of LANs!
When it comes to today's increased use of remote work connections, the WAN is a powerful tool
that provides interfaces to the Internet as well as giving access to systems that may be spread
throughout the world. One means of connecting to a WAN is through a VPN or virtual private
network. This allows a secure connection to the WAN, thus protecting your data and device from
attack. In addition to virtual connections, fiber optic provides a backbone to many WAN setups.
19
2.1.9 ONLINE VOTING SYSTEM
Online voting (also known as e-voting) is voting that uses electronic means to either aid or take care of
casting and counting ballots.
Depending on the particular implementation, e-voting may use standalone electronic voting machines (also
called EVM) or computers connected to the Internet. It may encompass a range of Internet services, from
basic transmission of tabulated results to full-function online voting through common connectable
household devices. The degree of automation may be limited to marking a paper ballot, or may be a
comprehensive system of vote input, vote recording, data encryption and transmission to servers, and
consolidation and tabulation of election results.
A worthy e-voting system must perform most of these tasks while complying with a set of standards
established by regulatory bodies, and must also be capable to deal successfully with strong requirements
associated with security, accuracy, integrity, swiftness, privacy, auditability, accessibility, cost-
effectiveness, scalability and ecological sustainability.
Electronic voting technology can include punched cards, optical scan voting systems and specialized
voting kiosks (including self-contained direct-recording electronic voting systems, or DRE). It can also
involve transmission of ballots and votes via telephones, private computer networks, or the Internet. In
general, two main types of e-voting can be identified:
These systems can include a ballot marking device or electronic ballot marker that allows voters to
make their selections using an electronic input device, usually a touch screen system similar to a
DRE. Systems including a ballot marking device can incorporate different forms of assistive
technology. In 2004, Open Voting Consortium demonstrated the 'Dechert Design', a General Public
License open source paper ballot printing system with open source bar codes on each ballot.
20
2. Direct Recording Electronic Voting System: A direct-recording electronic (DRE) voting
machine records votes by means of a ballot display provided with mechanical or electro-optical
components that can be activated by the voter (typically buttons or a touchscreen); that processes
data with computer software; and that records voting data and ballot images in memory
components. After the election it produces a tabulation of the voting data stored in a removable
memory component and as a printed copy. The system may also provide a means for transmitting
individual ballots or vote totals to a central location for consolidating and reporting results from
precincts at the central location. These systems use a precinct count method that tabulates ballots at
the polling place. They typically tabulate ballots as they are cast and print the results after the close
of polling.
2.1.10 POLLING
Polling place online voting and remote i-voting (Internet voting) systems of election have been used in
different democratic societies. The United States, Australia, Estonia, Japan, Brazil and India are at
various stages of online voting adoption. In Africa, Namibia was the first country to transit to online
voting in its 2014 general elections. In SUG, Kaduna State is the first state to adopt an online voting
system.
The advantage of online voting over the conventional voting system is obvious. Convenience is an
attribute of online voting that enhances participation and remedies apathy associated with traditional
voting methods. Online voting makes it easier for people to make their views known and cast their
votes, an important requisite for a constructive democratic process. Furthermore, poorly designed paper
ballots, which might have been filled in or counted incorrectly becomes a thing of the past if e-elections
are adopted.
21
2.2 REVIEW OF RELATED WORK
(Gaurav Kumar, Smriti Gupta, Divya Agarwal, Astha Tiwari, 2021) Worked on the virtual
voting system. The researchers said that India's voting system plays an important role in Indian
Democracy. The existing system is offline and has certain weaknesses. In recent years, the spread
of covid19, inefficient rural voters, people far from their place of birth, paper waste affecting
nature, budgets that should be used for development, invisible fraud, waste of human labor, have
been recorded and can be avoided by the virtual voting system. The research aims to supply an
easy and secure electoral system in India. The method used descriptive qualitative. The results
indicate that a virtual voting system is environmentally friendly and is considered a resource-
saving way for the election. It is because minimizes errors and increases voter participation
through convenient virtual voting. In conclusion, a virtual voting system can develop an Aadhar
based advanced Electronic Voting Machine (EVM), which helps in a free and fair way of
conducting elections.
(Taban Habibu, Konde Sharif, Sebwato Nicholas, 2017) Worked on the Public opinion and
democratic in polytechnic setting are the most important determinant to establish a good
administration. Voting is the process through which individuals convey their opinion and has the
freedom to elect a leader of the choice to signify and address the student’s issues. In today’s
technological and knowledge age, computerized related matters become widespread. E-voting is
one of these substances and it is capable to deliver appropriate, less costly, fast and secure
services. The aim of this paper is to present an electronic voting system (E-Voting) to be applied
to Muni University student’s electoral body. Several security measures were integrated into the
E-Voting system in order to achieve an enhanced, speedy and accurate performance. A computer
software application was developed using PHP (Hypertext processor) programming language and
MYSQL (My Structural Query Language), a relational database management system in
designing the database; tested and found to have produced the expected results. It is about time
that traditional voting in Muni University gives way to E-Voting and hence simplifies the task for
Electoral commission and his/her Officials.
22
(M.A Hosany, N. Chedembrun, 2017) Worked on the Voting systems have been present for long time
but, with the emergence of new web technologies, the conventional electoral process, be it is for
general election or for electing candidates for student council in a university, should be
modernized. Electronic voting is one of the most troublesome overhauls faced to obtain a perfect
outcome hence, this innovation touches the heart of the whole electoral process that is voting and
tallying of the votes. Online voting significantly decreases direct human control which is viewed as
a positive point but at the same time it presents an entire scope of new concerns. This paper
provides the specification and requirements to meet „University of Mauritius (UoM) Student
Online Voting System which is an android based application to be used by the students of
University of Mauritius during the Student Union Election. It covers the entire system development
life cycle from the identification of a solid problem to background research about the topic on to
analysis, design and implementation of an android based application. The concluding sections
cover the application testing and evaluation as well as possible enhancements to the application.
(Lauretha Rura, Biju Issac and Manas Kumar Haldar, 2020) Worked on the way online voting systems
are made available, we propose a new and secure steganography based E2E (end-to-end) verifiable
online voting system, to tackle the problems in voting process. This research implements a novel
approach to online voting by combining visual cryptography with image steganography to enhance
system security without degrading system usability and performance. The voting system will also
include password hashed-based scheme and threshold decryption scheme. The software is
developed on web-based Java EE with the integration of MySQL database server and Glassfish as
its application server. We assume that the election server used and the election authorities are
trustworthy. A questionnaire survey of 30 representative participants was done to collect data to
measure the user acceptance of the software developed through usability testing and user
acceptance testing.
23
(Okpeki U. K. and Oyubu A. O., 2021) Worked on the amount of money spent on the production of
ballot papers and other electoral materials has increased exponentially over the years. Large
democracies such as Nigeria’s require more balloting materials running into billions of dollars for a
national election. These materials which are neither transferable nor reusable are valid for just a
session of election; thus, whatever is left after an election cannot be re-used. This means that after
every election, a similar or higher budget than the preceding one is required for the next election.
This results in a colossal waste of revenue. An electronic voting system eliminates the use of ballot
papers and other electoral materials, gives an accurate result, and generally eliminates electoral
fraud which has characterized elections in most Sub-Sahara African countries over the years. The
system is re-useable as it can also be reset to conduct the fresh election as the needs arise. This
paper, the design and construction of an electronic voting system, presents a simple electronic
voting system. It is made up of both hardware, and software sections. While the hardware section
consists of a microcontroller.
The completion period for the project is done by using Gantt chart. A Gantt chart is a horizontal
bar chart which consists of Task, Start Time, Duration and End Time.
24
CHAPTER THREE
SYSTEM ANALYSIS AND DESIGN
3.1 INTRODUCTION
This chapter discussed how the current voting system works. It also discussed the gaps researchers
found with existing system. This chapter also presented the proposed system, its requirements and also
advantages the proposed system over the current system.
25
3.4 DATA COLLECTION TECHNIQUES
The data collection technique used in the SUG election is a Primary Method of data collection where
data are been collected from students who are willing to vote during the SUG election. And we are
making use of existing data already collected by previous literature on SUG’s elections to analyze the
election process and derive a conclusion on how to eliminate the issues.
Online voting system serves to provide a remedy for the inaccessible registration and voting venue as
eligible candidates can be registered and vote at their place of residence for their votes to count for their
particular place of origin. It also provides a means to eliminate ballot box snatching as votes are
counted as they are cast. There is also less room for result manipulation because the result get updated
and displayed to all as votes are being counted.
26
Figure 3.1: Flowchart of Administrator Login
The administrator dashboard is a desktop software application managing the elections. It incorporates
the basic CRUD (Create, Read, Update and Delete) features for monitoring and managing voters,
administrators, elections and the voting devices. It accesses the server which for its data that are
contained in the database. The administrator dashboard has a login page as shown below to restrict
unauthorized access to the dashboard. The login will require administrator email and password for
authentication and validates it against the values in the database. If validation succeeds, access to the
dashboard is granted, else he/she is restricted. The flowchart for the admin dashboard operation is
shown below.
27
Figure 3.2: Flowchart for Administrators Dashboard
28
3.6.3 REGISTRATION PLATFORM
This is where the voters are registered prior to an election. The setup of the registration platform
consists of the students Matriculation number.
The registration software application has features the enables voter’s registration, which involves
collecting voters data and storing the data in the database through the server. It interfaces with other
built-in programs to be able to interact with the fingerprint scanner, card reader and camera hardware
used for capturing different user data. The program flowchart is shown below.
29
3.6.4 VOTING INTERFACE
The voting interface is the software that will run on the electronic device. It works with other programs
to interact with the fingerprint scanner and the smart card reader. The flowchart for the voting interface
is shown below.
The result interface design is such that anyone can have access to election results, hence no
authentication is required to access this service. Nevertheless, data is transmitted over secure protocols
to insure integrity of the results being shown. The interface makes use of bar graphs and chats to show
live election results. The result interface program flowchart is shown below.
30
Figure 3.6: The Result Interface Flowchart
A use case diagram is used to capture the online voting system requirements as shown in figure 3.7
below.
Figure 3.7: Use case Diagram used to capture the Online voting System requirements
31
3.7 ENTITY AND RELATIONAL DIAGRAM
The design of the system to meet the requirements above is depicted in the system block diagram as
shown in figure 3.8 below
The software design consists of all the software platforms needed for the system functioning and their
interactions. The figure 3.9 below shows a block diagram of the software part of the system.
32
Figure 3.9: Software Design Block Diagram
3.7.2 DATA DICTIONARY
3.7.3 DATABASE
A NoSql database which is an object-relational database is designed. This approach is used as election
data is better represented as objects and it still maintains the advantage relational mapping of data
brings. The Entity relationship diagram (ERD) shown below in figure 3.10 presents a schematic view
of the online voting database.
SERVER
The server is designed with a REST API architecture. REST in the sense that the server is stateless as it
does not store data, it only defines certain protocols for which data in the database can be stored,
accessed, modified or removed. The server will use access tokens for security while sensitive user data
like passwords will be hashed before being stored in the database. A flow block diagram of the server
is shown below in figure 3.10.
33
CHAPTER FOUR
The program development gives the detailed explanation on how the program is been developed, how it
been run and the interface involved in the program.
The software section was implemented based on the design given in chapter three, figure 3.9
The admin dashboard was implemented with Electronics, a framework for building cross platform
desktop application with PHP, CSS and JavaScript. The software was built and packaged for windows
operating system. Its login page for restricted access is shown below in figure 4.1, while the main
admin dashboard is shown in figure 4.2 below.
34
Figure 4.1: Administrator Login Screen
35
4.2.1.2 VOTING INTERFACE
The voting interface is written in PHP which makes use of C++ and CSS libraries to interface with the
peripherals. Voting data is first encrypted before it is then transmitted over HTTPS to ensure security.
The software code is contained in appendix A. The voting software implementation is shown below in
figure 4.3.
36
TABLE 4.2: UNIT TEST FOR VOTING INTERFACE
The result has two implementations: A desktop app built with Electronics and a web portal built with
HTML, CSS and JavaScript and hosted with Github Pages at (Error! Hyperlink reference not valid.
result/index.html). The desktop app is built and packaged for windows operating system. These
interfaces receive result data over through HTTPS from the server this is to ensure security.
37
Figure 4.4: The Result Interface Implementation
38
4.2.1.4 REGISTRATION INTERFACE
The registration software is implemented in Java and makes use of C++ and Python libraries to
interface the system peripherals. All data is encrypted and transmitted over HTTPS to the server.
It begins with a login page to authentic the registrar.
Slot in a card
Click register
Send details to server
Write detail to card
Install Double click on installer Software installed correctly Software was
registration Follow installation prompt installed
Software correctly
39
The registration interface is shown below in figure 4.5.
4.2.1.5 SERVER
The server API is built with Nodejs, a JavaScript run-time outside the browser. The API routes are
protected and can only be accessed via an authentication token. All sensitive data like passwords are
hashed before they are sent to the database for storage. The server is hosted on Heroku, a cloud based
hosting service. The server was tested with Postman software application and the routes were
documented using Postman docs.
40
TABLE 4.5: UNIT TEST FOR SERVER
41
4.2.1.6 DATABASE
A NoSql Object-Relational database was implemented using MongoDb and saved on Heroku server
using mLab a MongoDB hosting service. Only the API has direct access to the database which it
accessed with a database key on a secure production environment variable file hosted on Heroku.
42
4.2.2 HARDWARE REQUIREMENT AND UNIT TESTING
This generates the power required for the devices to operate in a good working condition. It also
powers some LEDs for indication purposes. It contains a 12V battery to supply power to the devices in
the absence of external power. The input to the power unit is a 220V AC which is stepped down and
converted to DC. This output is used to power the touch screen module and the raspberry pi.
The control unit is the heart of the system. It is a raspberry pi model 3b running raspbian OS
(linux). The operating system provides the resources necessary to generate a graphical user interface
for the application. It also provides low level libraries to enable easy integration with other peripheral
(hardware) devices. It communicates with the card reader, the fingerprint sensor and the touch screen
via its USB ports which serves as a source of power to some of the peripherals like the fingerprint and
the card reader.
The voting application or software written in java and python, runs on this operating system and
communicates with the peripheral devices by using the low level libraries provided by the operation
system.
Start Application Attempt to run the vote The application The application ran
application should run without without errors
errors
43
4.2 SYSTEM INTEGRATION AND TESTING
All the different units explained above where put together such that the fingerprint scanner, camera and
smart card reader writer for the registration was added to the registration platform running on
a Windows system. The registration platform was also connected to the online Server. The result
website was hosted online at Online voting Result (https://bit.ly/32Y5z6q) and linked to the online
Server. The administrator dashboard was installed on a Windows system and linked to the online
Server as well. At the voting device end, the fingerprint module is coupled to the Raspberry pi, also the
smart card reader and LCD touch screen is connected to the Raspberry pi and coupled into the voting
system. The battery unit is added to the voting device too and the voting software is burnt to a memory
card and inserted into the Raspberry pi memory card slot. The system is started up and the voting
device is working.
44
TABLE 4.8: OVERALL SYSTEM TESTING
Click login
45
4. Voting Interface
4.4 SYSTEM PERFORMANCE
The system is designed to perform the following;
Voters Registration
Voting Interface
Result Interface
46
CHAPTER FIVE
CONCLUSION AND RECOMMENDATION
5.1 SUMMARY
The manual system of voting in SUG has failed to tackle the basic issues necessary for a clean and trusted
voting environment which has evidently driven some of its citizens to apathy.
The Online voting system was implemented to solve the proximity bottlenecks, unnecessary time delays,
with very secure and accurate recording of votes. The system has been thoroughly tested in voting
accuracy, ruggedness, responsiveness, and security by means of simulation and mini voting sessions to be
a successful one. It is seen that the system is fault tolerant at all end points (registration, voting platform
and the server).
This system will provide boundless voter participation in remote areas with very little or no cost on the
voter greatly reducing apathy. Further improvements can be done on the system to increase the credibility
of the votes and further reduce proximity issues.
5.2 RECOMMENDATION(S)
The following recommendations are made for optimal performance of the system:
1. Online Voting (E-voting): the use of smart phones or any internet connected device to cast
votes from any location.
2. The e-voting system and equipment should be tested by an independent body which
performs tests based on publicly available technical standards and specifications. Any
modifications of e-voting system components, in either hardware or software, should be
documented, and separately and integrally tested and certified based on publicly
available technical standards and specifications.
3. The voter interface should be modified in such a way that abstention is subject to the same
voter-verification options as selection of candidate i.e, a confirmation function should be
added.
5.3 CONCLUSION
The Online voting interface was programmed in such a way that it has a registration interface, and
the voting interface, of which it is programmed that if a voter has voted, there will be no other
47
room to revote anymore. More also, objectives were achieved by using HTML, CSS, and
JavaScript to develop the web page and MySQL to create the database.
48
REFERENCES
[1].
Gaurav Kumar, Smriti Gupta, Divya Agarwal, Astha Tiwari. (2021). VIRTUAL VOTING SYSTEM. International
Journal of Informatics,Information System and Computer Engineering, 1-32.
[2]. Lauretha Rura, Biju Issac and Manas Kumar Haldar. (2020). Implementation and Evaluation of
Steganography based Online Voting System. International Journal of Information, Information System, and
Computer Engineering, 1-23.
[3]. M.A Hosany, N. Chedembrun. (2017). Design and implementation of an online voting for the election of
students of the University of Maurituis. International Journal of Advanced Research in Science,
Engineering and Technology, 1-14.
[4]. Okpeki U. K. and Oyubu A. O. (2021). Design and Construction of an Electronic Voting System.
JOURNAL OF SCIECNCE TECHNOLOGY AND EDUCATION , 1-6.
[5]. Taban Habibu, Konde Sharif, Sebwato Nicholas. (2017). Design and Implementation of Electronic Voting
System. International Journal of Computer & Organization Trends (IJCOT), 1-23.
[6] Paul David Webb, Roger Gibbins, Heinz Eulau, “Election”, Encyclopaedia Britannica. [Online].
Available: https://www.britannica.com/topic/election-political-science. [Accessed: Aug. 05, 2019].
[7] Toba Paul Ayeni, Adebimpe Omolayo Esan, “The Impact of ICT in the Conduct of Elections in
SUG”, American Journal of Computer Science and Information Technology, February 09, 2018 .
[Online]. Available: http://www.imedpub.com/articles/the-impact-of-ict-in-the-conduct-of-
elections-in- SUG.php?aid=22211. [Accessed: Aug. 05, 2019].
[8] ACE, Online voting, The Electoral Knowledge Network, n.d., [Online]. Available:
http://aceproject.org/ace-en/focus/online voting/default. [Accessed: Aug. 07, 2019].
[9] Victor Ekwealor, Inside SUG’s first ever electronic voting exercise in Kaduna State, Techpoint
Africa, May 14, 2018, [Online]. Available: https://techpoint.africa/2018/05/14/kaduna-electronic-
voting/. [Access: Aug. 10, 2019].
49
[10] Alexandra Petruș,Whatiswo-fcr autheni (2FA)?,PhoneBackupExtr, O. 08 ,, What is two-factor authentication (2FA)?, iPhone Backup Extractor, Oct.
08, 2017, [Online]. Available: http://www.iphonebackupextractor.com/blog/2016/jun/3/extract-data-
two- factor-authentication/. [Accessed: Aug. 11, 2019].
[11] van Tilborg, Henk C.A.; Jajodia, Sushil, eds. (2011). Encyclopedia of Cryptography and
Security, Volume 1. Springer Science & Business Media. p.1305.
[12] Jason Cipriani, Seth Rosenblatt, Two-factor verification: What you need to know (FAQ), CNET,
June 15, 2015, [Online]. Available: https://www.cnet.com/news/two-factor-authentication-what-
you- need-to-know-faq. [Accessed: Aug. 10, 2019].
[13] Alexandra Dmitrienko, Christopher Liebchen, Christian Rossow, and Ahmad-Reza Sadeghi “On
the (In) Security of Mobile Two-Factor Authentication” Lecture Notes in Computer Science,
pp. 365-383, Nov 2014.
[15] Olufemi Sunday Adeoye “Evaluating the Performance of two-factor authentication solution in the
Banking Sector” IJCSI International Journal of Computer Science Issues, Vol. 9, Issue 4, No 2,
July 21.
[16] Rahul Kale, Neha Gore, Kavita, Nilesh Jadhav, Swapnil Shinde “ Review Paper on Two Factor
Authentication Using Mobile Phone” International Journal of Innovative research and Studies,
Vol. 2, Issue 5, pp. 164 - 170, May 2013.
[17] Van Tilborg, Henk C.A.; Jajodia, Sushil, eds. (2011). Encyclopedia of Cryptography and
Security, Volume 1. Springer Science & Business Media. p.1305.
[18] CardLogix Corporation, Smart Card Basics, CardLogix Corporation, 2010. [Online] Available
from: http://www.smartcardbasics.com [Accessed 1/05/19].
50
[19] MichaL Bairanzade, Smart card integration and specifications, ASPENCORE, 2002. [Online]
Available from: https://www.eetimes.com/document.asp? doc_id=1200923 [Accessed 1/05/19].
[20] Wikipedia, Smart card, Wikipedia, Wikipedia, n.d. [Online] Available from:
https://en.wikipedia.org/wiki/Smart_card [Accessed 29/04/19].
[21] S.L.Nita, M.I.Mihailiscu, V.C. Pau,” Security and CryptographicChallenges for Authentication
Based on Biometrics Data”, www.mdpi.com/journal/cryptography, pp.1-22, 2018,
[22] K. Nallaperumall, A. L. Fred and S. Padmapriya, “A Novel for Fingerprint Feature Extraction
Using Fixed Size Templates”, IEEE 2005 Conference, pp. 371-374, 2005.
[23] M. Egele, D. Brumley, Y. Fratantonio, and C. Kruegel, “An empirical study of cryptographic
misuse in Android applications,” in Proceedings of the ACM SIGSAC Conference on Computer
& Communications Security (CCS 2013), pp. 73–83, ACM, Berlin, Germany, November 2013.
[24] Kumar,R. Chandra,P. Hanmandlu, M.,”Local directional pattern (LDP) based fingerprint
matching using SLFNN”, IEEE Second International Conference on Image Information
Processing (ICIIP), Pages: 493 - 498, DOI: 10.1109/ICIIP.2013.6707640, 2013.
[25] N. Vurukonda and B.T. Rao, “A Study on Data Storage Security Issuesin Cloud,” Computing.
Procedia Computer Science, 92, pp. 128-135, 2016.
[26]Ruxandra Burtica, Eleonora Maria Mocanu, Mugurel Ionuţ Andreica, Nicolae Ţăpuş,
“Practical application and evaluation of no-SQL databases in Cloud Computing”, IEEE 2012
[27] Hoxmeier, J. A., &DiCesare, C. (2000). System response time and user satisfaction: An
experimental study of browser-based applications. AMCIS 2000 Proceedings, 347.
[28] Agrawal, S., Chaudhuri, S., Kollar, L., Marathe, A., Narasayya, V., &Syamala, M. (2005,
June). Database tuning advisor for microsoft SQL server 2005: demo. In Proceedings of the 2005
ACM SIGMOD international conference on Management of data (pp. 930-932). ACM.
51
[29] R.Jeberson Retna Raj, T.Sasipraba,(2014) “Privacy Preserving of Sensitive Data in Cloud based
on Fully Homomorphic Encryption (FHE) Technique”, Global Journal of Pure and Applied
Mathematics. ISSN 0973-1768 Volume 10, Number 3 (2014), pp. 431-441.
[30] Sarah P. Everett, Kristen K. Greene, Michael D. Byrne, Dan S. Wallach, Kyle Derr, Daniel
Sandler and Ted Torous, “Electronic Voting Machines versus Traditional Methods: Improved
Preference, Similar Performance”, in the Proceedings of Measuring, Business, and Voting,
Florence, Italy, April 5-10, 2008.
[33] Thomos M.Buchsbaum, “Online voting: International developments and lesson learnt”,
Technical Report by Australian Federal Ministry for Foreign Affairs, 2004.
[31] “Electronic Voting - Evaluating the Threat,” Michael Ian Shamos, CFP '93. [Online]
Available: http://www.cpsr.org/conferences/cfp93/shamos.html\. [Accessed: Sept]
52
Appendix A
Java code for Voting Interface
//////////////////////////java////////////////////////
package com.prime.ev;
import java.io.*;
import java.lang.reflect.Array;
import java.net.URL;
import java.nio.ByteBuffer;
import java.util.*;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.ScrollPane;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
import javax.imageio.ImageIO;
/**
* Created by Prime on 8/4/2019.
* DisplayManager is responsible for handling graphical interfaces,
* and update the interface on request.
*/
public class DisplayManager {
private Stage primaryStage;
private static ArrayList<Scene> sceneList;
private final String SCENE_NAME_FORMAT = "scene/scene";
DisplayManager(Stage primaryStage) {
this.primaryStage = primaryStage;
sceneList = new ArrayList<>();
currentElectionCodeMap = new HashMap<>();
sceneFunction = new SceneFunction();
53
new Thread(this::initializeAndStartFirstScenes, "Initialize First Scenes").start();
}
//backup and restore true scene3 as first scene either as sceneIndex 3(before final scenes)
// or sceneIndex 1 after final scenes
if(inFinalScenes){
Scene scene3 = getScene(DisplayAccessor.ANOTHER_NEW_VOTER_SCENE); //as sceneIndex 1
sceneList = new ArrayList<>();
sceneList.add(scene3);
} else{
Scene scene3 = getScene(DisplayAccessor.NEW_VOTER_SCENE); //as sceneIndex 3
sceneList = new ArrayList<>();
sceneList.add(scene3);
}
userDetails.forEach((data, value)->{
try{
((Label) scene4.lookup("#"+data)).setText(": "+value);
}catch(NullPointerException npe){
System.out.println("no "+data+" field found on scene");
}
});
54
Image userImage;
{
UserData usd = sceneFunction.getUserData();
ArrayList<Byte> imageByteList = (ArrayList<Byte>) usd.image.get("data");
byte[] imageBytes = new byte[imageByteList.size()];
Object[] bytes = imageByteList.toArray();
for (int i = 0; i < imageByteList.size(); i++)
{
imageBytes[i] = (byte) (double) (Double) bytes[i];
}
//compress
/*
* This should be done on the registration end instead
*/
try {
ImageCompressor.compress(ImageIO.read(i), new File("imtemp"), "jpg", 0.4f);
userImage = new Image(new FileInputStream("imtemp"));
//if successful, clear waste data for raspi
imageByteList = null;
imageBytes = null;
bytes = null;
} catch (IOException ioe) {
ioe.printStackTrace();
userImage = new Image(i);
}
}
ImageView imageView =
(ImageView)scene4.lookup("#userImage");
imageView.setFitWidth(512);
imageView.setFitHeight(512);
imageView.setPreserveRatio(false);
imageView.setClip(new Circle(imageView.getFitWidth()/2, imageView.getFitHeight()/2,imageView.getFitWidth()/2));
imageView.setImage(userImage);
sceneList.add(scene4);
56
ListView listView = ((ListView) scene.lookup("#partyList"));
listView.setItems(FXCollections.observableArrayList(wrapInView(electionData.getPartyList())));
currentElectionCodeMap.put(electionData.getTitle(), electionData.getCode());
sceneList.add(scene);
++numberOfVoterScenes;
}
}
return numberOfVoterScenes;
}
Image partyLogo;
try{ partyLogo = new Image(DisplayAccessor.RESOURCES+"/logo/"+partyName+".jpg"); }
catch(IllegalArgumentException i){
partyLogo = new Image(DisplayAccessor.RESOURCES+"/logo/default.jpg");
}
((ImageView) sPane.lookup("#party_logo")).setImage(partyLogo);
sPanes.add(sPane);
}
return sPanes;
}
/*
* Runs the inner scenes
* Note: i corresponds to scenex.i.fxml
*/
57
private void playScene(int scene_no) {
58
/*@debug*/System.out.println("\nplayScene invoked with scene number: "+scene_no);
new Thread(()->{
try{
for(int i=1; ; i++){
Thread.sleep(DELAY_MILLIS);
URL fxml_url = getClass().getResource(SCENE_NAME_FORMAT+scene_no+"."+i+".fxml");
/*@debug*/System.out.println("searched resource: "+SCENE_NAME_FORMAT+scene_no+"."+i+".fxml");
if(fxml_url == null) {
/*@debug*/System.out.println("resource not found"); break;
}
/*@debug*/System.out.println("found "+fxml_url.toExternalForm());
setRoot(fxml_url, i);
}
} catch(Exception e){ e.printStackTrace(); }
}, "Play Scenes").start();
}
Platform.runLater(()->{
primaryStage.setScene(scene);
try{
playScene(indexOfScene(getCurrentScene()));
invokeSceneFunction(indexOfScene(getCurrentScene()));
} // +1 to get actual file index
catch(Exception e){e.printStackTrace();}
});
}
void nextScene() {
int oldSceneIndex = indexOfScene(getCurrentScene());
int newSceneIndex = oldSceneIndex + 1;
/*@debug*/System.out.println("oldSceneIndex in nextScene: "+oldSceneIndex+"; new: "+newSceneIndex);
if(newSceneIndex >= 1 && newSceneIndex <= sceneList.size()) //range(1 - sceneCount)
setScene(sceneList.get(newSceneIndex-1)); //actual
}
void prevScene() {
int currentSceneIndex = sceneList.indexOf(getCurrentScene());
if(currentSceneIndex > 1)
setScene(sceneList.get(--currentSceneIndex));
else /*@debug*/System.out.println("no prev scene");
}
Image partyLogo;
try{ partyLogo = new Image(DisplayAccessor.RESOURCES+"/logo/"+voteMap.get("party")+".jpg"); }
catch(IllegalArgumentException i){
partyLogo = new Image(DisplayAccessor.RESOURCES+"/logo/default.jpg");
}
((ImageView) sPane.lookup("#partyLogo")).setImage(partyLogo);
sPanes.add(sPane);
}
if(inFinalScenes){
if(sceneIndex == sceneList.size()-2)
try {summarizeVoteData();} catch(IOException ioe){ioe.printStackTrace();}
if(sceneIndex == sceneList.size()-1) //fingerprint reading/voting scene
60
sceneFunction.castVote(trimScenesToElect(sceneList));
61
if(sceneIndex == sceneList.size()) return;//////////////////do nothing
//sceneFunction.newVote(); //////////////////////////////////////remove this when card is implemented
}
switch(sceneIndex) {
case DisplayAccessor.ANOTHER_NEW_VOTER_SCENE: if(!
inFinalScenes) break;
Thread scene1Thread = new Thread(()->{ try {
/*
* note that when the sceneFunction.fetchUserDetails returns false,
* the program pauses and waits for the user to retract his/her card.
* This retraction reloads the voter scene, serving as a loop in any
* occurrence of error while fetchingUserDetails
*/
if(!sceneFunction.fetchUserDetails()) return; //loop till it returns true
Map<String, String> userDetails = sceneFunction.getUserDetailsMap();
initializeVoterScenes(sceneFunction.getElectionBundle(), userDetails);
DisplayAccessor.nextScene();
}
catch(Exception e){
fatalError();
e.printStackTrace();
}
}, "Scene1 - Fetch Voter Details");
scene1Thread.start();
DisplayAccessor.addSceneThread(scene1Thread);
break;
case DisplayAccessor.NEW_VOTER_SCENE:
if(inFinalScenes) break;
//inFinalScenes = true;
Thread scene3Thread = new Thread(()->{ try { if(!
sceneFunction.fetchUserDetails()) return; //loop till it returns true
Map<String, String> userDetails = sceneFunction.getUserDetailsMap();
initializeVoterScenes(sceneFunction.getElectionBundle(), userDetails);
inFinalScenes = true;
DisplayAccessor.nextScene();
}
catch(ArrayIndexOutOfBoundsException arrayException) {
arrayException.printStackTrace();
fatalError();
}
catch(Exception e){
System.out.println("Unknown error");
e.printStackTrace();
}
}, "Scene3 - Fetch Voter Details");
scene3Thread.start();
DisplayAccessor.addSceneThread(scene3Thread);
break;
//case DisplayAccessor.USER_DETAILS_ERROR_SCENE:
// sceneFunction.userDetailError(); break;
}
}
//Note: sceneX.rootIndex.fxml
void invokeRootFunction(int rootIndex) {
switch(rootIndex){
62
//scene number for particular root number
case DisplayAccessor.FETCH_RESOURCES_ROOT:
new Thread(()->{
try{
//sceneFunction.fetchElectionBundle();
sceneFunction.showStartStatus(sceneFunction.createSocketConnection());
}
catch(Exception e){e.printStackTrace();}
}, "Fetch Election Resource").start();
break;
}
}
void setResultScene(){
try {
Scene resultScene = new Scene(FXMLLoader.load(getClass().getResource("scene/results.fxml")));
resultScene.getStylesheets().add(getClass().getResource("scene/scene_style.css").toExternalForm());
StringBuilder presVoteCount = new StringBuilder();
ArrayList<StackPane> sPanes = new ArrayList<>();
if(Factory.presidentialVoteCount!=null){
Factory.presidentialVoteCount.stream().limit(3).forEach(entry->{
presVoteCount.append(String.format("%s, %d\n", entry.getKey(), entry.getValue()));
try{
StackPane sPane = FXMLLoader.load(getClass().getResource("customfx/voteItemBox.fxml"));
//sPane.setMaxHeight(80);
((Label) sPane.lookup("#electionTitle")).setText(entry.getKey());
((Label) sPane.lookup("#partyName")).setText(entry.getValue().toString());
Image partyLogo;
try{ partyLogo = new Image(DisplayAccessor.RESOURCES+"/logo/"+entry.getKey()+".jpg"); }
catch(IllegalArgumentException i){
partyLogo = new Image(DisplayAccessor.RESOURCES+"/logo/default.jpg");
}
ImageView imView = (ImageView)
sPane.lookup("#partyLogo"); imView.setFitWidth(80);
imView.setFitHeight(80);
imView.setPreserveRatio(false);
//imView.setViewport(new Rectangle2D(50,50,50,50));
imView.setImage(partyLogo);
sPanes.add(sPane);
}catch (Exception e){e.printStackTrace();}
});
ListView listView = ((ListView) resultScene.lookup("#rankedVoteList"));
listView.setItems(FXCollections.observableArrayList(sPanes));
}
63
//((Label)(resultScene.lookup("#presidential"))).setText(presVoteCount.toString());
((Label)(resultScene.lookup("#summary"))).setText(summary.toString());
primaryStage.setScene(resultScene);
}catch (Exception e){e.printStackTrace();}
}
private void
fatalError()
{ Platform.r
unLater(()-
>{
((Label) getCurrentScene().lookup("#prompt")).setText("fatal error,
reboot device"); getCurrentScene().lookup("#prompt").setStyle("-fx-
font-size: 25px");
//irrecoverable error by calling next scene with out of bound array index,
// so no need for retry button
//getCurrentScene().lookup("#retryButton").setVisible(true);
});
}
private List<Scene> trimScenesToElect(ArrayList<Scene> scenes){
return scenes.subList(DisplayAccessor.FINAL_VOTE_BEGIN_SCENE-1, sceneList.size()-3);
}
}
64