2015-07-09 3 views
2

с помощью Xpath запроса я хотел бы получить эти 2 элементаXPath запросов на Spring контексте Фасоль Application

<security:http realm="Protected API" use-expressions="true" auto-config="false" create-session="always" 
         entry-point-ref="authenticationEntryPoint"> 
      <security:custom-filter ref="covAuthFilter" position="FORM_LOGIN_FILTER"/> 

из этой весной конфигурационный файл

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:security="http://www.springframework.org/schema/security" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
     http://www.springframework.org/schema/security 
     http://www.springframework.org/schema/security/spring-security.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> 


<security:http pattern="/data/**" security="none"/> 
<security:http pattern="/js/**" security="none"/> 
<security:http pattern="/css/**" security="none"/> 
<security:http pattern="/fonts/**" security="none"/> 
<security:http pattern="/img/**" security="none"/> 
<security:http pattern="/ckeditor/getImage**" security="none"/> 

<beans profile="default"> 

    <!-- Windows login uses a different entry point --> 
    <security:http use-expressions="true" pattern="/windows" auto-config="false" 
        entry-point-ref="negotiateSecurityFilterEntryPoint"> 
     <security:intercept-url pattern="/**" access="isAuthenticated()"/> 
     <security:custom-filter ref="waffleNegotiateSecurityFilter" position="FORM_LOGIN_FILTER"/> 
    </security:http> 

    <security:http realm="Protected API" use-expressions="true" auto-config="false" create-session="always" 
        entry-point-ref="authenticationEntryPoint"> 
     <security:custom-filter ref="bAuthFilter" position="FORM_LOGIN_FILTER"/> 
     <!--<security:custom-filter ref="csrfFilter" after="CSRF_FILTER"/>--> 
     <!--<security:intercept-url pattern="/**" access="permitAll"/>--> 
     <!-- Temporarily disable authentication until JSESSIONID/token management strategy can be determined --> 

     <!-- public access --> 
     <!-- apis --> 
     <security:intercept-url pattern="/api/login**" access="permitAll"/> 
     <security:intercept-url pattern="/api/appsettings/loginWarning" access="permitAll"/> 
     <security:intercept-url pattern="/api/loginwarning/agree" access="permitAll"/> 
     <security:intercept-url pattern="/api/about**" access="permitAll"/> 

     <security:access-denied-handler error-page="/login/"/> 
     <security:logout 
       logout-url="/api/logout" success-handler-ref="logoutSuccessHandler" 
       /> 
     <security:custom-filter ref="x509AuthenticationFilter" position="X509_FILTER"/> 

     <!--<security:csrf token-repository-ref="csrfTokenRepository"/>--> 
    </security:http> 


    <!-- Configure Waffle entry point --> 
    <beans:bean id="negotiateSecurityFilterEntryPoint" class="waffle.spring.NegotiateSecurityFilterEntryPoint"> 
     <beans:property name="provider" ref="waffleSecurityFilterProviderCollection"/> 
    </beans:bean> 

    <bean id="authenticationEntryPoint" 
      class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint"> 
     <constructor-arg name="loginFormUrl" value="/login/"/> 
    </bean> 


    <bean id="logoutSuccessHandler" class="bherto.testsecurity.LogoutSuccessHandler"> 
    </bean> 

    <security:authentication-manager erase-credentials="true" alias="authenticationManager"> 
     <security:authentication-provider ref="daoAuthenticationProvider"/> 
     <security:authentication-provider ref="preAuthProvider"/> 
    </security:authentication-manager> 

    <!-- Class responsible for retrieving user from submitted user name --> 
    <beans:bean id="abstractUserDetailsService" class="bherto.security.auth.AbstractUserDetailsService" 
       abstract="true"/> 
    <beans:bean id="usernameUserDetailsService" class="bherto.testsecurity.UserDetailsServiceImpl" 
       parent="abstractUserDetailsService"> 
     <beans:property name="accountLookupService" ref="bherto.non.lookupByLoginId"/> 
    </beans:bean> 
    <beans:bean id="dnUserDetailsService" class="bherto.testsecurity.UserDetailsServiceImpl" 
       parent="abstractUserDetailsService"> 
     <beans:property name="accountLookupService" ref="bherto.non.lookupByDNService"/> 
    </beans:bean> 

    <bean id="daoAuthenticationProvider" 
      class="org.springframework.security.authentication.dao.DaoAuthenticationProvider"> 
     <beans:property name="userDetailsService" ref="usernameUserDetailsService"/> 

     <property name="passwordEncoder" ref="shaPasswordEncoder"/> 
     <property name="saltSource"> 
      <bean class="org.springframework.security.authentication.dao.ReflectionSaltSource"> 
       <property name="userPropertyToUse" value="username"/> 
      </bean> 
     </property> 
     <beans:property name="postAuthenticationChecks" ref="bUserDetailsChecker"/> 
    </bean> 

    <beans:bean id="preAuthProvider" 
       class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider"> 
     <beans:property name="preAuthenticatedUserDetailsService"> 
      <beans:bean class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper"> 
       <beans:property name="userDetailsService" ref="dnUserDetailsService"/> 
      </beans:bean> 
     </beans:property> 
     <beans:property name="userDetailsChecker" ref="bUserDetailsChecker"/> 
    </beans:bean> 


    <!-- Auth success handler returns HTTP 200 (ok) to alert user that login was successfull --> 
    <bean id="bAuthSuccessHandler" class="bherto.testsecurity.bAuthenticationSuccessHandler"/> 

    <bean id="bAuthFailureHandler" class="bherto.testsecurity.bAuthenticationFailureHandler"/> 


    <beans:bean id="sas" 
       class="org.springframework.security.web.authentication.session.CompositeSessionAuthenticationStrategy"> 
     <beans:constructor-arg> 
      <beans:list> 
       <beans:ref bean="concurrentSessionControlAuthenticationStrategy"/> 
       <beans:bean 
         class="org.springframework.security.web.authentication.session.SessionFixationProtectionStrategy"/> 
       <beans:bean 
         class="org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy"> 
        <beans:constructor-arg ref="sessionRegistry"/> 
       </beans:bean> 
      </beans:list> 
     </beans:constructor-arg> 

    </beans:bean> 

    <beans:bean id="concurrentSessionControlAuthenticationStrategy" 
       class="bherto.security.session.XConcurrentSessionControlAuthenticationStrategy"> 
     <beans:constructor-arg ref="sessionRegistry"/> 
     <beans:property name="maximumSessions" value="-1"/> 
     <beans:property name="exceptionIfMaximumExceeded" value="true"/> 
    </beans:bean> 

    <beans:bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl"/> 

    <beans:bean id="nullRequestCache" class="org.springframework.security.web.savedrequest.NullRequestCache"/> 

    <bean id="bherto.non.lookupByDNService" class="bherto.security.auth.LookupByDNService"/> 
    <bean id="bherto.non.lookupByLoginId" class="bherto.security.auth.LookupByLoginIdService"/> 

</beans> 

<beans profile="insecure"> 
    <bean id="springSecurityFilterChain" 
      class="bherto.testsecurity.InsecureFilterChain"/> 
</beans> 

Я попытался следующие:

//s:beans//security:http[1] 

//security:http[1] 

до нет ail, tnx. Я буду использовать это на maven-config-processor-plugin и вставить что-то динамически в конфигурацию пружины во время пакета или установки.

ответ

1

при использовании пространств имен в XPath пространство имен должно быть определено в контексте, который вы используете в xapth в

, если это не возможно, вы могли бы использовать подстановочные так:.

//*:http[1] 

- редактировать -

я только что видел, что Maven плагин вы используете allows to define пространства имен контексты. я полагаю, вы могли бы использовать это, чтобы определить пространства имен, которые вы используете в своем xpath, вместо того, чтобы полагаться на подстановочные знаки.

+0

Очень хорошо, что я прошел второе редактирование, я понял, что мне просто нужно использовать _italic_ в config-processor-maven-plugin, поэтому мне пришлось избегать // *: http [1] подстановочные знаки пространства имен. спасибо @ andr% c3% a9-r – bherto39

Смежные вопросы