I'm sorry, but you are appearing to be very naive about border security. You would have to demonstrate why you think this is "illegal".
Start here -> http://www.priv.gc.ca/resource/fs-fi/02_05_d_45_e.asp and assume that similar systems apply in most countries in the world.
You should also read http://www.cbsa-asfc.gc.ca/security-securite/api_ipv-eng.html especially the section which states
Start here -> http://www.priv.gc.ca/resource/fs-fi/02_05_d_45_e.asp and assume that similar systems apply in most countries in the world.
You should also read http://www.cbsa-asfc.gc.ca/security-securite/api_ipv-eng.html especially the section which states
Under Canadian law, all commercial carriers are required to provide the CBSA with API/PNR data relating to all persons travelling to Canada. Airlines collect API data when passengers check in; PNR is drawn from airline flight reservations systems.
Advance Passenger Information (API)
Basic data identifying a person including the traveller's name, date of birth, gender, citizenship or nationality and travel document data. This type of information can be obtained from the machine-readable area of a person's passport.
Passenger Name Record (PNR)
Data that relates to a traveller's reservation and travel itinerary including type of ticket, date of travel, number of bags, etc. This type of information can be obtained from a commercial carrier's departure control and reservation systems.