gpt4 book ai didi

xml - Spring Beans 应用程序上下文上的 XPath 查询

转载 作者:行者123 更新时间:2023-12-03 16:30:55 26 4
gpt4 key购买 nike

使用 Xpath Query 我想获得这两个元素

<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"/>

来自这个 spring 配置文件
<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]

无济于事,tnx。我将在 maven maven-config-processor-plugin 上使用它,并在打包或安装期间在 spring 配置上动态插入一些东西。

最佳答案

如果您在 xpath 中使用命名空间,则必须在您使用 xapth 的上下文中定义命名空间。

如果这是不可能的,你可以使用这样的通配符:

//*:http[1]

-- 编辑 --

我刚刚看到你正在使用的 maven 插件 allows to define命名空间上下文。我想您可以使用它来定义您在 xpath 中使用的命名空间,而不是依赖通配符。

关于xml - Spring Beans 应用程序上下文上的 XPath 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31310165/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com