Simple authentication with java bean

J2EE offer different ways to check user authentication and authorization (JAAS, Apache SHIRO, Servlet Filters), often for demo software (or small ones) what you really need is a simple Session Bean as EventListener.

This ipotetic Session Bean manages user redirections between JSF views; consider this example with two views:
business.xhtml
loginform.xhtml

If a Guest user goes to http://localhost:8080/demo/business.xhtml he is gets redirected to loginform.xhtml, the Listener method save the originating URI (business.xhtml) and, if the auhentication is successful, brings the user back to the business view.

Setting the Event in view permit us to deny the access calling SessionBean.verifyUserLogin():

<f:event type="preRenderView" listener="#{SessionBean.verifyUserLogin()}"></f:event>

Continue reading “Simple authentication with java bean” »

Share

mod-vhost-ldap-ng updated for apache httpd 2.4

Today I release the version 1.2.0 of mod-vhost-ldap-ng for the new Stable release of  Apache HTTPd.

+ Per-request document-root: solves some problem in memory management of apache structures and give more stability
+ Fixed some compiler warning
+ Better configure script, now you can point a custom apxs binary outside $PATH

DOWNLOAD: https://github.com/Ardeek/mod-vhost-ldap-ng/archive/1.2.0.tar.gz

Share

Java code example: simple singleton lock using with Atomic variables

I needed a very simple lock system for a software demo for operation on HashMap, instead of using ReentrantLock from java.util.concurrent.locks i chose to use Atomic classes from java.util.concurrent.atomic.* .

My demo has a very LONG blocking thread that writes on a shared HashMap, the following class permits me to tune the sleep time for the lock without using a syncronized queue.
Continue reading “Java code example: simple singleton lock using with Atomic variables” »

Share