29 July 2005

Bug on Acegi's "debug.jsp" Contact example

I notice from the debug.jsp code of Acegi's Contacts sample application that this code snippet:



<%@ page import="net.sf.acegisecurity.context.SecurityContextHolder" %>
<%@ page import="net.sf.acegisecurity.Authentication" %>
<%@ page import="net.sf.acegisecurity.GrantedAuthority" %>
<%@ page import="net.sf.acegisecurity.adapters.AuthByAdapter" %>

<%
Authentication auth = SecurityContextHolder.getAuthentication();
if (auth != null) { %>
Authentication object is of type: <%= auth.getClass().getName() %>


Authentication object as a String: <%= auth.toString() %>




Is wrong, there is no such thing as getAuthentication() within the SecurityContextHolder, it has to be fixed with something like this:


<%@ page import="net.sf.acegisecurity.context.SecurityContextHolder" %>
<%@ page import="net.sf.acegisecurity.context.SecurityContext" %>
<%@ page import="net.sf.acegisecurity.Authentication" %>
<%@ page import="net.sf.acegisecurity.GrantedAuthority" %>
<%@ page import="net.sf.acegisecurity.adapters.AuthByAdapter" %>

<%
SecurityContext securityContext =
SecurityContextHolder.getContext();
Authentication auth =
securityContext.getAuthentication();
if (auth != null) { %>
Authentication object is of type: <%= auth.getClass().getName() %>



Authentication object as a String: <%= auth.toString() %>





No wonder the Contacts sample with every instructions followed can't work. And this file has been sleeping in the CVS for months. Calling Ben Alex, yoohoo!

No comments: