public String getUserId() { // if the authenticated user was explicitely set if (userId != null) { // return that one return userId; } // if an Authentication was specified Authentication authentication = get(Authentication.class); if (authentication != null) { // let the authentication do the work return authentication.getUserId(); } return null; }