Improve authorization mechanism in Java code