我正在尝试配置应该仅支持https的应用程序,并且我在securityContext.xml文件中添加了以下配置:
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="org.apache.commons.httpclient.protocol.Protocol"/>
<property name="targetMethod" value="registerProtocol"/>
<property name="arguments">
<list>
<value>https</value>
<bean class="org.apache.commons.httpclient.protocol.Protocol">
<constructor-arg value="https"/>
<constructor-arg>
<bean class="org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory"/>
</constructor-arg>
<constructor-arg value="443"/>
</bean>
</list>
</property>
</bean>
在运行服务器时,我遇到以下异常:
引起:org.springframework.beans.factory.BeanCreationException:创建名称为&#39; org.apache.commons.httpclient.protocol.Pr的bean时出错 otocol#59a20678&#39;在ServletContext资源[/WEB-INF/securityContext.xml]中定义:无法创建内部bean&#39; org.springframework.security.s aml.trust.httpclient.TLSProtocolSocketFactory#5658808&#39;类型为[org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory] 设置构造函数参数时;嵌套异常是org.springframework.beans.factory.BeanCreationException:使用n创建bean时出错 ame&#39; org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory#5658808&#39;在ServletContext资源中定义[/ WEB-INF / secur ityContext.xml]:bean的实例化失败;嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例化 te bean类[org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory]:找不到默认构造函数;嵌套异常 是java.lang.NoSuchMethodException:org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory。() 在org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281) 在org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:12 0) at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630) 在org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFacto) ry.java:1035) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactor) y.java:939) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java) :485) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:4 56) 在org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270) ......还有24个 引起:org.springframework.beans.factory.BeanCreationException:创建名称为&#39; org.springframework.security.saml.trust.h的bean时出错 ttpclient.TLSProtocolSocketFactory#5658808&#39;在ServletContext资源[/WEB-INF/securityContext.xml]中定义:bean的实例化失败; 嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例化bean类[org.springframework.security.sa ml.trust.httpclient.TLSProtocolSocketFactory]:找不到默认构造函数;嵌套异常是java.lang.NoSuchMethodException:org.spring framework.security.saml.trust.httpclient.TLSProtocolSocketFactory。() 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.j) AVA:997) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactor) y.java:943) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java) :485) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:4 56) 在org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270) ......还有32个 引起:org.springframework.beans.BeanInstantiationException:无法实例化bean类[org.springframework.security.saml.trust.h ttpclient.TLSProtocolSocketFactory]:找不到默认构造函数;嵌套异常是java.lang.NoSuchMethodException:org.springframework。 security.saml.trust.httpclient.TLSProtocolSocketFactory。() 在org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:72) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.j) AVA:990) ......还有36个 引起:java.lang.NoSuchMethodException:org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory。() at java.lang.Class.getConstructor0(Class.java:2971) at java.lang.Class.getDeclaredConstructor(Class.java:2165) 在org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:67) ......还有37个 错误listenerStart
请您指导我如何纠正这个问题。我有最新的行李箱。
答案 0 :(得分:0)
TLSProtocolSocketFactory
需要为其构造函数提供多个参数,而这些参数未指定,这就是配置失败的原因。
如果您希望Spring SAML自动配置TLSProtocolSocketFactory
,只需按照manual (chapter 7.2.3)中的说明操作,并包含以下bean而不是MethodInvokingFactoryBean
:
<bean class="org.springframework.security.saml.trust.httpclient.TLSProtocolConfigurer"/>
如果您不想使用TLSProtocolConfigurer
,另一种方法是包含以下应该具有相同效果的bean:
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="org.apache.commons.httpclient.protocol.Protocol"/>
<property name="targetMethod" value="registerProtocol"/>
<property name="arguments">
<list>
<value>https</value>
<bean class="org.apache.commons.httpclient.protocol.Protocol">
<constructor-arg value="https"/>
<constructor-arg>
<bean class="org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory">
<constructor-arg ref="keyManager"/>
<constructor-arg><null/></constructor-arg>
<constructor-arg value="default"/>
</bean>
</constructor-arg>
<constructor-arg value="443"/>
</bean>
</list>
</property>
</bean>