Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: how to detect the real, unfakeable user language and user country?

Tags:

java

locale

For our Java application, we are considering to toughen our licensing conditions and related code for certain countries for which we are experiencing massive license infringement. Therefore we want to find out the real user language and user country. I'm aware, that you can query system properties user.language and user.country, but these can easily be faked when starting the Java application using e.g. -Duser.language=en. Is there a way to detect the original, unaltered values for these properties? Or is there another API which gives us the real settings?

Note:

  • the solution should require only a small computational effort and no Internet connection

  • we are not looking for a perfectly safe solution, but it also shouldn't be too easy to fake (like with system properties).

like image 588
mstrap Avatar asked Mar 07 '23 20:03

mstrap


1 Answers

Do not even try. You are trying to solve at a technical level a legal question. I once used a Linux machine where different users had different declared languages and time zones, and still have a VM using "C" language et UTC time zone.

As per my experience, such controls can annoy well intentioned users that happen to use a non standard configuration, but cannot prevent someone to deliberately give a wrong information.

So my advice is:

  • use the system property to get the declared country
  • ask the user to confirm or change it
  • trust what user declared

It could save you number of hotline calls.

like image 98
Serge Ballesta Avatar answered Apr 04 '23 10:04

Serge Ballesta