IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Java Discussion :

authentication-provider element cannot have child elements when used with 'ref'


Sujet :

Spring Java

  1. #1
    Nouveau membre du Club
    Inscrit en
    Février 2006
    Messages
    47
    Détails du profil
    Informations forums :
    Inscription : Février 2006
    Messages : 47
    Points : 31
    Points
    31
    Par défaut authentication-provider element cannot have child elements when used with 'ref'
    Bonjour,

    j'essaie de configurer spring security pour une authentification via ldap. Tout fonctionne bien jusqu'à que j'ajoute un encoder indispensable à l'authentification.
    voici ma configuration

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
     
    <beans xmlns:sec="http://www.springframework.org/schema/security"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    	xmlns="http://www.springframework.org/schema/beans"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
              http://www.springframework.org/schema/beans/spring-beans.xsd 
             http://www.springframework.org/schema/security 
             http://www.springframework.org/schema/security/spring-security-3.2.xsd">
     
     
    	<sec:http use-expressions="true" auto-config="true">
    		<sec:intercept-url pattern="/WEB-INF/home.xhtml" access="permitAll" />
     
    		<!-- <sec:logout logout-url="/j_spring_security_logout" -->
    		<!-- invalidate-session="true" /> -->
    		<sec:logout invalidate-session="true" logout-success-url="/index.xhtml"
    			delete-cookies="JSESSIONID" logout-url="/j_spring_security_logout" />
    		<sec:form-login login-processing-url="/j_spring_security_check"
    			login-page="/WEB-INF/index.xhtml" 
    			default-target-url="/WEB-INF/home.xhtml" 
    			authentication-failure-url="/index.xhtml?error=1" />
     
    		<sec:session-management invalid-session-url="/j_spring_security_logout" />
    	</sec:http>
     
     
    	<bean id="propertyConfigurer"
    		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="ignoreResourceNotFound" value="true" />
    		<property name="ignoreUnresolvablePlaceholders" value="false" />
    		<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
    		<property name="locations">
    			<list>
    				<value>
    					classpath:/jboss.properties
    				</value>
    			</list>
    		</property>
    	</bean>
     
    	<sec:authentication-manager alias="authenticationManager">
            <sec:authentication-provider ref="ldapAuthProvider" >
            	<sec:password-encoder hash="{sha}" />
            </sec:authentication-provider>
        </sec:authentication-manager>
     
    	<bean id="ldapUserSearch"
    		class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
    		<constructor-arg index="0" value="${ldap.user-search-base}" />
    		<constructor-arg index="1" value="${ldap.user-search-filter}" />
    		<constructor-arg index="2" ref="contextSource" />
    		<property name="searchSubtree" value="true" />
    	</bean>
     
    	<bean id="contextSource"
    		class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
    		<constructor-arg value="${ldap.url}" />
    		<property name="userDn" value="${ldap.manager-dn}" />
    		<property name="password" value="${ldap.manager-password}" />
    	</bean>
     
    	<bean id="ldapAuthProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
            <constructor-arg>
                <bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
                    <constructor-arg ref="contextSource"/>
                    <property name="userDnPatterns">
                        <list>
                            <value>"${ldap.user-search-base}"</value>
                        </list>
                    </property>
                </bean>
            </constructor-arg>
            <constructor-arg>
    			<bean id="ldapAuthoritiesPopulator"
    				class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">
    				<constructor-arg index="0" ref="contextSource" />
    				<constructor-arg index="1" value="${ldap.group-search-base}" />
    				<property name="groupSearchFilter" value="${ldap.group-search-filter}" />
    				<property name="groupRoleAttribute" value="${ldap.group-role-attribute}" />
    				<property name="rolePrefix" value="${ldap.role-prefix}" />
    				<property name="searchSubtree" value="true" />
    				<property name="convertToUpperCase" value="true" />
    			</bean>
            </constructor-arg>
        </bean>
     
    </beans>
    Au démarrage de l'application j'ai l'errue suivante:


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
     
    Context initialization failed: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:spring/applicationContext-security.xml]
    Offending resource: class path resource [spring/applicationContext.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: authentication-provider element cannot have child elements when used with 'ref' attribute
    Offending resource: class path resource [spring/applicationContext-security.xml]
    	at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
    	at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
    	at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
    	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:248)
    	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:199)
    	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
    	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:141)
    	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
    	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:542)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
    	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    	at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850)
    	at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90)
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    	at java.lang.Thread.run(Thread.java:744)
    Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: authentication-provider element cannot have child elements when used with 'ref' attribute

    Pour ma conf j'ai juste repris celle d'une application qui tourne déjà que j'ai adapté, et cette partie de la configuration est la meme, c'est ce que je ne comprend pas.
    Est ce que quelqu'un pourrait m'eclairer. Merci

  2. #2
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Bonjour,

    Configuration problem: authentication-provider element cannot have child elements when used with 'ref' attribute
    L'erreur est ici donc,
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <sec:authentication-provider ref="ldapAuthProvider" >
            	<sec:password-encoder hash="{sha}" />
            </sec:authentication-provider>
    à remplacer par
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    <sec:authentication-provider ref="ldapAuthProvider" />
    Crée un bean
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <bean id="encoder" class="org.springframework.security.authentication.encoding.ShaPasswordEncoder">
         <constructor-arg value="256"/>
     </bean>
    Regarde le doc ici pour SHA.

    et dans le bean bean id="ldapAuthProvider", ajoute à la fin
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    <property name="passwordEncoder" ref="encoder" />

    A+.

Discussions similaires

  1. Réponses: 4
    Dernier message: 07/03/2014, 10h29
  2. Zend_Form_Element requires each element to have a name
    Par ZYTROcypher dans le forum Zend Framework
    Réponses: 11
    Dernier message: 12/09/2013, 17h37
  3. Réponses: 19
    Dernier message: 17/11/2010, 16h31
  4. SimpleDeserializer encountered a child element
    Par devAd dans le forum Wildfly/JBoss
    Réponses: 1
    Dernier message: 02/04/2007, 13h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo