58
Content Synchronization Architecture for Dissemination of Media Contents of Institutional Hubs M.Tech. Stage II Report Submitted in partial fulfilment of the requirements for the degree of Master of Technology by Gyanaranjan Shial Roll No : 113050075 under the guidance of Prof. D. B. Phatak Department of Computer Science and Engineering Indian Institute of Technology, Bombay June 2013

Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

  • Upload
    phamnhu

  • View
    239

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Content Synchronization Architecture for Dissemination ofMedia Contents of Institutional Hubs

M.Tech. Stage II Report

Submitted in partial fulfilment of the requirements for the degree of

Master of Technology

by

Gyanaranjan ShialRoll No : 113050075

under the guidance of

Prof. D. B. Phatak

Department of Computer Science and EngineeringIndian Institute of Technology, Bombay

June 2013

Page 2: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Dissertation Approval Certificate

Department of Computer Science and Engineering

Indian Institute of Technology, Bombay

The dissertation entitled “Content Synchronization Architecture for Dissemination of Me-dia Contents of Institutional Hubs ”, submitted by Gyanaranjan Shial (Roll No: 113050075)is approved for the degree of Master of Technology in Computer Science and Engineeringfrom Indian Institute of Technology, Bombay.

SupervisorProf. D.B. PhatakComputer Sc. & Engg., IIT Bombay

ChairpersonProf. Uday GaitondeMechanical & Engg, IIT Bombay

Internal ExaminerProf. Sridhar IyerComputer Sc. & Engg., IIT Bombay

External ExaminerMr. Avinash AwateProgram Director, NMEICT

Place: Indian Institute of Technology, Bombay, MumbaiDate: 27th June, 2013

Page 3: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Declaration of Academic Ethics

I declare that this written submission represents my ideas in my own words and where others’ ideas

or words have been included, I have adequately cited and referenced the original sources. I declare

that I have properly and accurately acknowledged all sources used in the production of this thesis.

I also declare that I have adhered to all principles of academic honesty and integrity and have not

misrepresented or fabricated or falsified any idea/data/fact/source in my submission. I understand

that any violation of the above will be a cause for disciplinary action by the Institute and can also

evoke penal action from the sources which have thus not been properly cited or from whom proper

permission has not been taken when needed.

Date: June 27, 2013 Gyanaranjan Shial

(Roll No. 113050075)

Page 4: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Acknowledgements

I have taken efforts in this project. However, it would not have been possible without the kind

support and help of many individuals and organization. I would like to extend my sincere thanks

to all of them.

I am highly indebted to Prof. D.B. Phatak for his guidance and constant supervision as well as

for providing necessary information regarding the project & also for their support in completing the

project. Without his guidance and persistent help this dissertation would not have been possible.

In addition, thanks to Mr Nagesh Karmali of IIT Bombay for providing his guidance, help and

support during the project.

I would like to express my gratitude towards my family & friends for their love and support &

member of Indian Institute of Technology, Bombay for their kind co-operation and encouragement

which help me in completion of this project.

My thanks and appreciations also go to my colleagues Pramendra and Pratik and others for their

valuable suggestions and support in developing the project and people who have willingly helped

me out with their abilities.

Last but not the least, I would like to thank the entire KReSIT family for providing me world class

computing infrastructure and for making my stay at IIT Bombay a memorable one.

Gyanaranjan Shial

IIT Bombay

June 27, 2013

3

Page 5: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Abstract

This research focuses on synchronizing student’s and teacher’s educational materials with eachother using Aakash tablet. To provide better solution for transferring files between tablet devicesand institutional hubs we need a better syncing application which will solve all the file transferproblems. Transferring file a whole is a bottle-neck in email systems. So in education system weneed a secure offline application which can solve in file sharing between teachers and students. Forthis I have developed an android application which will be able to sync files even when studentsand teachers are offline from internet using a wifi. It is more scalable in terms of number of usersand size of files that needs to be uploaded or downloaded. This application is supporting all fileformat for file synchronization including video and audio files. The performance issue and securityare all solved using AES algorithm and by very secure FTP daemon server.

Page 6: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Contents

Acknowledgements 3

1 Introduction 1

2 Design : 22.1 Database Inside Aakash Tablet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2.1.1 DB name, Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22.1.2 Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.1.3 Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.1.4 Folder Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.1.5 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.2 Methods of file Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2.1 Chunking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2.2 Upload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.2.3 Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.2.4 Transferring files in terms of chunks . . . . . . . . . . . . . . . . . . . . . . . 6

2.3 Running a service in background . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3 Architecture 83.1 Architecture for the syncing application . . . . . . . . . . . . . . . . . . . . . . . . 8

3.1.1 Student tablet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.2 Teacher Side Sync Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3.2.1 Teacher’s Side SyncApp Architecture . . . . . . . . . . . . . . . . . . . . . . 83.3 Assignments Deadline as per the sync application . . . . . . . . . . . . . . . . . . . 10

4 Implementation 114.1 VSFTPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4.1.1 How vsftp server is more Secure: . . . . . . . . . . . . . . . . . . . . . . . . 124.1.2 Settings for vsftpd.conf[10] . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

4.2 Connectivity to Moodle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.2.1 Function of moodle inside application . . . . . . . . . . . . . . . . . . . . . . 134.2.2 Moodle installation and accessing moodle web service [9][7] . . . . . . . . . . 134.2.3 Creating user in moodle database . . . . . . . . . . . . . . . . . . . . . . . . 134.2.4 Adding Course to moodle . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144.2.5 Creating a moodle web service . . . . . . . . . . . . . . . . . . . . . . . . . 144.2.6 Managing token . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.2.7 Calling a moodle web service from Android OS . . . . . . . . . . . . . . . . 15

4.3 Sync Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

i

Page 7: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

4.3.1 Admin PC : . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.3.2 Faculty PC : . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.3.3 Student tablet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

4.4 Features of this Aakash Sync Application . . . . . . . . . . . . . . . . . . . . . . . . 184.4.1 Features of my sync app for student side . . . . . . . . . . . . . . . . . . . . 184.4.2 Features of sync app for faculty side : . . . . . . . . . . . . . . . . . . . . . . 18

5 Security 205.1 Security in VSFTPD server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205.2 Running Web service and application security . . . . . . . . . . . . . . . . . . . . . 20

5.2.1 Security in web service and application: . . . . . . . . . . . . . . . . . . . . . 20

6 Results and Discussions 226.1 Testing and Performance Evaluations : . . . . . . . . . . . . . . . . . . . . . . . . . 22

7 Summary and Conclusion 297.1 Summery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297.2 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Appendices 31

A Folder generation after successful Sign Up 32

B Running Web service for providing VSFTPD server user informations 34

C Calling a Moodle web service from Android 36

D Running a service for Generating Notifications for Student Android Application 42

E Code for security encryption and decryption[12] 45

Page 8: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

List of Figures

3.1 Architecture for Syncing contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

6.1 Experiment: File Downloading Speed from VSFTPD server by android applicationfor a single student tablet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

6.2 Experiment: File Uploading Speed from android application to VSFTPD server fora single student tablet which includes both chunking time and uploading time . . . 24

6.3 Experiment: File chunking speed by android application . . . . . . . . . . . . . . . 256.4 Experiment: Average file chunking speed by 4 Aakash tablets . . . . . . . . . . . . 266.5 Experiment: Average file Uploading speed by 4 Aakash tablets . . . . . . . . . . . . 276.6 Experiment: Average file downloading speed by 4 Aakash tablets . . . . . . . . . . 28

iii

Page 9: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

List of Tables

2.1 Login Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22.2 Courseinfo Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22.3 downloadedfiles Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22.4 moodleInfo Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.5 serverInfo Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

iv

Page 10: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Chapter 1

Introduction

The power of technology needs to be leveraged to its true potential in the education sector. Forthis the Aakash tablet has reached some solution by implementing it in various educational needs.Among all everyday student and teacher needs to exchange some study materials , question papersand answer sheet as per better education system. Currently both teachers and students are usingmoodle for this purpose but though moodle is a better teaching tool but it does not provide anybetter content syncing facility as per now. For this I have developed an application which willdepend on moodle database partially during the student signup process and then it will work as astandalone application. The main purpose of this application is to sync the student’s and teacher’scontents with each other.

There are many method of file synchronisation between devices. File synchronisation solution areslow sync, fast sync, NFS, Rsync, cloudsync, hadoop-cloud-sync. Also there are many cloud basedsolution available to solve this problem. Applications that are available for file synchronisations aresuch as Dropbox, Sugarsync, Ubuntu one, syncany, Unison, GoodSync etc. The current solutionsnow providing limited amount of space, for Dropbox it is 2GB and others are proving 5GB spacefor free. This type of solution cant overcome the problems for file synchronisation between studenttablet devices and teachers PC with sustaining all types of file security.

This report considers file synchronisation as a mean for syncing the files between student tabletsand teacher’s PC. For this we considered a client server architecture for content synchronisationbetween student tablets and teacher’s PC. Here for this architecture we have considered a vsftpserver as the central storage space where students tablets and teachers PC are the client for thisserver.

Similar to fast sync and slow sync here in my application one notification will help in finding outthe new files between student tablets and teachers PC contents that need to be updated in studentside. If it will find any difference between the two then it will send notification to the student andthe student will download only the new file rather than whole files. Similarly I have implementeda desktop application which will help teachers in getting those student’s files from the server andalso send some files to the students those who have signed for that course.

1

Page 11: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Chapter 2

Design :

2.1 Database Inside Aakash Tablet

Table 2.1: Login Table

ID User Name Password Name

1 113050003 abc Ganesh Raipuria

Table 2.2: Courseinfo Tablecourse id course name

CS101 Computer Programming

Table 2.3: downloadedfiles TableFile Name Downloaded Time

103 output 10.dat 2013-06-21 20:52:04

Here In this application database is required to store student informations for further accessingthis application without using internet. During sign Up process all the informations will be storedinside the sqlite database. The informations are student courses, userId and password along withthat, I am also storing information about file name those are downloaded yet, so that the applicationwill give new file notification when faculty will add a new file to the faculty folder inside coursefolder in FTP server. One of the most important function of sqlite database is to provide securityfor this application which stores the VSFTPD server informations in an encrypted format. Herethe VSFTPD server informations are the login credentials for that server.

2.1.1 DB name, Tables

Database name : LOGIN.dbTable names : LOGIN, courseInfo, downloadedfiles, moodleInfo, moodleInfo, moodleInfo

2

Page 12: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Table 2.4: moodleInfo TableipAddress

http://192.168.193.102/moodle

Table 2.5: serverInfo TableipAddress port loginId password home

10.129.23.232 21 ada HyxA6GP+G/fatLhXdIep8Q== ada

2.1.2 Schema

LOGIN table :CREATE TABLE LOGIN( ID integer primary key autoincrement,USERNAME text,PASSWORDtext, NAME text);courseInfo table :CREATE TABLE courseInfo(course id text not null, course name text);downloadedfiles table :CREATE TABLE downloadedfiles(fileName text not null, downloadedon datetime);moodleInfo table :CREATE TABLE moodleInfo(ipAddress text);serverInfo table :CREATE TABLE serverInfo(ipAddress text, port int, loginId text, password text);webServiceInfo table :CREATE TABLE webServiceInfo(ipAddress text);

2.1.3 Code

2.1.4 Folder Generation

2.1.5 Purpose

All the synchronization process will be based on different folder content between student tabletfolder and FTP server folder contents. This application synchronises student course folder with thecorresponding course folder contents in the FTP server.

• Directory structure : For better synchronisation purpose students android application willcreate different course folder under the parent folder named Sync. Suppose X student hasregistered for three courses named 101,102,103 then the directory structure will be

Page 13: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Sync

101

102

103

Similarly in FTP server the folders will be created if not existing before and the directory struc-ture will be

Sync

101

102

103

Faculty

Suppose the student Roll number is 113050003 then the course folder in FTP contents subfolder

Sync

101

113050003

102

113050003

103

113050003

The whole tree structure folder in FTP server for all students will look like

Page 14: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Sync

101

113050002

113050003

113050004

102

113050003

113050004

113050005

113050006

113050007

113050008

103

113050002

113050003

113050004

All these folders will be created in students tablet inside SD card and also inside FTP server afterthe student will be able to signup with this application using their valid moodle ID and password.

2.2 Methods of file Synchronization

2.2.1 Chunking

Transferring files in terms of blocks during upload and download process. Before upload or downloadfirst files will be divided into blocks of fixed size and then file blocks needs to be transferredfrom student tablet to ftp server or vice versa. Similar techniques will be used in faculty desktopapplications. The point of using this technique is that during file transfer there may be chances forwifi disconnection. So to avoid this problem download process or upload process needs to resumefrom that point where last synchronisation has finished, so that bandwidth and time will be saved.With this chunking method block -level file transfer is used to provide high performance by usingfast sync. With this method only part of the file will be transferred rather transferring whole fileif connection has been disconnected in between the transmission. The slow sync file transfer will

Page 15: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

require all files to be transferred even if there are some similarity between source and the destination.

2.2.2 Upload

Before uploading file will be splitting into multiple chunks and each chunk will be transmittedindividually to the students folder and at the FTP server the whole chunk will be stored inside aparent folder whose name is same as file name as in student folder.

2.2.3 Download

Then when faculty will download the student folders contents, the content will be received as abunch of multiple chunks at the faculty side and when final chunk of that file will be received andthe desktop application will convert it into a single file.1 2

2.2.4 Transferring files in terms of chunks

Here during file transfer I am transferring files in terms of chunks. For this files needs to be splittinginto same size blocks.

How it is working in my application

Suppose a student wants to sync a file with his/her student folder in some course. Then he/sheneeds to select that file for uploading after clicking the upload button. Before uploading file it needsto be splitted into similar blocks and it will be stored in a local folder named splitted. After thewhole file finishes splitting then actual uploading starts. Then the splitted blocks will be transferredindividually.Suppose during file uploading the wifi got disconnected then when the wifi connection will beestablished then the rest of the chunks needs to be uploaded rather uploading the whole numbersof chunks again. For this a service needs to be run in the background which will check whetherany remaining chunks still exist inside the splitted folder, if it finds any splitted chunks inside thatfolder then it will try to upload all the remaining chunks and deleting the recent uploaded chunks.And the whole thing of uploading will be done by the service which is running in the background.Here the service will run between every 5 sec to check whether any splitted chunks still exit in thatsplitted folder. To do this the service will share a context variable between the splitting thread anduploading thread.

During file download in faculty side

Both faculty side desktop application and student android application will use the same size blockfor splitting and merging. When the teacher will download whole students files then splitted chunkswill be downloaded in to facultySync folder and after single folder blocks are transferred from thecorresponding student folder, then the desktop application will start merging the recently madefolder. All the folder generation will be made by the desktop application based on the folder

1NOTE : we are storing only chunks of files inside FTP server.2NOTE : Splitting and chunking are interchangeable

Page 16: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

structure as it is inside FTP server named Sync folder. Same thing will work during file uploadingby the teacher to the faculty folder and when it is downloaded by student’s folder.

2.3 Running a service in background

Purpose: The service runs in the background to provide notification to tablet student tabletswhen new file is added to the faculty folder. Based on the filename difference between studenttablets files and faculty folder files in VSFTPD the notification will be generated in the studenttablets. For getting this feature the user need to start the service and the service will start runningin the background and it is an option for the user to start the service. When the user will click thenotification it will show all the course folders and the updated course folder succeed by changedname changed i.e. CS101(changed)Code For this part has been implemented in appendix D.

Page 17: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Chapter 3

Architecture

3.1 Architecture for the syncing application

Figure 3.1: Architecture for Syncing contents

3.1.1 Student tablet

Here students are using Aakash tablet for syncing their files with the VSFTPD server. These tabletare having android OS. Students need to connect with the wifi for making connectivity with thestorage system here the storage system is a very secure FTP daemon.

Initially the tablet needs to have following requirements for running the sync application. Theseare as follows.

• Sqlite database which comes with android os itself

• Wifi connectivity

• Internet connection during signUp process

• It needs configuring the moodle server web address

8

Page 18: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

• configuring web server address inside sqlite database that will provide the FTP server infor-mation (for making secure connection with the very secure FTP daemon ) , required duringsignUp process.

3.2 Teacher Side Sync Application

Here I have designed a desktop application for providing syncing facility for the teachers. HereI have considered desktop PC or laptops as the syncing device for teachers and the admin userbecause they need to get all registered student’s files in a single device and that device needs tohave maximum capacity for storing all these files. Though Aakash tablet does not support for hugestorage, so we need a PC or laptop for teacher side content synchronisation. Here the teacher’sdesktop application architecture is as follows.

3.2.1 Teacher’s Side SyncApp Architecture

First of all when the application starts running it will check wheather a FacultySync folder exit underuser’s home folder, if not exit then the application will create a new folder named FacultySync. Afterthat the application needs a moodle Ip configuration i.e. http://MoodleServerIPAddress/moodle.Then a user will be able to sign up with this application. Then the teacher will ask the admin for a fileknown as courseinfo.txt which contains all course name with their ID. And this file is needed to checkwhether the user is a student or a teacher. If a user is trying to signUp with the application withoutthis file, then he/she will not able to signup. The Sign-up informations are moodleID, password,userid, newpassword, conform newpassword. After successful sign-up then course folders and onetext file named courses.txt file will be created inside FacultySync folder in current user’s homefolder. The courses.txt file will help for further accesing the course during content synchronisationsand course folders will be the folder location where faculty can download all the student’s uploadedfile with a single click, by pressing the download button. Then after successful login welcome pagewill be displayed. Here a user need to provide the web address i.e http://IPaddress:portnumber ofthe web server which is running a web service to provide the IP address, username and passwordfor accessing VSFTPD server. Then all VSFTPD server authentication informations will be storedin a file named FTPSettings with encrypted form and the application will read the file and use itfor establishing a connection with VSFTPD. Now user will be able to sync any number of files to aparticular course after selecting the course name from the drop down list. Suppose the faculty wantto download all student file for a perticular moodle course, then he need select the course namefrom the drop down list and after that he/she will get all student’s files inside the course no folderin FacultySync folder.

3.3 Assignments Deadline as per the sync application

Students will be able to upload files inside their FTP folder with meeting the deadline of anyassignments or any online exam. For this firstly faculty needs to create assignments with deadline.When student needs to upload files to that assignment then one has to to the corresponding coursefolder and then select the file that needs to be uploaded, then select the appropriate assignmentsto upload. Then the file will be uploaded as per our splitting method and at the FTP server thefile will be stored with splitted files whose names are preceded by the assignment name.

Page 19: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

With this faculty can conduct an online exam which requires question and answer need to beuploaded/downloaded before the deadline start and after it is over and also for fixing the deadlinefor assignment upload/download both for faculties and students.

Page 20: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Chapter 4

Implementation

4.1 VSFTPD

In syncing application I am using FTP server for storage system. Here for the implementationpurpose it needs to have one running vsftpd server.

Vsftpd supports virtual users with PAM (pluggable authentication modules). A virtual user isa user login which does not exist as a real login on the system in /etc/passwd and /etc/shadowfile. Virtual users can therefore be more secure than real users, because a compromised account canonly use the FTP server but cannot login to system to use other services such as ssh or smtp.[17]

Benefit of using Vsftpd for Storage

• very high secure

• good scalability

• the possibility to create virtual users

• better than average performance

• the possibility to access virtual IPs

• high speed

• bandwidth limits

Over the 24 hours, vsftpd has served 2.6TB (yes, terabytes) with a concurrent user count often over1,500. This is on a single machine.[16]

11

Page 21: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

4.1.1 How vsftp server is more Secure:

• For my application I am using vsftpd (very secure FTP server daemon)for storage purpose.

• It is safe from buffer overflow attack.

• Only ftp files area is accessible to the authorized user.

• whole system files are safe from attack as it is using virtual user login credentials.

4.1.2 Settings for vsftpd.conf[10]

# disables anonymous FTPanonymous enable=NO# enables non-anonymous FTPlocal enable=YES# activates virtual usersguest enable=YES# virtual users to use local privs, not anon privsvirtual use local privs=YES# enables uploads and new directorieswrite enable=YES# the PAM file used by authentication of virtual usespam service name=vsftpd-virtual# in conjunction with ’local root’,# specifies a home directory for each virtual useruser sub token=$USERlocal root=/home/destiny/Sync# the virtual user is restricted to the virtual FTP areachroot local user=YES# hides the FTP server user IDs and just display ”ftp” in directory listingshide ids=YES# runs vsftpd in standalone modelisten=YES# listens on this port for incoming FTP connections#listen port=60021# the minimum port to allocate for PASV style data connectionspasv min port=62222# the maximum port to allocate for PASV style data connectionspasv max port=63333# controls whether PORT style data connections use port 20 (ftp-data)connect from port 20=YES# the umask for file creationlocal umask=022chroot list enable=YES

Page 22: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

4.2 Connectivity to Moodle

4.2.1 Function of moodle inside application

It will help in providing authenticated user to use this application.Users will automatically get the registered course name and course-id from moodle web-service

4.2.2 Moodle installation and accessing moodle web service [9][7]

♦ Download the latest moodle tar file from the web

♦ First move the Moodle files into the system’s web directory

♦ Create a single database for Moodle to store all its tables in (or choose an existing database).

♦ Visit your Moodle site with a browser, then you will be redirected to the install.php script,which will lead you through creating a config.php file and then setting up Moodle, creatingan admin account etc.

♦ For accessing moodle from local Ip address type http://localhost/moodle in your browserURL.

♦ Our application needs every user to access the moodle from IP address, So the config.phpfile needs to be changed as our requirement. Here you have to add $CFG-¿wwwroot =’http://YourIPAddress/moodle’; in config.php file.The path to this file is /var/www/moodle/config.php.

4.2.3 Creating user in moodle database

♦ Login as an admin user

♦ click home

♦ click settings

♦ go to site administration

♦ then go to users

Page 23: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

♦ then click add new user

♦ then fill the user details then click create users

♦ login as an admin user and make turn on editing

4.2.4 Adding Course to moodle

? Go to settings and click add/edit courses

? Adding users to the courses :

? click home

? click current courses

? Then find and click the courseId for which you want to add user(student or teacher)

? Then go to settings and click users

? click enrolled users

? then list of registered user will appear

? click enrol users from that page

? Select the users from the list to enrol for the course

? click enrol and then click finish enrolling users

4.2.5 Creating a moodle web service

♦ go to settings then site administration

♦ then click plugin

♦ go to web services

♦ then click external services

♦ then click add

♦ select enable

♦ select authorised user if you need

♦ give a name to the service and select the required capability

♦ click save changes button from page

♦ click functions for adding/deleting functions to the moodle web service

Page 24: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

♦ then click add functions

♦ select the required function from the dropdown list

♦ then click add function button after selecting

♦ you can remove functions similarly

4.2.6 Managing token

• Go to site administration, then plugin

• click web services

• then click manage tokens

• then click add

• then select user and select web service

• then click save changes

• it will create token for that user with the corresponding web service

4.2.7 Calling a moodle web service from Android OS

Considering moodle as the user’s database I have taken help with moodle web service to save user’sinformations such as user name, password, course name for all users. To get access to all this servicesI am sending http request for the moodle web services for getting user token. After getting theuser token then I am calling different web service methods to access various user informations i.e.user’s course name and the type of user informations. Code for this section has been implementedin appendix C.

Page 25: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Sync Application

4.3 Sync Manual

Assume that Moodle users are exiting prior to installing this application.

◦ Install Vsftpd server in a network Computer

◦ Create a virtual user

◦ Create parent Directory named Sync inside this users directory

◦ Start the web service

◦ Run Faculty Sync application

4.3.1 Admin PC :

? Configure moodle i.e. http://IP Address/moodle

? Enter admin moodle information( loginId, password, userId)

? Press ConfigureFTP

? Enter web service web address i.e. http://Web service IP address:8181

? Enter VSFTPd IP address i.e. IP address VSFTPD server, port i.e 21, FTP loginId andFTP password

? Press OK

? Then follow the steps to finish configuration.

4.3.2 Faculty PC :

· Create FacultySync folder in your home directory

· Configure moodle i.e. http://Moodle Ip Address/moodle

· Configure FTP using web service address i.e. http://Web service IP address:port (to be im-plemented)

· Click find course button

· SignUp with your moodle information and provide your local password for further use i.e.

16

Page 26: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

· Moodle login ID, password and userID

· Press Authenticate button

· Login with userId and local password

· Select course to Sync

· Click Sync course button

· Click upload button to upload a file

· Select a file from your PC to upload

· Click View uploaded files button to view all uploaded files

· Select a uploaded file to delete it, if uploaded mistakenly

· Click download button to download all students files from FTP server for this course. Thenall files will be downloaded to the FacultySync folder inside same courseId in Faculty PC.

· Select a course and then click assignment button to add assignment for that course. It willcreate an assignment for that course with due date and time. Press add assignment and giveassignment name with due date and time.

4.3.3 Student tablet

◦ Create a folder named Sync inside your SD card

◦ Connect the tablet with the Wifi

◦ Connect it with internet

◦ switch on the proxy android if needed.

◦ open application

◦ Configure moodle ip ( http://IP address/moodle )

◦ Configure FTP just by pressing the button

◦ Sign Up with moodle userId, password with this moodle user will be authenticated and coursefolder in ftp will be created in ftp server as well as inside student tablets.

◦ sign in with the local authentication this will navigate you to the page with your course list

◦ Click the particular course to synchronise

◦ click Upload button to upload a file from the Sync folder of your SD card. This will show allthe files stored inside the course directory. So to upload a file, first you need to put it insidethat corresponding course folder inside Sync directory of the SD card. You have a scrollablelist box to find out the file from many.

Page 27: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

◦ Click Download button to download a file that faculty has uploaded to his faculty folder forthat course in FTP server.Suppose a student has downloaded a file, then the list will not showthat file name. If needed then select the check box named show all.

◦ One can view all uploaded files by clicking the Uploaded files button.

◦ One can delete that file by selecting the file name inside the listview

◦ Please dont select file after clicking Uploaded files button if you dont want to delete file.

◦ The top portion of the page will show the current course name which is in the syncing process.

◦ One service is alway running in the background to check whether a new file is added tothe faculty folder. If added it will show a notification to the user even if he has closed theapplication. You can get this service as an optional by clicking start button after logging withthe application. Then the after clicking the notification it will take you to the correspondingcourse folder for which that notification has been generated.This service is calculating filedifference between the tablet database with the current file names inside FTP server.

4.4 Features of this Aakash Sync Application

4.4.1 Features of my sync app for student side

• Student can view all files in his/her own student folder for which he is a students,

• Student can upload and download files

• Every time teacher puts a file in the faculty folder will be notified to student by the application

• Student can delete his/her already uploaded file

• He/she can upload same file as many times as per his/her wish but last upload file will replacethe if the file name are same

• Can view all uploaded files from his/her own student folder.

4.4.2 Features of sync app for faculty side :

• Faculty can upload files to the course folder inside faculty public folder from where all theregistered students can access that files.

• This application is allowing all faculties to change or delete all the uploaded files files if needed.

• Faculty can download all files from all registered students( the student who is already regis-tered with that course) folder with a single click using his desktop application.

• He/she can view and change all files uploaded to the faculty folder inside course folder

• One faculty can use these facility for all course for which he/she is a faculty

• One auto-sync facility is also provided to the faculty desktop application by which

Page 28: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

• he/she can get all students folders contents as per deadline. This facility will help faculty toconduct class test or assignment evaluations which will collect all students answer sheets afterthe deadline automatically.

Page 29: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Chapter 5

Security

5.1 Security in VSFTPD server

Here for the purpose of storing all uploaded file by students and teachers are stored in a secure FTPserver. So here I am using a VSFTPD server which is allows to use virtual users a FTP client. Herevirtual user are restricted to their own home folder rather accessing other files and folders insidethe PC. This is helpful in case the FTP credentials are compromised.

Here I am storing all the VSFTPD credentials inside the tablet using sqlite database. Here allthe credential are in encrypted format. So I am using AES encrypted standard for encryption anddecryption. Before storing the FTP password it is encrypted to some form and when it is usedthe it is again queried to the database and then it is decrypted before it is used. By this way myapplication is more secure for any number of users with same username and password.

5.2 Running Web service and application security

Purpose

Here for the purpose of security concern the application is not sharing FTP user credentials withstudent or teacher, for that purpose the application is getting the IP address, username and pass-word from a running web service. At the initial stage when student want to sign Up with theapplication, then he/she needs to provide the web service IP address to the application. Then afterpressing the ConfigureFTP button it will ask for web service IP address with port numberex: http://10.129.23.232:8080

5.2.1 Security in web service and application:

Only student will get the IP address of the web service running host then if a student/user triesget web service information then he will not able to get it because for that a user need to know thefull URL and the full url is given in application code itself.

After receiving the FTP information, then it will be stored in a sqlitedatabase inside Aakashtablet and this is done by the application itself.

20

Page 30: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Requirements : Any web server tomcat or glsssfishFor coding part refer to appendix B

Page 31: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Chapter 6

Results and Discussions

6.1 Testing and Performance Evaluations :

For testing the performance of the application, I have tested it using Kresit wifi network and myVSFTPD server is installed in ADA lab IITB, CSE department. Here the network speed is 54mbpsand I have downloaded and uploaded file size upto 20 Mega Bytes at a time. The performance Ihave measured by 4 tablet devices and one vsftpd server and the server is having I-5 processor. HereI have measured downloading speed, uploading speed and the chunking speed of the application bytablet devices.

Experimental Results :

With the above experiments I concluded that the uploading and downloading speed of the VSFTPDserver is linear and it depends on the current network load. Here in figure 7.1 the download timeis almost linear. But in figure 7.2 initially the graph is linear but in the middle it has reached itspeak time then it is decreased to some point lower than previous time even if the file size is greaterthan the previous one. Then the uploading curve shows a zigzag line, so it shows the uploadingtime depends on the current network load.

In figure 7.3, it shows the file size vs chunking time graph and the curve initially grows linearbut when the file size 14 Mega Bytes the slope value increases, then after 16 Mega bytes the curvestarts in decreasing. All this chunking depends on android OS and Aakash tablet processing speed.Then the curve grows linearly.

The average curve of chunking in figure 7.4, it shows the chunking speed is propertional to thefile size, Android OS and Aakash tablet processing speed and the graph is linear. Figure 7.5 showsaverage uploading speed and the graph is linear and depends on the current network load, so thecurve has been slightly diverted to non-linear at file size 16 MB. Similarly average downloadingspeed speed curve is shown in fig.7.6 and it shows a linear downloading speed.

22

Page 32: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Figure 6.1: Experiment: File Downloading Speed from VSFTPD server by android application fora single student tablet

Page 33: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Figure 6.2: Experiment: File Uploading Speed from android application to VSFTPD server for asingle student tablet which includes both chunking time and uploading time

Page 34: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Figure 6.3: Experiment: File chunking speed by android application

Page 35: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Figure 6.4: Experiment: Average file chunking speed by 4 Aakash tablets

Page 36: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Figure 6.5: Experiment: Average file Uploading speed by 4 Aakash tablets

Page 37: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Figure 6.6: Experiment: Average file downloading speed by 4 Aakash tablets

Page 38: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Chapter 7

Summary and Conclusion

7.1 Summery

This project is meant for studnet file synchronization with faculty PC and vice-versa. So here Ihave chosen a client-server architecture for solving this problem. With this architecture I haveimplemented an android application for Aakash tablet which is now able to help students synchro-nizing their tablet files with the dedicated server. Also I have implemented a desktop applicationfor teachers to synchronize their files with the central server, so that all students will be able toget these files. Finally students file will reach at Faculty folder in server and thenb it will reach atteacher’s folder securely in teachers PC.

For security purpose I am registering users with moodle userID, password. The applicationallows each student’s and teachers to store files in separate folders in server under a commondirectory where files are stored in the server in terms of chunks. when the teacher downloads thisfile, all these chunks will be downloaded into a common directory where directory name is same asfile name. After all chunks finishes downloading then the application will start combining all thesedownloaded chunks. Then the application checks whether any remaining files still exit in server, ifit finds then the same process will continue until all files are not downloaded. One more thing isall students files are uploaded to the server in terms of block/chunk. These chunks are uploadedseparately as single file from students tablets and these chunks are stored under a folder where thisfolder name is same as the uploaded file name. When faculty downloads this then all these foldercontains are downloaded rather downloading the folder at time. When it finds the whole folderfile has been downloaded then the facultySync application will try to combine these chunks. Aftercombining this chunks, it will rename the folder preceding with downloaded. Then the downloadingprocess will continue for folders whose name are not preceded by downloaded. Here also noted thatstudents are restricted to upload file with any name. They need to upload files as per teachersinstructions. I have added this chunking facility to better extend this application for fixing issuewhen the wifi goes down during file upload and download. When they will once again come withthe wifi, when they will be able to connect then they will get only file blocks or file which are notyet downloaded.

29

Page 39: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

7.2 Conclusion

In the earlier section I have discussed the design and implementation aspect of the application.Now for using this application all students files will be put under a common directory with differentuser’s files in different subdirectories. With this all the syncing facilities has been achieved andI have deployed the application in IITB campus network and I have done all above experimentusing some temporary users. The experimental results shows some better result with linearity inperformance curve. Since the performance depends on the VSFTPD server, so by increasing theperformance of the VSFTPD server we can get most benefit from this application.

Page 40: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Appendices

31

Page 41: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Appendix A

Folder generation after successful SignUp

code :protected String doInBackground(String... params) {

// TODO Auto-generated method stub

String token = ””, loginIdAndUser = ””, loginId = ””, userName = ””;token = getToken(userLoginId, userPassword);if(token.equals(”Not Assigned Result”)){return ”Invalid User”;}else if(token.equals(”Exception”)){return ”Invalid User”;}else if(token.equals(””)){return ”Invalid User”;}else if(token.contains(”not found”)){return ”Invalid User”;}try{generateXML(token, userId);}catch(IOException e){loginId = ”Exception”;}loginIdAndUser = getMyLoginId();StringTokenizer st = new StringTokenizer(loginIdAndUser);if(st.hasMoreTokens()){loginId = st.nextToken();userName = st.nextToken();if(st.hasMoreTokens())userName += ” ” + st.nextToken();}

32

Page 42: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

if(loginId.equals(”Not Assigned”)){return ”Invalid User”;}String courses = returnCourses(token, userId);if(courses.equals(”Exception”)){return ”Could not fetch courses”;}if(courses.equals(””)){return ”No course registered yet”;}loginDataBaseAdapter = new LoginDataBaseAdapter(signUp.context);loginDataBaseAdapter = loginDataBaseAdapter.open();

String status = ftpConnect(ftpIpAddress, ftpLogin, ftpPassword, ftpPort);String currentDirectory = ”/home/” + ftpLogin + ”/Sync/”;ftpChangeDirectory(currentDirectory);FTPFile fileList[] = ftpPrintFilesList(currentDirectory);boolean courseFolderFound = false;

StringTokenizer st2 = new StringTokenizer(courses);while(st2.hasMoreTokens()){courseFolderFound = false;String currCourse = st2.nextToken();for(int i = 0; i ¡ fileList.length; i++){if(fileList[i].equals(currCourse)){courseFolderFound = true;break;}}if(!courseFolderFound){ftpMakeDirectory(currentDirectory + currCourse);ftpMakeDirectory(currentDirectory + currCourse + ”/Faculty”);}ftpMakeDirectory(currentDirectory + currCourse + ”/” + signUp.userName);loginDataBaseAdapter.insertCourse(currCourse, ”Default”);}loginDataBaseAdapter.close();return userName;}

Page 43: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Appendix B

Running Web service for providingVSFTPD server user informations

code : package org.me.configureftp;

import javax.jws.WebService;import javax.jws.WebMethod;import javax.jws.WebParam;import javax.ejb.Stateless;

/** * * @author destiny */ @WebService(serviceName = ”ConfigureFTP”, targetNamespace =”configureftp.me.org”)@Stateless()public class ConfigureFTP {

String ipAddress, loginId, password, home;int port;

/**Web service operation/@WebMethod(operationName = ”Configure”)public Boolean Configure(@WebParam(name = ”ipAddress”) String ipAddress, @WebParam(name= ”port”) int port,@WebParam(name = ”loginId”) String loginId, @WebParam(name = ”password”) String password,@WebParam(name = ”home”)String home) {//TODO write your implementation code here:this.ipAddress = ipAddress;this.port = port;this.loginId = loginId;if(password.equals(” ”))password = ”@ConvertedFromSpace@”;this.password = password;this.home = home;

34

Page 44: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

return null;}

/**Web service operation/@WebMethod(operationName = ”getConfiguration”)public String getConfiguration() {return ipAddress + ” ” + Integer.toString(port) + ” ” + password + ” ” + loginId + ” ” + home;}}

Page 45: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Appendix C

Calling a Moodle web service fromAndroid

code : class Moodler extends AsyncTask ¡ String, String, String¿ {TextView t1;SignUpActivity signUp;String userLoginId;String userPassword;String userId;LoginDataBaseAdapter loginDataBaseAdapter;FTPClient mFTPClient;ProgressDialog progress;String ftpIpAddress, ftpLogin, ftpPassword, ftpHome;int ftpPort;String moodleIpAddress;

public Moodler(TextView t, String uli, String up, String ui, String ftpAddress, int port, StringftpLogin, String ftpHome, String ftpPassword, String mipa, SignUpActivity ma){t1 = t;signUp = ma;userLoginId = uli;userPassword = up;userId = ui;ftpIpAddress = ftpAddress;ftpPort = port;this.ftpLogin = ftpLogin;this.ftpHome = ftpHome;this.ftpPassword = ftpPassword;moodleIpAddress = mipa;}

@Overrideprotected void onPreExecute() {//progress = ProgressDialog.show(signUp.context, ”Connecting...”, ”Connecting to Moodle andVerifying”,

36

Page 46: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

true);//Toast.makeText(signUp, ftpIpAddress + ” ” + ftpPort + ” ” + ftpLogin + ” start ” + ftpPass-word + ”End”, Toast.LENGTH LONG).show();

progress = new ProgressDialog(signUp);progress.setTitle(”Connecting...”);progress.setMessage(”Connecting to Moodle and Verifying”);progress.setCancelable(false);progress.setIndeterminate(true);progress.show();}

@Overrideprotected String doInBackground(String... params) {// TODO Auto-generated method stub

String token = ””, loginIdAndUser = ””, loginId = ””, userName = ””;token = getToken(userLoginId, userPassword);if(token.equals(”Not Assigned Result”)){return ”Invalid User”;}else if(token.equals(”Exception”)){return ”Invalid User”;}else if(token.equals(””)){return ”Invalid User”;}else if(token.contains(”not found”)){return ”Invalid User”;}try{generateXML(token, userId);}catch(IOException e){loginId = ”Exception”;}loginIdAndUser = getMyLoginId();StringTokenizer st = new StringTokenizer(loginIdAndUser);if(st.hasMoreTokens()){loginId = st.nextToken();userName = st.nextToken();if(st.hasMoreTokens())userName += ” ” + st.nextToken();}

if(loginId.equals(”Not Assigned”)){

Page 47: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

return ”Invalid User”;}String courses = returnCourses(token, userId);if(courses.equals(”Exception”)){return ”Could not fetch courses”;}if(courses.equals(””)){return ”No course registered yet”;}loginDataBaseAdapter = new LoginDataBaseAdapter(signUp.context);loginDataBaseAdapter = loginDataBaseAdapter.open();

String status = ftpConnect(ftpIpAddress, ftpHome, ftpPassword, ftpPort);String currentDirectory = ”/home/” + ftpLogin + ”/Sync/”;ftpChangeDirectory(currentDirectory);FTPFile fileList[] = ftpPrintFilesList(currentDirectory);boolean courseFolderFound = false;

StringTokenizer st2 = new StringTokenizer(courses);while(st2.hasMoreTokens()){courseFolderFound = false;String currCourse = st2.nextToken();for(int i = 0; i ¡ fileList.length; i++){if(fileList[i].equals(currCourse)){courseFolderFound = true;break;}in }if(!courseFolderFound){ftpMakeDirectory(currentDirectory + currCourse);ftpMakeDirectory(currentDirectory + currCourse + ”/Faculty”);}ftpMakeDirectory(currentDirectory + currCourse + ”/” + signUp.userName);loginDataBaseAdapter.insertCourse(currCourse, ”Default”);}loginDataBaseAdapter.close();return userName;}

@Overrideprotected void onPostExecute(String str) {progress.dismiss();ftpDisconnect();File first = new File(Environment.getExternalStorageDirectory() + ”/newdoc.xml”);File second = new File(Environment.getExternalStorageDirectory() + ”/newdoc2.xml”);//Toast.makeText(signUp.getApplicationContext(), str, Toast.LENGTH LONG).show();if(first.exists()){

Page 48: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

first.delete();}if(second.exists()){second.delete();}if(str.equals(”Invalid User”) —— str.equals(””)){Toast.makeText(signUp.getApplicationContext(), ”Invalid User!!!”, Toast.LENGTH LONG).show();signUp.finish();}else if(str.equals(”Could not fetch courses”)){Toast.makeText(signUp.getApplicationContext(), ”Could Not Fetch Courses”,Toast.LENGTH LONG).show();signUp.finish();}else if(str.equals(”No course registered yet”)){Toast.makeText(signUp.getApplicationContext(), ”No course registered yet”,Toast.LENGTH LONG).show();signUp.finish();}else{t1.setText(str);Toast.makeText(signUp.getApplicationContext(), ”Valid User”, Toast.LENGTH LONG).show();}}

@Overrideprotected void onPostExecute(String str) {progress.dismiss();ftpDisconnect();File first = new File(Environment.getExternalStorageDirectory() + ”/newdoc.xml”);File second = new File(Environment.getExternalStorageDirectory() + ”/newdoc2.xml”);//Toast.makeText(signUp.getApplicationContext(), str, Toast.LENGTH LONG).show();if(first.exists()){first.delete();}if(second.exists()){second.delete();}if(str.equals(”Invalid User”) —— str.equals(””)){Toast.makeText(signUp.getApplicationContext(), ”Invalid User!!!”, Toast.LENGTH LONG).show();signUp.finish();}else if(str.equals(”Could not fetch courses”)){Toast.makeText(signUp.getApplicationContext(), ”Could Not Fetch Courses”,Toast.LENGTH LONG).show();signUp.finish();}

Page 49: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

else if(str.equals(”No course registered yet”)){Toast.makeText(signUp.getApplicationContext(), ”No course registered yet”,Toast.LENGTH LONG).show();signUp.finish();}else{t1.setText(str);Toast.makeText(signUp.getApplicationContext(), ”Valid User”, Toast.LENGTH LONG).show();}}

public String getToken(String usrLoginId, String password){String loginId = ””;String responseStr=”not assigned”;String token = ”Not Assigned”;String result = ”Not Assigned Result”;HttpPost post = new HttpPost(moodleIpAddress + ”/login/token.php”);HttpClient client = new DefaultHttpClient();List¡NameValuePair¿ params = new ArrayList¡ NameValuePair ¿();params.add(new BasicNameValuePair(”username”, usrLoginId));params.add(new BasicNameValuePair(”password”, password));params.add(new BasicNameValuePair(”service”,”get all users”));try{post.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF 8));HttpResponse response = client.execute(post);if (response.getStatusLine().getStatusCode()==200){responseStr=EntityUtils.toString(response.getEntity());}String loginReturnStr = responseStr;token = loginReturnStr.substring(10, 42);result = token.toString();}catch(Exception e){e.printStackTrace();result = ”Exception”;}return result;}

void generateXML(String tkn, String userId) throws ProtocolException, IOException {String token = tkn;String domainName = moodleIpAddress;String restformat = ”xml”; //Also possible in Moodle 2.2 and later: ’json’//Setting it to ’json’ will fail all calls on earlier Moodle versionif (restformat.equals(”json”)){restformat = ”&moodlewsrestformat=” + restformat;}

Page 50: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

else{restformat = ””;}String urlParameters = ”userids[0]=” + URLEncoder.encode(userId, ”UTF-8”);String functionName = ”core user get users by id”;String serverurl = domainName + ”/webservice/rest/server.php” + ”?wstoken=” + token + ”&ws-function=”+ functionName;HttpURLConnection con = (HttpURLConnection) new URL(serverurl).openConnection();con.setRequestMethod(”POST”);con.setRequestProperty(”Content-Type”, ”application/x-www-form-urlencoded”);con.setRequestProperty(”Content-Language”, ”en-US”);con.setDoOutput(true);con.setUseCaches (false);con.setDoInput(true);DataOutputStream wr = new DataOutputStream (con.getOutputStream ());wr.writeBytes(urlParameters);wr.flush ();wr.close ();PrintWriter out = new PrintWriter(Environment.getExternalStorageDirectory() + ”/newdoc2.xml”);//Get ResponseInputStream is = con.getInputStream();BufferedReader rd = new BufferedReader(new InputStreamReader(is));String line;StringBuilder response = new StringBuilder();while((line = rd.readLine()) != null){response.append(line);response.append(’̊’);out.println(line + ”̊”);}rd.close();out.close();}

Page 51: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Appendix D

Running a service for GeneratingNotifications for Student AndroidApplication

Code :public class MyService extends Service{

private static final String TAG = ”MyService”;int i = 0;String loginId, name;String courses;String arrCourses[];String courseId = ””;String changedCourses = ””;int newFiles = 0;int numCourses = 0;String test = ”abc”;Handler handler = new Handler();final MyService ms2 = this;public FTPClient mFTPClient = null;boolean started = false;

String ftpIpAddress, ftpLogin, ftpPassword;

NotificationCompat.Builder mBuilder = null;NotificationManager mNotifyMgr = null;

private final Runnable sendData = new Runnable(){public void run(){if(started){newFiles = 0;try {//prepare and send the data here..changedCourses = ””;

42

Page 52: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

for(int i = 0; i ¡ numCourses; i++){courseId = arrCourses[i];int currFiles = areFilesUploaded();newFiles += currFiles;if(currFiles != 0)changedCourses = changedCourses + courseId + ” ”;}

//Toast.makeText(MyService.this, newFiles + ” ” + numCourses +Integer.toString(newFiles)+ ” ” + courses + ” Run number ” + i++, Toast.LENGTH LONG).show();if(newFiles == 0){if(mNotifyMgr != null){mNotifyMgr.cancel(001);}}if(newFiles != 0){mBuilder = newNotificationCompat.Builder(MyService.this).setSmallIcon(R.drawable.download notify2).setContentTitle(”Mynotification”).setContentText(Integer.toString(newFiles) + ” new files found”);Intent resultIntent = new Intent(MyService.this, Welcome.class);// Because clicking the notification opens a new (”special”) activity, there’s// no need to create an artificial back stack.Bundle b = new Bundle();b.putString(”login”, loginId);b.putString(”changedCourses”, changedCourses);b.putString(”name”, name);resultIntent.putExtras(b);

PendingIntent resultPendingIntent = PendingIntent.getActivity(MyService.this,0, resultIntent, PendingIntent.FLAG UPDATE CURRENT);mBuilder.setContentIntent(resultPendingIntent);mBuilder.getNotification().flags —= Notification.FLAG AUTO CANCEL;int mNotificationId = 001;mBuilder.setAutoCancel(true);// Gets an instance of the NotificationManager servicemNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION SERVICE);// Builds the notification and issues it.

mNotifyMgr.notify(mNotificationId, mBuilder.build());}Log.d(TAG, ”onCreate”);handler.postDelayed(this, 10000);

}catch (Exception e) {e.printStackTrace();}

Page 53: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

}}};

Page 54: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Appendix E

Code for security encryption anddecryption[12]

code : class SimpleProtector {

private static final String ALGORITHM = ”AES”;private static final byte[] keyValue =new byte[] { ’c’, ’o’, ’u’, ’n’, ’t’, ’e’, ’R’, ’A’, ’t’, ’t’, ’a’, ’c’, ’K’, ’I’, ’N’, ’G’ };

public static String encrypt(String valueToEnc) throws Exception {Key key = generateKey();Cipher c = Cipher.getInstance(ALGORITHM);c.init(Cipher.ENCRYPT MODE, key);byte[] encValue = c.doFinal(valueToEnc.getBytes());//String encryptedValue = new BASE64Encoder().encode(encValue);String encryptedValue = Base64.encodeToString(encValue, Base64.DEFAULT);return encryptedValue;}

public static String decrypt(String encryptedValue) throws Exception {Key key = generateKey();Cipher c = Cipher.getInstance(ALGORITHM);c.init(Cipher.DECRYPT MODE, key);//byte[] decodedValue = new BASE64Decoder().decodeBuffer(encryptedValue);byte[] decodedValue = Base64.decode(encryptedValue, Base64.DEFAULT);byte[] decValue = c.doFinal(decodedValue);String decryptedValue = new String(decValue);return decryptedValue;}

private static Key generateKey() throws Exception {Key key = new SecretKeySpec(keyValue, ALGORITHM);// SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);// key = keyFactory.generateSecret(new DESKeySpec(keyValue));return key;

45

Page 55: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

}}

Page 56: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

Bibliography

[1] Alternative to file sharing. http://alternativeto.net/tag/file-sharing/?platform=

android-tablet.

[2] Rsync. http://rsync.samba.org,, October 2012.

[3] Android community for application development for ftp connect type @MISC and ‘howpub-lished’. http://androiddev.orkitra.com/?p=28note = 2013-06-22, June 2013.

[4] Android login registration screen with sqlite database exam-ple type @MISC and ‘howpublished’. http://techblogon.com/

android-login-registration-screen-with-sqlite-database-example/ note = 2013-06-22, June 2013.

[5] Apache commons ftpclient java example - download files from servertype @MISC and ‘howpublished’. http://www.mysamplecode.com/2012/03/

apache-commons-ftpclient-java-example_16.html note = 2013-06-22, June 2013.

[6] Code on cloud for android beginners type @MISC and ‘howpublished’. http://

codeoncloud.blogspot.in/2012/07/android-login-activity-with-mysql.html note =2013-06-22, June 2013.

[7] Installing moodle type @MISC and ‘howpublished’. http://docs.moodle.org/23/en/

Installing_Moodle note = 2013-06-22, June 2013.

[8] Java code for retrieving user token type @MISC and ‘howpublished’. https://moodle.org/

mod/forum/discuss.php?d=215303 note = 2013-06-22, June 2013.

[9] Moodle installation type @MISC and ‘howpublished’. https://github.com/moodle/moodle

note = 2013-06-22, June 2013.

[10] Setup virtual users and directories in vsftpd type @MISC and ‘howpublished’. http:

//linuxforfun.net/2008/04/05/vsftpd-virtual-users/note = 2013-06-22, June 2013.

[11] Setup virtual users and directories in vsftpd type @MISC and ‘howpublished’. http://howto.gumph.org/content/setup-virtual-users-and-directories-in-vsftpd/ note = 2013-06-22, June 2013.

[12] slowaes encryption and java decryption type @MISC and ‘howpublished’. http:

//stackoverflow.com/questions/3032832/slowaes-encryption-and-java-decryption

note = 2013-06-22, June 2013.

47

Page 57: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

[13] Sql as understood by sqlite type @MISC and ‘howpublished’. http://www.sqlite.org/lang_createtable.htmlnote = 2013-06-22, June 2013.

[14] Ubuntu server guide: Contain about ubuntu server guide, tutorial, setup and configuration,how to install moodle 2.3 on ubuntu server 12.04 type @MISC and ‘howpublished’. http:

//ubuntuserverguide.com/2012/11/how-to-install-moodle-on-ubuntu-server-12-04.

html note = 2013-06-22, June 2013.

[15] Using moodle web services type @MISC and ‘howpublished’. http://www.rumours.co.nz/

manuals/using_moodle_web_services.htm note = 2013-06-22, June 2013.

[16] vsftpd: Probably the most secure and fastest ftp server for unix-like systems. type @MISCand ‘howpublished’. https://security.appspot.com/vsftpd.htmlnote = 2013-06-22, June2013.

[17] vsftpd type @MISC and ‘howpublished’. https://help.ubuntu.com/community/vsftpd note= 2013-06-22, June 2013.

[18] T.F. Abdelzaher and N. Bhatti. Web server qos management by adaptive content delivery. InQuality of Service, 1999. IWQoS’99. 1999 Seventh International Workshop on, pages 216–225.IEEE, 1999.

[19] S. Agarwal, D. Starobinski, and A. Trachtenberg. On the scalability of data synchronizationprotocols for pdas and mobile devices. Network, IEEE, 16(4):22–28, 2002.

[20] Philipp C. Heckel. Minimizing remote storage usage and synchronization time using deduplica-tion and multichunking: Syncany as an example. Technical Report TR-CS-96-05, universitatmannheim, School of Business Informatics and Mathematics Laboratory for Dependable Dis-tributed Systems University of Mannheim, 2012. http://www.syncany.org/.

[21] Drew Houston and Arash Ferdowsi. Beyond dropbox: Requirements for enterpriseclass secure file sharing and file synchronization. White paper, Accellion, Inc.,2011. http://security.networksasia.net/content/beyond-dropbox-requirements-enterprise-class-secure-file-sharing.

[22] W.Y. Ma, I. Bedner, G. Chang, A. Kuchinsky, and H.J. Zhang. Framework for adaptive contentdelivery in heterogeneous network environments. In PROC SPIE INT SOC OPT ENG, volume3969, pages 86–100. Citeseer, 2000.

[23] S.M. Rho, J.W. Cho, and E.J. Hwang. Adaptive multimedia content delivery in ubiquitousenvironments. In Web Information Systems Engineering–WISE 2005 Workshops, pages 43–52.Springer, 2005.

[24] T. Suel, P. Noel, and D. Trendafilov. Improved file synchronization techniques for maintaininglarge replicated collections over slow networks. In Data Engineering, 2004. Proceedings. 20thInternational Conference on, pages 153–164. IEEE, 2004.

[25] A. Tridgell and P. Mackerras. The rsync algorithm. Technical Report TR-CS-96-05, AustralianNational University, Department of Computer Science, June 1996. http://rsync.samba.org.

Page 58: Content Synchronization Architecture for Dissemination of ... · Content Synchronization Architecture for Dissemination of ... The dissertation entitled \Content Synchronization Architecture

[26] Toshie NINOMIYA Toshio OKAMOTO Xinyou ZHAO, Fumihiko ANMA. Personalized adap-tive content system for context-aware mobile learning. In International Journal of ComputerScience and Network Security, VOL.8 No.8, pages 23–25, August 2008.

[27] J. Zhang, X. Yu, Y. Li, and L. Lin. Hadooprsync. In Cloud and Service Computing (CSC),2011 International Conference on, pages 166–173. IEEE, 2011.

[28] X. Zhao and T. Okamoto. A device-independent system architecture for adaptive mobilelearning. In Advanced Learning Technologies, 2008. ICALT’08. Eighth IEEE InternationalConference on, pages 23–25. IEEE, 2008.