Prevent use of "-Duser.name=root"
We are developing a program that requires the user to be authorized to use it.
Can I use the system property user.name to check the username to authorize the user?
It seems to me that any user then may just make a copy of the startscript and use "-Duser.name=root" in that script to get root privileges in my application.
Is there a way to prevent setting (on the command line) of certain system properties (or maybe a way to read the "default value" - the value before re-set on the cmd)?
Or, is there another way to get the username?
[580 byte] By [
wallroth] at [2007-9-26 8:28:55]

Well, I assume they also need to provide a password (or some type of credentials) along with the user name. So even if they change it to 'root', they should be prevented from logging on because (presumably) they don't know the root password. If you aren't requiring a password, then yes this would be a pretty big risk.
-Derek
If you need user to login, use JAAS. The java will
not run as 'root' simply because you use '-Duser.name=root'. Java authorization and OS's
authorization are two different authorization. User
need BOTH java permission and OS permission to
access a resource, say a file.
I do not know any way in Java that allow JVM to do OS impersonation.