Generalized AuthUtils code for Spring 3 and Spring 4