-
Oct 28th, 2012, 01:05 PM
#1
Using Spring EL expressions inside a spring security xml configuration file
Hi,
I'm trying to configure a remember-me setting in xml using spring expression language.
We frequently modify our spring configuration from a properties file by using spel to grab properties from the file, and then using a different properties file in a different deployment.
So in some properties files there would be a key named ssl with a value of true, and in others the key would have a value of false.
The config file looks something like this:
<util:properties id="appProperties" location="classpath:application.properties"/>
<http use-expressions="true" auto-config="true" create-session="stateless">
<!-- more things go here -->
<remember-me token-validity-seconds="3600" key="smartStepsKey" use-secure-cookie="#{ appProperties['ssl'] }" />
</http>
With most other areas of spring this works fine, but when I try to manipulate the remember-me element that way, I get an exception (stack trace below).
Is this something I should expect to be able to do? If not, is there a simple workaround that I've overlooked?
Cheers,
Sean
Stack trace:
org.springframework.beans.factory.xml.XmlBeanDefin itionStoreException: Line 54 in XML document from ServletContext resource [/WEB-INF/applicationContext-security.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 54; columnNumber: 162; cvc-datatype-valid.1.2.1: '#{ appProperties['ssl'] }' is not a valid value for 'boolean'.
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:76)
at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.importBeanDefinitionResour ce(DefaultBeanDefinitionDocumentReader.java:271)
at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.parseDefaultElement(Defaul tBeanDefinitionDocumentReader.java:196)
at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.parseBeanDefinitions(Defau ltBeanDefinitionDocumentReader.java:181)
at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.doRegisterBeanDefinitions( DefaultBeanDefinitionDocumentReader.java:140)
at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.registerBeanDefinitions(De faultBeanDefinitionDocumentReader.java:111)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.registerBeanDefinitions(XmlBeanDefinit ionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:302)
at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:174)
at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:209)
at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:125)
at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:94)
at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:527)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:441)
at org.springframework.web.context.ContextLoader.conf igureAndRefreshWebApplicationContext(ContextLoader .java:383)
at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 111)
...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules