Привет! Я создал файл security-app-context.xml для моего приложения grails / groovy.Это выглядит следующим образом:
<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/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http use-expressions="true">
<intercept-url pattern="/js/**" access="IS_AUTHENTICATED_FULLY" />
<intercept-url pattern="/css/**" access="IS_AUTHENTICATED_FULLY" />
<intercept-url pattern="/images/**" access="IS_AUTHENTICATED_FULLY" />
<intercept-url pattern="/swf/**" access="IS_AUTHENTICATED_FULLY" />
<form-login />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" password="password" authorities="supervisor, teller, user" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
Я отредактировал свой web.xml следующим образом:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml
/WEB-INF/security-app-context.xml --> added this
</param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter>
filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Я добавил spring-security-acl-3.1.0.M2.jar, spring-security-config-3.1.0.M2.jar, spring-security-core-3.1.0.M2.jar, spring-security-taglibs-3.1.0.M2.jar и spring-security-web-3.1.0.M2.jar в моей библиотеке, но я получаю сообщение об ошибке при запуске сервера tomcat, говорящее
org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0': Cannot create inner bean '(inner bean)' of type [org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource] while setting bean property 'securityMetadataSource'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#5': Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.security.web.util.UrlMatcher]: Could not convert constructor argument value of type [java.util.LinkedHashMap] to required type [org.springframework.security.web.util.UrlMatcher]: Failed to convert value of type 'java.util.LinkedHashMap' to required type 'org.springframework.security.web.util.UrlMatcher'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.util.LinkedHashMap] to required type [org.springframework.security.web.util.UrlMatcher]: no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:125)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
.........and some other exceptions
Я установил плагин ядра безопасности Spring, необходимо определить полномочия в security-app-context.xmlгде-то?Не уверен, где мне не хватает, если что-нибудь, я следовал учебнику весенней безопасности ..