users@glassfish.java.net

Validating credentials against the file realm

From: Steven Van Impe <steven.vanimpe_at_icloud.com>
Date: Mon, 27 May 2013 19:56:55 +0200

Hi all,

I'm trying to figure out how to do HTTP Basic Authentication with JAX-RS and GlassFish. So far, I seem to have everything set up, but I did run into the following problem:

When a user enters invalid credentials, and I use these credentials to make an AJAX request, I do not get back a 401 or 403 status code. Instead the browser displays a popup asking for new credentials. Therefore, I want to add a service to my back-end that can validate credentials. But how can a resource check if a given username/password combination is valid in the file realm (which is what I'm using for some of my simpler projects) ?

Using HttpServletRequest.login() works, but that seems to create sessions and JESSIONID cookies, which is not what I want.

Thanks,

---
Steven Van Impe
Lecturer @ University College Ghent
http://asipofjava.blogspot.com/