Tuesday, February 19, 2013

JAAS between two EE applications with TomEE, WS-RS and Javascript

PhotoDB no longer contains user data. Now its users credentials are remotely managed by FaceID. PhotoDB binds itself to it via via ws-rs from loginscript.js, and the JAAS does the rest.

While JAX-RS 2.0 and its very handy Client API are not yet official, our JAAS needs to use a regular java.net.URL connection. This way we avoid to get tied to any proprietary library. The loginscript.js opens an http connection to the remote application and authenticates the provided user credentials against what FaceID have stored. The resulting output is either a csv string with a list of all the groups in which the user is part, or a "Bad user or password" exception.

The applications now share the same TomEE installation, but you don't need to worry about it. We have a new Makefile task: make up-war-restart. So, let's build it!

Clone the projects and open two terminal windows.

First run make clean-start && make tail for the PhotoDB in order to build the application and tail the catalina.out file.

You should be able to use the PhotoDB application with the user "michael" and password "test".
Now run make up-war-restart for the FaceID.