Java permission control algorithm