При переносе устаревшего приложения на spring безопасность я получил следующее исключение:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterChainProxy': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterChainList': Cannot resolve reference to bean '_filterSecurityInterceptor' while setting bean property 'filters' with key [3]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterSecurityInterceptor': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unsupported configuration attributes: [superadmin]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
В старом приложении есть такие роли, как "superadmin", "editor", "helpdesk" и т.д. Но во всех примерах безопасности spring я вижу только такие роли, как "ROLE_" ( "ROLE_ADMIN" и т.д.). Когда я переименую "superadmin" в "ROLE_ADMIN" и использую эту роль только в конфиге, все работает.
Не работает:
<http auto-config="true">
<intercept-url pattern="/restricted/**" access="superadmin"/>
<form-login
authentication-failure-url="/secure/loginAdmin.do?error=true"
login-page="/secure/loginAdmin.do" />
</http>
Работает:
<http auto-config="true">
<intercept-url pattern="/restricted/**" access="ROLE_ADMIN"/>
<form-login
authentication-failure-url="/secure/loginAdmin.do?error=true"
login-page="/secure/loginAdmin.do" />
</http>
Можно ли использовать собственные имена роли?