To do so follow this following steps:
1- Open Glassfish admin console then go to:
2- Enter "USERS" in Assign Groups
3- Press in "Manage Users" button
4- Press New to create new user and set Group List to "USERS"
5- In your web application add this in web.xml
6- In your web application create file "sun-web.xml" in the same place of web.xml and write this:
7- Now deploy the web application (Java, ADF ,Web Service,...) to the Glassfish and when you try to call the application you have to enter username / password