Voting Server Protocol: Commands and Authorization, Study notes of Computer Science

The commands and authorization matrix for the voting server (vs) protocol. Users can log in, register, and issue commands such as vote, vote-status, poll-totals, and more. The document also includes error codes and examples of command usage.

Typology: Study notes

Pre 2010

Uploaded on 03/28/2010

koofers-user-9sq-1
koofers-user-9sq-1 ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
- 1 -
Voting Server- Version 1.0
E. Ruben Ramirez
Table of Contents
1. Introduction
2. Basic Operation
3. Authorization Matrix
4. Connecting
5. Commands
a. LOGIN
b. POLL-STATUS
c. POLL-TOTALS
d. REGISTER
e. LIST-OPEN
f. VOTE
g. VOTE-STATUS
h. LIST-CLOSED
i. ADD-POLL
j. ADD-MONITOR
k. QUIT
6. Error Codes
7. Sample session.
Protocol Version 1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Voting Server Protocol: Commands and Authorization and more Study notes Computer Science in PDF only on Docsity!

Voting Server- Version 1.

E. Ruben Ramirez

Table of Contents

  1. Introduction
  2. Basic Operation
  3. Authorization Matrix
  4. Connecting
  5. Commands a. LOGIN b. POLL-STATUS c. POLL-TOTALS d. REGISTER e. LIST-OPEN f. VOTE g. VOTE-STATUS h. LIST-CLOSED i. ADD-POLL j. ADD-MONITOR k. QUIT
  6. Error Codes
  7. Sample session.

Protocol Version 1

1. Introduction The Voting Server (VS) is a server that allows users to be able vote for a specific item in an active poll. There is a monitor that is able to create polls. A poll is active for a specified amount of time and only registered users or monitors are able to vote in the active poll. To become a register user an anonymous user registers and once the user is registered they become a registered user and can start voting in active polls. Below is an Authorization Matrix that lists which users have access to what commands and the definition of each command. 2. Basic Operation

The server host starts the VS (Voting Server) by listening on an assigned port. When a client wants to connect it establishes a TCP connection with the host. When the connection is established, the VS server sends the version number of the server currently running. From then the client issues commands and the server responds to them. The connection is active until the user issues a QUIT command or the connection is lost.

Messages are sent back and form from the client and server by having the parameter name followed by a semicolon then the data for that parameter followed by a carriage return. A message is terminated by two carriage returns. A carriage return is denoted by โ€œโ€.

Example: command:LOGIN user:[email protected] pass:hello

A value that will be supplied by the client or server is specified as โ€œโ€. Below is the same example as the above command but with the values for user and pass will be filled in by the client or server depending on who is sending the message.

Example: command:LOGIN user: pass:

Commands in the VS server are uppercase. All data sent is ASCII text and dates are specified as MM-DD-YYYY format.

3. Authorization Matrix List of commands and the users that are allowed to execute the commands. Details about each command are explained in detail in the Commands section.

Anonymous Registered Monitor Admin LOGIN X POLL-STATUS X X X POLL-TOTALS X X X REGISTER X LIST-OPEN X X VOTE X X VOTE-STATUS X X LIST-CLOSED X X ADD-POLL X ADD-MONITOR X QUIT X X X X

LOGIN

In order to become a registered, monitor or admin user you have to send a login command. Upon first connecting to the system you are an anonymous user and only have access rights that an anonymous user has.

CLIENT SERVER

command:LOGIN email: pass:

return-code:<return-code>

Return-code 0-Success 100-Invalid login attempt 125-Server error 127-User already logged in

Example: Client: command:LOGIN user:[email protected] pass:hello Server: return-code:0

POLL-STATUS Requests the status of the polls/elections, that is if they are open or closed. CLIENT SERVER command:VOTE-STATUS

return-code:<return-code> poll-id:<poll-id> label:

Return-code 0 - Success 125 โ€“ Server error

poll-id The unique id identifying this poll label The label describing the poll status open closed

Example: Client: command:VOTE-STATUS Server: return-code:0 poll-id:100 label:Vote for your favorite programming language status:open poll-id:120 label:Vote for your favorite scripting language status:closed

POLL-TOTALS

Requests the total for a given poll/election. Anonymous users can only view totals for an active poll. Registered users can view totals for active and closed polls.

CLIENT SERVER

Command:POLL-TOTALS id:

return-code:<return-code> : : ... :

Return-code 0 - Success 125 โ€“ Server error 130 โ€“ Access denied, not authorized for given poll.

Example: Client: command:VOTE-TOTAL id:125 Server: return-code:0 c++:100 java:245 C#:82 assembly language:14

REGISTER The register command registers an anonymous user. A successful registration requires that the email and nickname be unique in the system. If the registration is successful the users session changes from anonymous user to registered user and has access rights according to the authorization matrix.

CLIENT SERVER

command:REGISTER user: pass: nick:

return-code:<return-code>

Return-code 0 - Success 120- Invalid email 121- Duplicate email 122- Duplicate nickname 125- Server error 126- User not authorized

Example: Client: command:REGISTER user:[email protected] pass:hello nick:andrew Server: return-code:0

VOTE

Cast a vote for a particular poll. If the user already voted for the given poll then the new vote replaces the old one.

CLIENT SERVER

command:VOTE poll-id:<poll-id> option:

return-code:<return-code>

Return-code 0 - Success 125 โ€“ Server error 126 โ€“ User not authorized 144 โ€“ Invalid vote, option does not exist

Example: Client: command:VOTE poll-id:120 option:java Server: return-code:0

VOTE-STATUS

Request the vote status for a given poll. That is, if the user has voted in the poll and which option was the vote applied to. If the user voted in a poll then the option is the item the user voted on. If the user did not vote in the given poll then option is blank.

CLIENT SERVER

command:VOTE-STATUS poll-id:<poll-id>

return-code:<return-code> option:

Return-code 0 - success 125 โ€“ Server error 126 โ€“ user not authorized

Example of a user who has already voted for java:

Client: command:VOTE-STATUS poll-id:120 Server: return-code:0 option:java

Example of a user who has not voted:

Client: command:VOTE-STATUS poll-id:125 Server: return-code:0 option:

LIST-CLOSED

Requests all the closed polls/elections. Each poll has the following attributes: poll-id (unique), label, description, start-date, end-date and options.

Options contains a comma separated list of items that a user voted on and the total for that item. The format for options is specified below: =<option-name1>:<option-total1>,โ€ฆ,<option-nameN>:<option-totalN>

CLIENT SERVER

command:LIST-CLOSED

return-code:<return-code> poll-id:<poll-id> label:

Return-code 0 - Success 125 โ€“ Server error 126 โ€“ User not authorized

Example: Client: command:LIST-CLOSED Server: return-code:0 poll-id:120 label:Vote for your favorite programming language. description: Poll to determine which is the favorite programming language for January start-date:01-01-2007 end-date:01-31-2007 options:c++:10,java:40,cobol:4,assembly language:2 poll-id:130 label:Vote for your favorite scripting language. description: Poll to determine which is the favorite scripting language for January start-date:01-01-2007 end-date:01-31-2007 options:javascript:105,perl:80,actionscript:35

ADD-MONITOR

Adds a monitor to the system. Only a system administrator can add a monitor to the system. Email and nickname are unique. No two users can be registered having the same email or nickname.

CLIENT SERVER

command:ADD-MONITOR email: pass: nick:

return-code:<return-code>

Return-code 0 - Success 120- Invalid email 121- Duplicate email 122- Duplicate nickname 126- User not authorized

email Email used to login to the system. Maximum length 255 characters.

password Password used to authenticate. Maximum length 24 characters.

nickname Maximum length 20 characters.

QUIT

Closes the connection.

CLIENT SERVER

command:QUIT Return-code:0

Return-code 0 - success 125- server error

  1. Error Codes 0- Success 100- Invalid login attempt 120- Invalid email 121- Duplicate email 122- Duplicate nickname 125- Server error 126- User not authorized 127- User already logged in 130โ€“ Access denied, not authorized for given poll 140- Active poll with current label already exists 141- End-Date is prior to start-date 142- End-Date has already passed no voting can take place 143- Start-Date has to be set to current-date or some future date 144- Invalid Vote, option does not exist 145- Invalid Command

An error code of 125 that is Server error means that there was a problem with the server processing the command. If the server uses a database to store the data it could be that the database is down or some other type of error has occurred. In this case it is up to the server administrator to fix this type of errors.

  1. Sample Session Below is a sample session that does the following: 1. User connects 2. The anonymous user registers 3. The registered user lists the open polls. 4. The registered user votes for a given item in a poll. 5. The registered user requests a vote total for the poll he voted on. 6. The registered user checks what item he voted on. 7. The registered user votes again on the same poll but on a different item. 8. The registered user requests a vote total for the poll he voted on. 9. The registered sends a quit command.

Client: Open tcp connection Server: version:1.0 Client: command:REGISTER user:[email protected] pass:hello nick:andrew Server: return-code:0 Client: command:LIST-OPEN Server: return-code:0 poll-id:120 label:Vote for your favorite programming language start-date:01-12-2007 end-date:01-31-2007 options:c++,java,cobol,fortran,assembly language poll-id:121 label:Vote for your favorite programming language start-date:01-12-2007 end-date:01-31-2007 options:c++,java,cobol,fortran,assembly language Client: