73
1. INTRODUCTION Location cloaking is one typical approach to protect the user location privacy in LBS. Upon receiving a location-based spatial query (e.g., a range query or a kNN query) from the user, the system cloaks the user’s current location into a cloaking region based on the user’s privacy requirement. The location-based spatial query is, thus, transformed into a region-based spatial query before being sent to the LBS server. The LBS server then evaluates the region- based query and returns a result superset, which contains the query results for all possible location points in the cloaking region. Finally, the system refines the result superset to generate the exact results for the query location. In the literature, a variety of cloaking algorithms based on snapshot user 1

SECURE LOCATION BASED QUERY OPTIMIZATION

Embed Size (px)

Citation preview

Page 1: SECURE LOCATION BASED QUERY OPTIMIZATION

1. INTRODUCTION

Location cloaking is one typical approach to protect the user

location privacy in LBS. Upon receiving a location-based spatial

query (e.g., a range query or a kNN query) from the user, the system

cloaks the user’s current location into a cloaking region based on the

user’s privacy requirement. The location-based spatial query is, thus,

transformed into a region-based spatial query before being sent to the

LBS server.

The LBS server then evaluates the region-based query and

returns a result superset, which contains the query results for all

possible location points in the cloaking region. Finally, the system

refines the result superset to generate the exact results for the query

location. In the literature, a variety of cloaking algorithms based on

snapshot user locations have been developed for different privacy

metrics.

1

Page 2: SECURE LOCATION BASED QUERY OPTIMIZATION

2. SYSTEM ANALYSIS

2.1 EXISTING SYSTEM

In existing system though we have many web sites portal, and

through high end mobile phones or PDAs we can get information

about the needed sometimes. But these systems are not available to all

and not all time. And also, this information does not reach people at

the time of emergencies. It cannot be accessed by people who don’t

know to access the device. Other wise we have to make a call to some

one or to make an enquiry to know about the current location. Thus it

fails to provide privacy for the user.

2

Page 3: SECURE LOCATION BASED QUERY OPTIMIZATION

2.2 PROPOSED SYSTEM

Proposed system provides more easy and efficient way to get

answer about the location and other related queries via J2ME mobile.

In this system we can get the answer about What, When, and how the

queries are. To use this system, there is no need of using any extra

devices or searching in websites. Thus it is used by people who are

living in rural areas also.

2.2.1. ADVANTAGES:

• Easy to access

• Provide information as fast

• Keep the user information confidentially

3

Page 4: SECURE LOCATION BASED QUERY OPTIMIZATION

3. SYSTEM REQUIREMENTS

3.1 SOFTWARE REQUIREMENTS

• Java1.6 or More

• J2ME

• Wireless toolkit 2.5.1

• Windows XP

• MS-SQL Server

3.2 HARDWARE REQUIREMENTS

• Hard disk : 40 GB

• RAM : 128mb

• Processor : Pentium

4

Page 5: SECURE LOCATION BASED QUERY OPTIMIZATION

3.3 TECHNOLOGIES USED

3.3.1. JAVA

It is a Platform Independent. Java is an object-oriented programming

language developed initially by James Gosling and colleagues at Sun

Microsystems. The language, initially called Oak (named after the oak

trees outside Gosling's office), was intended to replace C++, although

the feature set better resembles that of Objective C.

3.3.2. WORKING OF JAVA:

Java is two things:

▪ A programming language and

▪ A platform

3.3.3 The Java Programming Language

Java is a high-level programming language that is all of the

following:

• Simple

• Object oriented

• Distributed

• Interpreted

5

Page 6: SECURE LOCATION BASED QUERY OPTIMIZATION

• Robust

• Secure

• Architecture-neutral

• Portable

• High-performance

• Multithreaded

• Dynamic

Java is also unusual in that each Java program is both compiled

and interpreted. With a compiler, you translate a Java program into an

intermediate language called Java byte codes--the platform-

independent codes interpreted by the Java interpreter. With an

interpreter, each Java byte code instruction is parsed and run on the

computer. Compilation happens just once; interpretation occurs each

time the program is executed. This figure illustrates how this works.

(FIG 3.1) WORKING OF JAVA

6

Page 7: SECURE LOCATION BASED QUERY OPTIMIZATION

Java byte codes can be considered as the machine code

instructions for the Java Virtual Machine (Java VM). Every Java

interpreter, whether it's a Java development tool or a Web browser

that can run Java applets, is an implementation of the Java VM. The

Java VM can also be implemented in hardware.

Java byte codes help make "write once, run anywhere" possible.

The Java program can be compiled into byte codes on any platform

that has a Java compiler. The byte codes can then be run on any

implementation of the Java VM. For example, the same Java program

can run on Windows NT, Solaris, and Macintosh.

3.3.4. The Java Platform

A platform is the hardware or software environment in which a

program runs. The Java platform differs from most other platforms in

that it's a software-only platform that runs on top of other, hardware-

7

Page 8: SECURE LOCATION BASED QUERY OPTIMIZATION

based platforms. Most other platforms are described as a combination

of hardware and operating system.

The Java platform has two components:

• The Java Virtual Machine (Java VM)

• The Java Application Programming Interface (Java API)

The Java API is a large collection of ready-made software

components that provide many useful capabilities, such as graphical

user interface (GUI) widgets. The Java API is grouped into libraries

(packages) of related components.

The following figure depicts a Java program, such as an

application or applet, that's running on the Java platform. As the

figure shows, the Java API and Virtual Machine insulates the Java

program from hardware dependencies.

As a platform-independent environment, Java can be a bit slower than

native code. However, smart compilers, well-tuned interpreters, and

just-in-time byte code compilers can bring Java's performance close to

that of native code without threatening portability.

8

Page 9: SECURE LOCATION BASED QUERY OPTIMIZATION

ADDITIONAL FEATURES OF JAVA

Accessibility from any location in the world: Java is an internet

programming language The web provides accessibility to a computer

from anywhere in the world Virus free System:

1.)Java is secure

2.)That is any changes made to the computer are tagged as

errors and the program will not execute

Platform Independent Language:

1.)java compiler compiles java code to an intermediate byte

code that is understood by JVM(java virtual machine)

2.) To execute the byte codes the system should have java

interpreter or java enabled internet browser

Speed:

1.) Java is a High performance language.

2.) Faster than programs written in other interpreter languages,

such as BASIC.

3.) Faster than C, C++.

Development time:

1.) Java is simple.

2.) In java programmers do not need to manipulate memory.

GARBAGE COLLECTION

It’s the process that automatically frees the memory of

objects that are no more in use. There is no specification of a

technique for garbage collection

9

Page 10: SECURE LOCATION BASED QUERY OPTIMIZATION

How Will Java Technology Change My Life?

We can't promise you fame, fortune, or even a job if you learn

the Java programming language. Still, it is likely to make your

programs better and requires less effort than other languages. We

believe that Java technology will help you do the following:

Get started quickly: Although the Java programming language

is a powerful object-oriented language, it's easy to learn, especially for

programmers already familiar with C or C++.

Write less code: Comparisons of program metrics (class counts,

method counts, and so on) suggest that a program written in the Java

programming language can be four times smaller than the same

program written in C++.

Write better code: The Java programming language encourages

good coding practices, and automatic garbage collection helps you

avoid memory leaks. Its object orientation, its JavaBeansTM

component architecture, and its wide-ranging, easily extendible API

let you reuse existing, tested code and introduce fewer bugs.

Develop programs more quickly: The Java programming

language is simpler than C++, and as such, your development time

could be up to twice as fast when writing in it. Your programs will

also require fewer lines of code.

Avoid platform dependencies: You can keep your program

portable by avoiding the use of libraries written in other languages.

Write once, run anywhere: Because applications written in the

Java programming language are compiled into machine-independent

bytecodes, they run consistently on any Java platform.

10

Page 11: SECURE LOCATION BASED QUERY OPTIMIZATION

Distribute software more easily: With Java Web Start software,

users will be able to launch your applications with a single click of the

mouse. An automatic version check at startup ensures that users are

always up to date with the latest version of your software. If an update

is available, the Java Web Start software will automatically update

their installation.

What Can Java Do?

Probably the most well-known Java programs are Java applets.

An applet is a Java program that adheres to certain conventions that

allow it to run within a Java-enabled browser.

However, Java is not just for writing cute, entertaining applets

for the World Wide Web ("Web"). Java is a general-purpose, high-

level programming language and a powerful software platform. Using

the generous Java API, we can write many types of programs.

The most common types of programs are probably applets and

applications, where a Java application is a standalone program that

runs directly on the Java platform.

How does the Java API support all of these kinds of programs?

With packages of software components that provide a wide range of

functionality. The core API is the API included in every full

implementation of the Java platform. The core API gives you the

following features:

11

Page 12: SECURE LOCATION BASED QUERY OPTIMIZATION

The Essentials: Objects, strings, threads, numbers, input and output,

data structures, system properties, date and time, and so on.

Applets: The set of conventions used by Java applets.

Networking: URLs, TCP and UDP sockets, and IP addresses.

Internationalization: Help for writing programs that can be localized

for users worldwide. Programs can automatically adapt to specific

locales and be displayed in the appropriate language.

Security: Both low-level and high-level, including electronic

signatures, public/private key management, access control, and

certificates.

Software components: Known as JavaBeans, can plug into existing

component architectures such as Microsoft's OLE/COM/Active-X

architecture, OpenDoc, and Netscape's Live Connect.

Object serialization: Allows lightweight persistence and

communication via Remote Method Invocation (RMI).

Java Database Connectivity (JDBC): Provides uniform access to a

wide range of relational databases.

3.3.5. About the J2ME Language

What is J2ME?

Sun Microsystems defines J2ME as "a highly optimized Java run-time

environment targeting a wide range of consumer products, including

pagers, cellular phones, screen-phones, digital set-top boxes and car

navigation systems."

12

Page 13: SECURE LOCATION BASED QUERY OPTIMIZATION

Announced in June 1999 at the JavaOne Developer Conference, J2ME

brings the cross-platform functionality of the Java language to smaller

devices, allowing mobile wireless devices to share applications. With

J2ME, Sun has adapted the Java platform for consumer products that

incorporate or are based on small computing devices.

Devices J2ME targets:

Target devices for J2ME applications developed using CLDC

generally have the following characteristics:

* 160 to 512 kilobytes of total memory available for the Java platform

* Limited power, often battery powered

* Network connectivity, often with a wireless, inconsistent connection

and with limited bandwidth

* User interfaces with varying degrees of sophistication; sometimes

with no interface at all. Some devices supported by CLDC include

wireless phones, pagers, mainstream personal digital assistants

(PDAs), and small retail payment terminals.

According to Sun Microsystems, target devices for CDC generally

have the following characteristics:

* Powered by a 32-bit processor

* Two megabytes or more of total memory available for the Java

platform

* Devices that require the full functionality of the Java 2 "Blue Book"

virtual machine

* Network connectivity, often with a wireless, inconsistent connection

and with limited bandwidth

13

Page 14: SECURE LOCATION BASED QUERY OPTIMIZATION

* User interfaces with varying degrees of sophistication; sometimes

with no interface.

3.4. DATABASE

3.4.1. JDBC API 2.0

The JDBC API lets you invoke SQL commands from Java

programming language methods. You use the JDBC API in an

enterprise bean when you override the default container-managed

persistence or have a session bean access the database. With

container-managed persistence, database access operations are

handled by the container, and your enterprise bean implementation

contains no JDBC code or SQL commands. You can also use the

JDBC API from a servlet or JSP page to access the database directly

without going through an enterprise bean.

The JDBC API has two parts: an application-level interface

used by the application components to access a database, and a

service provider interface to attach a JDBC driver to the J2EE

platform.

3.4.2. JAVA DATABASE CONNECTIVITY (JDBC)

JDBC AND ODBC IN JAVA:

Most popular and widely accepted database

connectivity called Open Database Connectivity (ODBC) is

used to access the relational databases. It offers the ability to

14

Page 15: SECURE LOCATION BASED QUERY OPTIMIZATION

connect to almost all the databases on almost all platforms. Java

applications can also use this ODBC to communicate with a

database. Then we need JDBC why? There are several reasons:

▪ ODBC API was completely written in C language and

it makes an extensive use of pointers. Calls from Java to

native C code have a number of drawbacks in the security,

implementation, robustness and automatic portability of

applications.

▪ ODBC is hard to learn. It mixes simple and advanced

features together, and it has complex options even for simple

queries.

▪ ODBC drivers must be installed on client’s machine.

3.4.3. Architecture of JDBC:

Application Layer:

Java program wants to get a connection to a database. It needs the

information from the database to display on the screen or to modify

the existing data or to insert the data into the table.

Driver Manager:

The layer is the backbone of the JDBC

architecture. When it receives a connection-request form.

The JDBC Application Layer:

It tries to find the appropriate driver by iterating through all the

available drivers, which are currently registered with Device Manager.

15

Page 16: SECURE LOCATION BASED QUERY OPTIMIZATION

After finding out the right driver it connects the application to

appropriate database.

JDBC Driver layers: This layer accepts the SQL calls from

the application and converts them into native calls to the database and

vice-versa. A JDBC Driver is responsible for ensuring that an

application has consistent and uniform m access to any database.

When a request received by the application, the JDBC driver

passes the request to the ODBC driver, the ODBC driver

communicates with the database and sends the request and gets the

results. The results will be passed to the JDBC driver and in turn to

the application. So, the JDBC driver has no knowledge about the

actual database, it knows how to pass the application request o the

ODBC and get the results from the ODBC.

The JDBC and ODBC interact with each other, how? The

reason is both the JDBC API and ODBC are built on an interface

called “Call Level Interface” (CLI). Because of this reason the JDBC

driver translates the request to an ODBC call. The ODBC then

converts the request again and presents it to the database. The results

of the request are then fed back through the same channel in reverse.

3.4.4. Structured Query Language (SQL)

SQL (Pronounced Sequel) is the programming language

that defines and manipulates the database. SQL databases are

relational databases; this means simply the data is store in a set of

simple relations. A database can have one or more table. You can

define and manipulate data in a table with SQL commands. You use

the data definition language (DDL) commands to creating and altering

16

Page 17: SECURE LOCATION BASED QUERY OPTIMIZATION

databases and tables.

You can update, delete or retrieve data in a table with

data manipulation commands (DML). DML commands include

commands to alter and fetch data.

The most common SQL commands include commands is

the SELECT command, which allows you to retrieve data from the

database.

In addition to SQL commands, the oracle server has a

procedural language called PL/SQL. PL/SQL enables the programmer

to program SQL statement. It allows you to control the flow of a SQL

program, to use variables, and to write error-handling procedures.

17

Page 18: SECURE LOCATION BASED QUERY OPTIMIZATION

Response to the user

Location Based Services Server

Location cloaking Agent

Location based queries

4. SYSTEM DESIGN

4.1. SYSTEM ARCHITECTURE:

18

Page 19: SECURE LOCATION BASED QUERY OPTIMIZATION

FIG 4.1

4.2. DATAFLOW DIAGRAMS:

19

Page 20: SECURE LOCATION BASED QUERY OPTIMIZATION

FIG 4.2

User

Type Query

Send Query

Location cloaking agent receives the query and passes to LBS

process Query

Stop

Location cloaking agent Send Result

User Get Location Information

User LBS Mobile

Login and registration

Level 0- login and registration module

20

Page 21: SECURE LOCATION BASED QUERY OPTIMIZATION

FIG 4.2.1

FIG4.2.2

4.3. UML DIAGRAMS

4.3.1. USE CASE DIAGRAM:

User LBS Mobile

Location cloaking agent

Captures the query

Send query for any place

LBS Server

Search the particular query

Send response

Send the location

information

Get immediate and valid information

Level 1- Query and response

21

Page 22: SECURE LOCATION BASED QUERY OPTIMIZATION

4.3.2. SEQUENCE DIAGRAM:

User

Login

Query with GPS value

Only one Nearest output Send to user

Region with Query

Cloaking Server

N-Number Nearest output Send to Chocking server

Location Server

1.Query means SBI ATM Center2. Automatic GPS Value Send

22

Page 23: SECURE LOCATION BASED QUERY OPTIMIZATION

UserUser Cloaking ServerCloaking Server Location ServerLocation Server

1: Login

2: Query with Gps value

3: Region with Query value

4: N-Number of Nearest output

5: Only one output send to the user Mobile

23

Page 24: SECURE LOCATION BASED QUERY OPTIMIZATION

4.3.3. COLLABORATION DIAGRAM:

User

Cloaking Server

Location Server

1: Login2: Query with Gps value

5: Only one output send to the user Mobile

3: Region with Query value

4: N-Number of Nearest output

24

Page 25: SECURE LOCATION BASED QUERY OPTIMIZATION

4.3.4. ACTIVITY DIAGRAM:

5. SYSTEM IMPLEMENTATION

25

Login

Query With Gps value to cloaking server

Query with Region to Location Server

N-number of Nearest OutputQuery send to cloaking server

Only one Nearest Send to user Mobile

Page 26: SECURE LOCATION BASED QUERY OPTIMIZATION

5.1. MODULES

1. User Registration

2. User Authentication & Query Process

3. User Location Identification

4. Safe Region Manipulation

5. Query Request to the Data Location Server

6. Retrieve of results in according to safe region

7. Find the nearest location

5.2. MODULE DESCRIPTION

26

Page 27: SECURE LOCATION BASED QUERY OPTIMIZATION

1. USER REGISTRATION

In the Location base query system we have to register the user for his

future query search. Without registering a user can’t access the

clocking agent. For register the user should give his details such as his

name, address, age, sex, ext., once a user register his details he can get

useful information from the clocking server. Each user will identify

by a unique username and password. REF[1].

2. USER AUTHENTICATION & QUERY PROCESS

If a client want to arise a query first he should be authenticated by the

server for this he have to login by his user name and password after he

got sign-in he can arise query to the server. This query will go the

clocking agent and the clocking agent will send the query to the

location server. REF[2].

3. USER LOCATION IDENTIFICATION

The clocking agent will get user location and then it will find the user

is moving towards the location or moving outwards the location. The

current location is obtained using GPS from the mobile user. The

mobile user will carry with the GPS for getting the longitude &

latitude values. These values are obtained via satellite communication.

So once the user sends the query to the Cloaking Agent, the Cloaking

agent will get the exact location of the user via GPS values of the

user. REF[3]&[4].

27

Page 28: SECURE LOCATION BASED QUERY OPTIMIZATION

4. SAFE REGION MANIPULATION

When ever a clocking agent receives a query from the client it

will check the query and find the safe region for the client. Safe region

is calculated from the exact user location. We apply Max Cloak

Algorithm, to fetch the direction of the user. If the direction of the

user is towards forward then the cloaking agent will calculate the safe

region with respect to the main location. For example user sends a

request from Habibullah Road, user is moving towards T.Nagar, then

the Safe region T.Nagar, if the user is moving in the opposite direction

then the cloaking agent will specify the safe region as

Nungambakkam.. After find safe region the clocking agent will send

the request to the Location Server. The location server will send the

result for the safe region the clocking agent receives the result from

the Location server and then it find the nearest Location from the

result and send the location to the client.REF[5]

5. QUERY REQUEST TO THE DATA LOCATION SERVER

The Clocking agent Manipulate the Safe region for the client and the

send the query to the Location server. The location server checks the

Query and Retrieve the results according to the safe region and then

send the result to the clocking agent. If the user is requested for ATM

Bank from Habibullah Road, first the query is sent to the Cloaking

28

Page 29: SECURE LOCATION BASED QUERY OPTIMIZATION

Agent. Cloaking agent will manipulate the safe region as T.Nagar,

then the query is forwarded to the Data Location Server. REF[6]&[7].

6. RETRIEVE OF RESULTS IN ACCORDING TO SAFE

REGION

Clocking agent will send the query to the Location server. The

Location server manipulates the user query and it will send the results

to the clocking server. The main data server will retrieve the nearest

results that are fit into the safe region area calculation. If the query for

ATM Bank from the T,nagar as safe Region, then the Location server

will find the nearest ATM bank with respect to T.nagar. The location

based is retrieved and the results are given back to the Cloaking agent.

REF[8].

7. FIND THE NEAREST LOCATION

After getting the query result from the Location server, the clocking

server will filter the results in accordance to the user exact location.

The Location server will retrieve the ATM bank information in

accordance to T. Nagar to the cloaking agent. But the cloaking agent

knows user is in Habibullah Road. So the cloaking agent will apply

KNN Query Algorithm to fetch the nearest ATM bank in accordance

to Habibullah Road. So user will be receving the exact information, as

requested but then the user’s Location Privacy is still maintained,

because the Location server will update in its table as the query is

29

Page 30: SECURE LOCATION BASED QUERY OPTIMIZATION

from T.anagr not from Habibullah Road. By this way we ensure

Privacy in the user’s location. REF[9].

30

Page 31: SECURE LOCATION BASED QUERY OPTIMIZATION

6. TESTING

6.1. SYSTEM TESTING

The purpose of testing is to discover errors. Testing is the

process of trying to discover every conceivable fault or weakness in a

work product. It provides a way to check the functionality of

components, sub assemblies, assemblies and/or a finished product It is

the process of exercising software with the intent of ensuring that the

Software system meets its requirements and user expectations and

does not fail in an unacceptable manner. There are various types of

test. Each test type addresses a specific testing requirement.

6.2. TYPES OF TESTS

Unit testing:

Unit testing involves the design of test cases that validate that

the internal program logic is functioning properly, and that program

input produces valid outputs. All decision branches and internal code

flow should be validated. It is the testing of individual software units

of the application .it is done after the completion of an individual unit

before integration. This is a structural testing, that relies on knowledge

of its construction and is invasive. Unit tests perform basic tests at

component level and test a specific business process, application,

31

Page 32: SECURE LOCATION BASED QUERY OPTIMIZATION

and/or system configuration. Unit tests ensure that each unique path of

a business process performs accurately to the documented

specifications and contains clearly defined inputs and expected

results.

Integration testing:

Integration tests are designed to test integrated software

components to determine if they actually run as one program. Testing

is event driven and is more concerned with the basic outcome of

screens or fields. Integration tests demonstrate that although the

components were individually satisfaction, as shown by successfully

unit testing, the combination of components is correct and consistent.

Integration testing is specifically aimed at exposing the problems

that arise from the combination of components.

Functional test:

Functional tests provide a systematic demonstration that

functions tested are available as specified by the business and

technical requirements, system documentation, and user manuals.

Functional testing is centered on the following items:

Valid Input : identified classes of valid input must be

accepted.

Invalid Input : identified classes of invalid input must be

rejected.

Functions : identified functions must be exercised.

32

Page 33: SECURE LOCATION BASED QUERY OPTIMIZATION

Output : identified classes of application outputs must

be exercised.

Systems/Procedures: interfacing systems or procedures must be

invoked.

Organization and preparation of functional tests is focused on

requirements, key functions, or special test cases. In addition,

systematic coverage pertaining to identify

Business process flows; data fields, predefined processes, and

successive processes must be considered for testing. Before functional

testing is complete, additional tests are identified and the effective

value of current tests is determined.

System Test:

System testing ensures that the entire integrated software

system meets requirements. It tests a configuration to ensure known

and predictable results. An example of system testing is the

configuration oriented system integration test. System testing is based

on process descriptions and flows, emphasizing pre-driven process

links and integration points.

White Box Testing:

White Box Testing is a testing in which in which the software

tester has knowledge of the inner workings, structure and language of

the software, or at least its purpose. It is purpose. It is used to test

areas that cannot be reached from a black box level.

33

Page 34: SECURE LOCATION BASED QUERY OPTIMIZATION

Black Box Testing:

Black Box Testing is testing the software without any

knowledge of the inner workings, structure or language of the module

being tested. Black box tests, as most other kinds of tests, must be

written from a definitive source document, such as specification or

requirements document, such as specification or requirements

document. It is a testing in which the software under test is treated, as

a black box .you cannot “see” into it. The test provides inputs and

responds to outputs without considering how the software works.

Unit Testing:

Unit testing is usually conducted as part of a combined code

and unit test phase of the software lifecycle, although it is not

uncommon for coding and unit testing to be conducted as two distinct

phases.

Test strategy and approach

Field testing will be performed manually and functional tests

will be written in detail.

34

Page 35: SECURE LOCATION BASED QUERY OPTIMIZATION

Integration Testing

Software integration testing is the incremental integration

testing of two or more integrated software components on a single

platform to produce failures caused by interface defects.

The task of the integration test is to check that components or

software applications, e.g. components in a software system or – one

step up – software applications at the company level – interact without

error.

Test Results:

All the test cases mentioned above passed successfully. No defects

encountered.

35

Page 36: SECURE LOCATION BASED QUERY OPTIMIZATION

7. CONCLUSION

The representation of cloaking regions and circular region leads to a

small result superset. Experimental result shows that the mobility

aware cloaking algorithms are robust against trace analysis attack

without compromising much on query latency or communication

cost.The progressive query processing algorithm generally achieves

shorter response time than the bulk algorithm.

36

Page 37: SECURE LOCATION BASED QUERY OPTIMIZATION

8. APPENDIX

8.1 Source Code

Login:

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

import javax.microedition.io.*;

import java.io.*;

public class Login extends Form implements CommandListener

{

TextField txtUser,txtPwd,txtIPAddress;

Display disp;

Command cmdSubmit,cmdBack;

Form welScreen;

String userpassword;

public Login(String strTitle,Display disp1,Form welScreen)

{

super(strTitle);

this.disp = disp1;

37

Page 38: SECURE LOCATION BASED QUERY OPTIMIZATION

this.welScreen = welScreen;

cmdSubmit = new Command("Submit",Command.OK,1);

cmdBack = new Command("Back",Command.BACK,1);

txtUser = new TextField("UserName","",40,TextField.ANY);

txtPwd = new TextField("PassWord","",40,TextField.PASSWORD);

txtIPAddress = new TextField("IPAddress","",40,TextField.ANY);

this.append(txtUser);

this.append(txtPwd);

this.append(txtIPAddress);

this.setTicker(new Ticker("Login Form"));

this.addCommand(cmdSubmit);

this.addCommand(cmdBack);

this.setCommandListener(this);

}

public void commandAction(Command com,Displayable d1){

if(com==cmdSubmit){

userpassword = "LI$"+txtUser.getString().trim()+"$"+txtPwd.getString();

ServerIPAddress.setServerIPAddress(txtIPAddress.getString());

socketexam clsoc=new socketexam(userpassword,disp);

}

else if(com==cmdBack)

38

Page 39: SECURE LOCATION BASED QUERY OPTIMIZATION

disp.setCurrent(welScreen); }}

DIRECTION:

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

import javax.microedition.io.*;

import java.io.*;

import java.lang.*;

public class Destination extends Form implements CommandListener

{

Display disp;

TextField userInput = null;

Command cmdSubmit,cmdBack;

static Form welScreen;

socketexam clsoc;

String finalString = null;

String direction = null;

// This is constructor used to Design Form like Forward and Backward

public Destination(String strTitle,Display disp,String direction){

super(strTitle);

this.disp=disp;

this.direction = direction;

userInput = new TextField("Enter Your GPS Value","",40,TextField.ANY);

39

Page 40: SECURE LOCATION BASED QUERY OPTIMIZATION

cmdSubmit = new Command("SUBMIT",Command.OK,1);

cmdBack = new Command("BACK",Command.BACK,1);

this.setTicker(new Ticker("GPS FORM"));

this.append(userInput);

this.addCommand(cmdSubmit);

this.addCommand(cmdBack);

this.setCommandListener(this);

}

// This method is used to generate the event ie, If You click the Forward button Client will move

the forward direction

public void commandAction(Command com,Displayable d1){

if(com==cmdSubmit){

System.out.println("Submit");

finalString = "direction,"+userInput.getString()+","+direction;

socketexam clsoc=new socketexam(finalString,disp);

}

if(com==cmdBack){

System.out.println("Back");

}

}

}

40

Page 41: SECURE LOCATION BASED QUERY OPTIMIZATION

CHOKING SERVER:

import java.lang.*;

import java.util.*;

import java.sql.*;

import java.io.*;

import java.net.*;

public class ChokingServer extends Thread

{

Thread t;

PrintWriter clientOutput;

private Connection connection = null;

private Statement statement = null;

private ResultSet resultSet = null;

StringTokenizer st = null;

float intLan,intLat;

String uname,pass=null,direction,category;

private ServerSocket serverSocket = null;

private Socket clientSocket = null;

ObjectOutputStream ous =null;

ObjectInputStream ois = null;

41

Page 42: SECURE LOCATION BASED QUERY OPTIMIZATION

ArrayList locationList = null;

ArrayList locationArrayList = null;

private double a[]=new double[50];

static Socket ss = null;

static ServerSocket sock = null;

private float lat,lan;

private String status = "";

String rname=null,rpass=null,raddress=null,rno=null,rmail=null;

public ChokingServer(){

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

connection=DriverManager.getConnection("jdbc:odbc:Driver={SQL Server};

Server=.;Database=location;UId=sa");

statement = connection.createStatement();

}

catch(Exception ex)

{

ex.printStackTrace();

System.out.println(ex);

}

}

public void database()

42

Page 43: SECURE LOCATION BASED QUERY OPTIMIZATION

{

try

{

statement.executeUpdate("insertinto userlogin(name,password,address,phoneno,mailid)

values('"+rname+"','"+rpass+"','"+raddress+"','"+rno+"','"+rmail+"')"

);

}

catch (SQLException ex10)

{

System.out.println(ex10);

ex10.printStackTrace();

}

}

public void run()

{

try{

clientOutput=new PrintWriter(ss.getOutputStream());

String str=HttpTunnel.undoHttpTunneling(ss.getInputStream());

str = str.substring(1);

System.out.println("royal test"+str);

if(str.startsWith("LI"))

{

43

Page 44: SECURE LOCATION BASED QUERY OPTIMIZATION

st = new StringTokenizer(str,"$");

st.nextToken();

uname = st.nextToken();

pass = st.nextToken();

resultSet=statement.executeQuery("select * from userlogin where name='"+uname+"' and

password='"+pass+"’ ”);

if(resultSet.next()){

status = "Logged In";

}

else{

status = "InValid";

}

HttpTunnel.doHttpTunneling(clientOutput,status);

}else if(str.startsWith("Add")){

System.out.println("ssfdfds"+str);

st = new StringTokenizer(str,"$");

st.nextToken();

rname=st.nextToken();

rpass=st.nextToken();

raddress=st.nextToken();

rno=st.nextToken();

44

Page 45: SECURE LOCATION BASED QUERY OPTIMIZATION

rmail=st.nextToken(); System.out.println(rname+"\

n"+rpass+"\n"+raddress+"\n"+rno+"\n"+rmail);

database(); HttpTunnel.doHttpTunneling(clientOutput,"register");

}else if(str.startsWith("direction"))

{

st = new StringTokenizer(str,",");

st.nextToken();

lat =Float.parseFloat(st.nextToken());

lan = Float.parseFloat(st.nextToken());

category = st.nextToken();

direction = st.nextToken();

System.out.println("Direction "+direction);

if(direction .intern() == "Forward"){

intLan = lan+0.20f;

intLat = lat+0.20f;

}else if(direction .intern() == "Backward"){

intLan = lan-0.20f;

intLat = lat-0.20f;

}

String msg = "direction,"+intLat+","+intLan;

System.out.println("Message"+msg);

connectToCentralServer(msg,lat,lan,category);

45

Page 46: SECURE LOCATION BASED QUERY OPTIMIZATION

System.out.println("connect To server");

}

}

catch (Exception e){

e.printStackTrace();

System.out.println(e);

}

}

public void connectToCentralServer(String str,float strLat,float strLan,String category){

try{

clientSocket = new Socket("localhost",7005);

System.out.println("socket is created");

ous = new ObjectOutputStream(clientSocket.getOutputStream());

System.out.println("Data Sent to central server"+str);

ous.writeObject(str+","+category);

System.out.println("Data Sent to central server");

ois = new ObjectInputStream(clientSocket.getInputStream());

locationList = (ArrayList) ois.readObject();

System.out.println("Location List"+locationList);

float d2 = strLat;

float d1 = strLan;

Float f2 = new Float(d2);

46

Page 47: SECURE LOCATION BASED QUERY OPTIMIZATION

double df2 = f2.doubleValue();

System.out.println("float value:"+f2);

System.out.println("double value:"+df2);

Float f1 = new Float(d1);

double df1 = f1.doubleValue();

System.out.println("float value:"+f1);

System.out.println("double value:"+df1);

computedistance(df2,df1);

computeshortest(df2,df1);

}

catch(Exception ex){

ex.printStackTrace();

System.out.println(ex);

System.out.println(" Exception is Caughed !!!");

}

}

public void computedistance(double x1,double y1)

{

locationArrayList = new ArrayList();

int i=1;

double x=0,x2=0,y2=0;

Iterator it=locationList.iterator();

47

Page 48: SECURE LOCATION BASED QUERY OPTIMIZATION

while(it.hasNext()){

//System.out.println(it.next());

String str=it.next().toString();

System.out.println("String"+str);

StringTokenizer st=new StringTokenizer(str,"&");

st.nextToken();

st.nextToken();

String location=st.nextToken();

String strLat=st.nextToken();

String strLan=st.nextToken();

x2=Double.parseDouble(strLat);

y2=Double.parseDouble(strLan);

a[i]=Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));

System.out.println(a[i]);

locationArrayList.add(location+"&"+a[i]);

System.out.println("Location ArrayList"+locationArrayList);

i++;

}

}

public void computeshortest(double x1,double y1)

{

48

Page 49: SECURE LOCATION BASED QUERY OPTIMIZATION

try{

String message=null;

int i=1;

for( i=1;i<=locationArrayList.size();i++)

{

for(int j=1+i;j<=locationArrayList.size();j++)

{

if(a[i]>a[j])

{

double temp=a[i];

a[i]=a[j];

a[j]=temp;

}

}

}

for( i=1;i<=locationArrayList.size();i++){

System.out.println("Shortest Route"+a[i]);

Iterator it=locationArrayList.iterator();

while(it.hasNext()){

String str=it.next().toString();

System.out.println(str);

StringTokenizer st=new StringTokenizer(str,"&");

49

Page 50: SECURE LOCATION BASED QUERY OPTIMIZATION

String location=st.nextToken();

String val=st.nextToken();

double value=Double.parseDouble(val);

System.out.println("***"+val+"A[1] Value"+a[1]);

if(value==a[1]){

System.out.println("Location Is"+location);

HttpTunnel.doHttpTunneling(clientOutput,location);

break;

}

}

}

}

catch(Exception ex)

{

ex.printStackTrace();

System.out.println(ex);

}

}

public static void main(String a[]){

try{

sock=new ServerSocket(7000);

while(true){

50

Page 51: SECURE LOCATION BASED QUERY OPTIMIZATION

ss=sock.accept();

ChokingServer cs = new ChokingServer();

cs.start();

}

}

catch(Exception ex){

System.out.println(ex);

}

}

}

51

Page 52: SECURE LOCATION BASED QUERY OPTIMIZATION

8.2 SCREEN SHOTS

SIGN IN:

FIG 8.2.1

52

Page 53: SECURE LOCATION BASED QUERY OPTIMIZATION

REGISTRATION FORM:

FIG 8.2.2

53

Page 54: SECURE LOCATION BASED QUERY OPTIMIZATION

DIRECTION FORM:

FIG 8.2.3

54

Page 55: SECURE LOCATION BASED QUERY OPTIMIZATION

LOCATION INFORMATION:

55

Page 56: SECURE LOCATION BASED QUERY OPTIMIZATION

FIG 8.2.4

9. References

[1] B. Bamba,L. Liu, P. Pesti, and T. Wang, “Supporting Anonymous Location Queries

in Mobile Environments with Privacygrid,” Proc. Int’l World Wide Web Conf. (WWW),

2008.

[2] C. Bettini, S.Mascetti, X.S. Wang, and S.Jajodia, “Anonymity in Location-Based

Services: Towards a General Framework,” Proc. Eighth Int’l Conf. Mobile Data

Management (MDM), May 2007.

[3] S.Berchtold, C Bo¨hm, D.A. Keim, F. Krebs, and H.-P. Kriegel,“On Optimizing

Nearest Neighbor Queries in High-Dimensional Data Spaces,” Proc. Int’l Conf. Database

Theory (ICDT), 2001.

[4] A.R. Beresford and F. Stajano,“Location Privacy in Pervasive Computing,” IEEE

Pervasive Computing, vol. 2, no. 1, pp. 46-55, Jan.-Mar. 2003.

[5] R. Cheng, Y. Zhang, E. Bertino, and S. Prabhakar,“Preserving User Location Privacy

in Mobile Data Management Infrastructures,” Proc. Privacy Enhancing Technology

Workshop, June 2006.

[6] C.-Y. Chow, M.F. Mokbel,and X. Liu, “A Peer-to-Peer Spatial Cloaking Algorithm

for Anonymous Location-Based Services,” Proc. ACM Int’l Symp.Advances in

Geographic Information Systems (GIS), 2006.

[7] J. Du, J. Xu, X. Tang, and H. Hu, “iPDA: Supporting Privacy- Preserving Location-

Based Mobile Services (Demonstration),” Proc. Eighth Int’l Conf. Mobile Data

Management (MDM), May 2007.

[8] G. Myles, A. Friday, and N. Davies, “Preserving Privacy in Environments with

Location-Based Applications,” IEEE Pervasive Computing, vol. 2, no. 1, pp. 56-64, Jan.-

Mar. 2003.

56

Page 57: SECURE LOCATION BASED QUERY OPTIMIZATION

[9] G. Ghinita, P. Kalnis, and S. Skiadopoulos, “Prive: Anonymous Location-Based

Queries in Distributed Mobile Systems,” Proc. Int’l World Wide Web Conf. (WWW

’07), pp. 371-380, 2007.

57