未找到SAMLAuthenticationToken的AuthenticationProvider

时间:2014-09-25 15:29:21

标签: spring saml saml-2.0 spring-saml

我使用SSOCircle作为IDP提供程序并使用spring SAML。我已登录SSOCircle并创建了一个新的SP并在securityContext.xml中配置了唯一的entityID

我能够看到idp选择页面,但无法看到登录页面。添加的配置如下

<bean id="metadata" class="org.springframework.security.saml.metadata.CachingMetadataManager">  
  <constructor-arg>
        <list>
            <bean class="org.springframework.security.saml.metadata.ExtendedMetadataDelegate">
                <constructor-arg>
                    <bean class="org.opensaml.saml2.metadata.provider.ResourceBackedMetadataProvider">
                        <constructor-arg>
                            <bean class="java.util.Timer"/>
                        </constructor-arg>
                        <constructor-arg>
                            <bean class="org.opensaml.util.resource.ClasspathResource">
                                <constructor-arg value="/conf/spring_saml_metadata.xml"/>
                            </bean>
                        </constructor-arg>
                        <property name="parserPool" ref="parserPool"/>
                    </bean>
                </constructor-arg>
                <constructor-arg>
                    <bean class="org.springframework.security.saml.metadata.ExtendedMetadata">
                       <property name="local" value="true"/>
                       <property name="securityProfile" value="metaiop"/>
                       <property name="sslSecurityProfile" value="pkix"/>
                       <property name="sslHostnameVerification" value="default"/>
                       <property name="signMetadata" value="false"/>
                       <property name="signingKey" value="apollo"/>
                       <property name="encryptionKey" value="apollo"/>
                       <property name="requireArtifactResolveSigned" value="false"/>
                       <property name="requireLogoutRequestSigned" value="false"/>
                       <property name="requireLogoutResponseSigned" value="false"/>
                       <property name="idpDiscoveryEnabled" value="true"/>
                       <property name="idpDiscoveryURL" value="http://localhost:8080/myApp/saml/discovery"/>
                       <property name="idpDiscoveryResponseURL" value="http://localhost:8080/myApp/saml/login?disco=true"/>
                    </bean>
                </constructor-arg>
            </bean>
            <bean class="org.opensaml.saml2.metadata.provider.HTTPMetadataProvider">
                <constructor-arg>
                    <value type="java.lang.String">http://idp.ssocircle.com/idp-meta.xml</value>
                </constructor-arg>
                <constructor-arg>
                    <value type="int">15000</value>
                </constructor-arg>
                <property name="parserPool" ref="parserPool"/>
            </bean>
    </list></constructor-arg>
</bean>

实体ID的配置如下所述

<bean id="metadataGeneratorFilter" class="org.springframework.security.saml.metadata.MetadataGeneratorFilter">
    <constructor-arg>
        <bean class="org.springframework.security.saml.metadata.MetadataGenerator">
            <!-- <property name="entityId" value="urn:test:user:city"/> -->
            <property name="entityId" value="urn:myApp:useruser:dub"/>
            <property name="requestSigned" value="true"/>
        </bean>
    </constructor-arg>
</bean>

例外情况如下

 org.springframework.security.authentication.ProviderNotFoundException: No AuthenticationProvider found for org.springframework.security.saml.SAMLAuthenticationToken
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:196)
at org.springframework.security.saml.SAMLProcessingFilter.attemptAuthentication(SAMLProcessingFilter.java:84)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:195)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

2 个答案:

答案 0 :(得分:0)

该异常表示您的AuthenticationProvider缺少org.springframework.security.saml.SAMLAuthenticationProvider的实例,请确保您的securityContext.xml包含SAML身份验证提供程序的定义,类似于以下内容:

<security:authentication-manager alias="authenticationManager">
    <security:authentication-provider ref="samlAuthenticationProvider"/>
</security:authentication-manager>

答案 1 :(得分:0)

我有同样的问题,我在@Vladimir所说的spring xml中添加了samlAutheticationProvider。我仍然有同样的例外。当我调试代码并记录可用的身份验证管理器时,我无法找到新的saml身份验证管理器。 当我添加&#34; id&#34;在security:authentication-manager,它运作良好。

<security:authentication-manager  alias="samlAuthenticationManager" id="samlAuthenticationManager">
    <!-- Register authentication manager for SAML provider -->
    <security:authentication-provider ref="samlAuthenticationProvider"/>
</security:authentication-manager>

希望这有帮助。