SecurityContextHolder.getContext().getAuthentication() returning null

2010-03-17 Thread Lance Hill
I am trying to get access to the currently logged in user, but when I call
SecurityContextHolder.getContext().getAuthentication(), the Authentication
returned is null. I am assuming the user is logged in since they have access
to the secure page I am testing, but I don't know how to tell for sure since
I cannot access the Authentication object.

 

Any hints about why SecurityContextHolder.getContext().getAuthentication()
would return a null?



Re: SecurityContextHolder.getContext().getAuthentication() returning null

2010-03-17 Thread Lukasz Lenart
2010/3/17 Lance Hill la...@baldhead.com:
 Any hints about why SecurityContextHolder.getContext().getAuthentication()
 would return a null?

Spring version? Configuration? Did you try the simplest possible setup?


Regards
-- 
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: SecurityContextHolder.getContext().getAuthentication() returning null

2010-03-17 Thread Lance Hill
I'm using Spring 3/Spring Security 3.

I tried using security:authentication property=principal.username/ on the 
protected page and the username actually appears when I go directly to 
http://localhost/jsp/hello.jsp. 

If I go to http://localhost/hello.action, the security:authentication 
property=principal.username/ tag renders nothing and 
SecurityContextHolder.getContext().getAuthentication() returns a null value.

Here is my struts.xml

struts
package name=myPackage extends=struts-default 
action name=hello class=helloAction 
result/jsp/hello.jsp/result
/action
/package
/struts

And my web.xml


!-- Filters --

filter
filter-namespringSecurityFilterChain/filter-name

filter-classorg.springframework.web.filter.DelegatingFilterProxy/filter-class
/filter

filter
filter-nameaction2-cleanup/filter-name

filter-classorg.apache.struts2.dispatcher.ActionContextCleanUp/filter-class
/filter

filter
filter-namesitemesh/filter-name

filter-classcom.opensymphony.module.sitemesh.filter.PageFilter/filter-class
/filter

filter
filter-nameaction2/filter-name

filter-classorg.apache.struts2.dispatcher.FilterDispatcher/filter-class
/filter

filter
   filter-nameCAS Single Sign Out Filter/filter-name
   
filter-classorg.jasig.cas.client.session.SingleSignOutFilter/filter-class
/filter

 !-- --

filter-mapping
filter-nameaction2-cleanup/filter-name
url-pattern/*/url-pattern
/filter-mapping
filter-mapping
filter-namesitemesh/filter-name
url-pattern/*/url-pattern
/filter-mapping
filter-mapping
filter-nameaction2/filter-name
url-pattern/*/url-pattern
/filter-mapping

filter-mapping
   filter-nameCAS Single Sign Out Filter/filter-name
   url-pattern/*/url-pattern
/filter-mapping

filter-mapping
  filter-namespringSecurityFilterChain/filter-name
  url-pattern/*/url-pattern
/filter-mapping

!--  --
!-- Listeners --
listener

listener-classorg.jasig.cas.client.session.SingleSignOutHttpSessionListener/listener-class
/listener
listener

listener-classorg.springframework.web.context.ContextLoaderListener/listener-class
/listener
listener

listener-classorg.apache.tiles.web.startup.TilesListener/listener-class
/listener

!-- Servlets --
servlet
servlet-namedwr/servlet-name
servlet-classuk.ltd.getahead.dwr.DWRServlet/servlet-class
init-param
param-namedebug/param-name
param-valuetrue/param-value
/init-param
/servlet
servlet
servlet-namejspSupportServlet/servlet-name

servlet-classorg.apache.struts2.views.JspSupportServlet/servlet-class
load-on-startup5/load-on-startup
/servlet
servlet
servlet-nametiles/servlet-name
servlet-classorg.apache.tiles.web.startup.TilesServlet/servlet-class
init-param

param-nameorg.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG/param-name
param-value/WEB-INF/tiles-defs.xml/param-value
/init-param
load-on-startup2/load-on-startup
/servlet

servlet-mapping
servlet-namedwr/servlet-name
url-pattern/dwr/*/url-pattern
/servlet-mapping


!-- Welcome file lists --
welcome-file-list
welcome-fileindex.jsp/welcome-file
welcome-filedefault.jsp/welcome-file
welcome-fileindex.html/welcome-file
/welcome-file-list

error-page
error-code403/error-code
location/403.jsp/location
/error-page



-Original Message-
From: Lukasz Lenart [mailto:lukasz.len...@googlemail.com] 
Sent: Wednesday, March 17, 2010 11:52 AM
To: Struts Users Mailing List
Subject: Re: SecurityContextHolder.getContext().getAuthentication() returning 
null

2010/3/17 Lance Hill la...@baldhead.com:
 Any hints about why SecurityContextHolder.getContext().getAuthentication()
 would return a null?

Spring version? Configuration? Did you try the simplest possible setup?


Regards
-- 
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: SecurityContextHolder.getContext().getAuthentication() returning null

2010-03-17 Thread Hoying, Ken
Check your filter order.  I cannot recall if it is the filters are chained by 
the filter declaration order of the filter mapping order.

-Original Message-
From: Lance Hill [mailto:la...@baldhead.com] 
Sent: Wednesday, March 17, 2010 12:08 PM
To: 'Struts Users Mailing List'; lukasz.len...@gmail.com
Subject: RE: SecurityContextHolder.getContext().getAuthentication() returning 
null

I'm using Spring 3/Spring Security 3.

I tried using security:authentication property=principal.username/ on the 
protected page and the username actually appears when I go directly to 
http://localhost/jsp/hello.jsp. 

If I go to http://localhost/hello.action, the security:authentication 
property=principal.username/ tag renders nothing and 
SecurityContextHolder.getContext().getAuthentication() returns a null value.

Here is my struts.xml

struts
package name=myPackage extends=struts-default 
action name=hello class=helloAction 
result/jsp/hello.jsp/result
/action
/package
/struts

And my web.xml


!-- Filters --

filter
filter-namespringSecurityFilterChain/filter-name

filter-classorg.springframework.web.filter.DelegatingFilterProxy/filter-class
/filter

filter
filter-nameaction2-cleanup/filter-name

filter-classorg.apache.struts2.dispatcher.ActionContextCleanUp/filter-class
/filter

filter
filter-namesitemesh/filter-name

filter-classcom.opensymphony.module.sitemesh.filter.PageFilter/filter-class
/filter

filter
filter-nameaction2/filter-name

filter-classorg.apache.struts2.dispatcher.FilterDispatcher/filter-class
/filter

filter
   filter-nameCAS Single Sign Out Filter/filter-name
   
filter-classorg.jasig.cas.client.session.SingleSignOutFilter/filter-class
/filter

 !-- --

filter-mapping
filter-nameaction2-cleanup/filter-name
url-pattern/*/url-pattern
/filter-mapping
filter-mapping
filter-namesitemesh/filter-name
url-pattern/*/url-pattern
/filter-mapping
filter-mapping
filter-nameaction2/filter-name
url-pattern/*/url-pattern
/filter-mapping

filter-mapping
   filter-nameCAS Single Sign Out Filter/filter-name
   url-pattern/*/url-pattern
/filter-mapping

filter-mapping
  filter-namespringSecurityFilterChain/filter-name
  url-pattern/*/url-pattern
/filter-mapping

!--  --
!-- Listeners --
listener

listener-classorg.jasig.cas.client.session.SingleSignOutHttpSessionListener/listener-class
/listener
listener

listener-classorg.springframework.web.context.ContextLoaderListener/listener-class
/listener
listener

listener-classorg.apache.tiles.web.startup.TilesListener/listener-class
/listener

!-- Servlets --
servlet
servlet-namedwr/servlet-name
servlet-classuk.ltd.getahead.dwr.DWRServlet/servlet-class
init-param
param-namedebug/param-name
param-valuetrue/param-value
/init-param
/servlet
servlet
servlet-namejspSupportServlet/servlet-name

servlet-classorg.apache.struts2.views.JspSupportServlet/servlet-class
load-on-startup5/load-on-startup
/servlet
servlet
servlet-nametiles/servlet-name
servlet-classorg.apache.tiles.web.startup.TilesServlet/servlet-class
init-param

param-nameorg.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG/param-name
param-value/WEB-INF/tiles-defs.xml/param-value
/init-param
load-on-startup2/load-on-startup
/servlet

servlet-mapping
servlet-namedwr/servlet-name
url-pattern/dwr/*/url-pattern
/servlet-mapping


!-- Welcome file lists --
welcome-file-list
welcome-fileindex.jsp/welcome-file
welcome-filedefault.jsp/welcome-file
welcome-fileindex.html/welcome-file
/welcome-file-list

error-page
error-code403/error-code
location/403.jsp/location
/error-page



-Original Message-
From: Lukasz Lenart [mailto:lukasz.len...@googlemail.com] 
Sent: Wednesday, March 17, 2010 11:52 AM
To: Struts Users Mailing List
Subject: Re: SecurityContextHolder.getContext().getAuthentication() returning 
null

2010/3/17 Lance Hill la...@baldhead.com:
 Any hints about why SecurityContextHolder.getContext().getAuthentication()
 would return a null?

Spring version? Configuration? Did you try the simplest possible setup?


Regards
-- 
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org