Announcement Announcement Module
Collapse
No announcement yet.
Spring Security tags does not work Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Security tags does not work

    Hello!

    I have a problem with spring security tags. They just doesn't work.
    When I use <security:authorize ifAnyGranted="ROLE_USER"> .... </security:authorize> it's not interpeted and I get it in result HTML.
    I'm using spring security (and tag lib) 2.0.5.RELEASE

    My config:

    <beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-2.0.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-2.0.1.xsd">

    <http auto-config="true">
    <intercept-url pattern="/app/login/**"
    access="IS_AUTHENTICATED_ANONYMOUSLY" />
    <intercept-url pattern="/app/m**" access="ROLE_USER" />
    <form-login default-target-url="/app/menu" login-page="/app/login"
    always-use-default-target="false"
    authentication-failure-url="/app/login?authfailed=true"/>
    </http>

    <beans:bean id="daoAuthenticationProvider"

    class="org.springframework.security.providers.dao. DaoAuthenticationProvider">
    <beansroperty name="userDetailsService" ref="userDetailsService" /

    <custom-authentication-provider />
    </beans:bean>
    <beans:bean id="userDetailsService"
    class="pl.app.UserDetailsServiceImpl" />

    </beans:beans>

    sample XHTML:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:c="http://java.sun.com/jstl/core"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:security="http://www.springframework.org/security/tags">

    <ui:composition template="/WEB-INF/layout/template.xhtml">
    <ui:define name="body">
    <security:authorize ifAnyGranted="ROLE_USER">
    <h:commandButton action="options" value="Opcje" />
    </security:authorize>
    </ui:define>
    </ui:composition>
    </html>

    I thought that annotations might solve the problem, but when I added:

    <global-method-security secured-annotations="enabled">
    </global-method-security>

    I got an exception:
    org.springframework.beans.factory.parsing.BeanDefi nitionParsingException:
    Configuration problem: Cannot locate
    'org.springframework.security.annotation.SecuredMe thodDefinitionSource'
    Offending resource: ServletContext resource [/WEB-INF/config/
    applicationContext-security.xml]
    at
    org.springframework.beans.factory.parsing.FailFast ProblemReporter.error
    (FailFastProblemReporter.java:68)
    at org.springframework.beans.factory.parsing.ReaderCo ntext.error
    (ReaderContext.java:85)
    at org.springframework.beans.factory.parsing.ReaderCo ntext.error
    (ReaderContext.java:72)
    at
    org.springframework.security.config.GlobalMethodSe curityBeanDefinitionParser.validatePresent
    (GlobalMethodSecurityBeanDefinitionParser.java:47)
    at
    org.springframework.security.config.GlobalMethodSe curityBeanDefinitionParser.registerAnnotationBased MethodDefinitionSources
    (GlobalMethodSecurityBeanDefinitionParser.java:103 )
    at
    org.springframework.security.config.GlobalMethodSe curityBeanDefinitionParser.parse
    (GlobalMethodSecurityBeanDefinitionParser.java:56)
    at
    org.springframework.beans.factory.xml.NamespaceHan dlerSupport.parse
    (NamespaceHandlerSupport.java:69)
    at
    org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement
    (BeanDefinitionParserDelegate.java:1297)
    at
    org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement
    (BeanDefinitionParserDelegate.java:1287)
    at
    org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.parseBeanDefinitions
    (DefaultBeanDefinitionDocumentReader.java:135)
    at
    org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.registerBeanDefinitions
    (DefaultBeanDefinitionDocumentReader.java:92)
    at
    org.springframework.beans.factory.xml.XmlBeanDefin itionReader.registerBeanDefinitions
    (XmlBeanDefinitionReader.java:507)
    at
    org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions
    (XmlBeanDefinitionReader.java:398)
    at
    org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions
    (XmlBeanDefinitionReader.java:342)
    ...

    I'm using JSF + Spring WebFlow, Richfaces ,Spring 2.5.6
    Anyone knows what can be the problem ?
    Thanks in advance for help !

    Regards,
    Łukasz
Working...
X