[英]Spring SAML cant read property from properties file
So this one stumps me. 所以这一点让我感到难过。 I have been using properties files for years now, but I have never seen this. 我已经使用属性文件多年了,但是我从未见过。
I am using Spring MVC with SAML authentication. 我正在使用带有SAML身份验证的Spring MVC。 my context xml has this in it: 我的上下文xml中包含以下内容:
<context:property-placeholder location="file:/opt/saml.properties" />
<bean id="keyManager" class="org.springframework.security.saml.key.JKSKeyManager">
<constructor-arg value="file:/opt/mySamlKeystore.jks"/>
<constructor-arg type="java.lang.String" value="${keystore.password}"/>
<constructor-arg>
<map>
<entry key="${privateKey.alias}" value="${key.password}"/>
</map>
</constructor-arg>
<constructor-arg type="java.lang.String" value="${privateKey.alias}"/>
</bean>
I am getting this error: 我收到此错误:
java.security.UnrecoverableKeyException: Cannot recover key
I so some SO research and they all say basically that I have the wrong password, which im sure I don't. 我进行了一些SO研究,他们基本上都说我输入了错误的密码,但我肯定没有。 So to test that it's reading the right file, I go and replace all the properties %{} and hard code them. 因此,要测试它正在读取正确的文件,我去替换所有属性%{}并对其进行硬编码。 Everything then works fine. 然后,一切正常。
I am trying to figure this out, when I noticed that some of the other properties from that file are working! 当我发现该文件中的其他一些属性正在运行时,我正在尝试解决这个问题! In fact, I can even do this: 实际上,我什至可以做到这一点:
<bean id="keyManager" class="org.springframework.security.saml.key.JKSKeyManager">
<constructor-arg value="file:/opt/myKeystore.jks"/>
<constructor-arg type="java.lang.String" value="${keystore.password}"/>
<constructor-arg>
<map>
<entry key="${privateKey.alias}" value="password"/>
</map>
</constructor-arg>
<constructor-arg type="java.lang.String" value="${privateKey.alias}"/>
</bean>
So spring is getting ${keystore.password} and ${privateKey.alias} (Along with others needed like entityID, metadataProvider, etc...) from the properties file, but not ${key.password} !!! 因此,春天从属性文件中获得了$ {keystore.password}和$ {privateKey.alias}(以及其他需要的实体ID,metadataProvider等),但不是$ {key.password}!
here is the saml.properties 这是saml.properties
#keystore stuff
keystore.password=password
key.password=password
privateKey.alias=mysaml
#SP stuff (aka, my side of things)
entity.id=mycompany:me:me:me1
entity.base.url=https://mycompany.com
#IDP stuff (aka, the SAML server)
metadata.provider=https://saml.mycompany.com/FederationMetadata/2007-06/FederationMetadata.xml
This is all working when I hard coded the key password, but not when I use the ${key.password} property. 当我对密钥密码进行硬编码时,所有这些都可以正常工作,但是当我使用$ {key.password}属性时,则无法正常工作。 What is going on here? 这里发生了什么?
you have two more slash after file 归档后您还有两个斜杠
For example 例如
<bean id="keyManager" class="org.springframework.security.saml.key.JKSKeyManager">
<constructor-arg value="file:///opt/myKeystore.jks"/>
<constructor-arg type="java.lang.String" value="${keystore.password}"/>
<constructor-arg>
<map>
<entry key="${privateKey.alias}" value="password"/>
</map>
</constructor-arg>
<constructor-arg type="java.lang.String" value="${privateKey.alias}"/>
</bean>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.