Announcement Announcement Module
Collapse
No announcement yet.
How do I access a boolean field from my security principal in JSTL? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I access a boolean field from my security principal in JSTL?

    Hi,

    I'm using Spring 3.1.1.RELEASE with accompanying Spring security. I want to access one of my Boolean value from a field in my UserDetails object. The object is

    Code:
    public class CustomAuthenticationUser implements UserDetails, CredentialsContainer
    {
    
        	...
    	private final Organization organization;
    	
    	/**
    	 * @return the organization
    	 */
    	public Organization getOrganization()
    	{
    		return organization;
    	}
    I want to say

    Code:
    				<c:if test="${not pageContext['request'].userPrincipal.organization.sampleOrg}">
    					print stuff
    but the above produces the exception

    Code:
    org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: The class 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken' does not have the property 'organization'.
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:413)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    	org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    	org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
    	org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:322)
    	org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
    	org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    	org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    	org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    	org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    	org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    	org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    	org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    	org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    	org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    	org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:184)
    	org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:155)
    	org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    	org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    How can I correct my JSTL to properly reference my property? Thanks, - Dave
Working...
X