anand mishra anand mishra - 16 days ago 9
reST (reStructuredText) Question

How to add session management in rest services?

I have an application that back-end build using JAX-RS and Hibernate and front end in HTML,CSS,AJAX and JavaScript.I am using the embedded jetty server with my application. I have implemented the authentication via local database using the email and password.

But I want to implement google session/case in my application so if user does not have a session either from email/password or from OpenID user can not use any page and stuck on login.

I have no idea how to create and maintain session in jersey web service. Can anyone please guide me ?

Answer

It using following approach to solve my problem:

1- Creating the partial profile of users in my local database those are coming via open id and validating only their email id in database and creating a session key using the JAVA UUID generator and storing it in Guava Cache and checking it with every request comes from user.

2- Validate the local user by matching the password and email id in local database and creating a session key using the JAVA UUID generator and storing it in Guava Cache and checking it with every request comes from user.