gpt4 book ai didi

spring - Vaadin 7.1 + Spring-Security 集成在 Tomcat 服务器中运行

转载 作者:行者123 更新时间:2023-12-04 04:05:43 25 4
gpt4 key购买 nike

我是 vaadin 和 spring security 的新手,我想知道是否有人有一个完整的 vaadin 7.1 + spring-security 集成在 tomcat 服务器(不在码头)中运行的项目示例。

最佳答案

Vaadin 7 与 Spring Security 轻松集成。您应该只配置 2 个文件。第一个 - web.xml 和第二个 spring-security.xml(用户凭据和安全设置)。这是如何使用基本表单进行身份验证的小示例。

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>Vaadin7SpringSecurity</display-name>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/spring-security.xml
</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- filter declaration for Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

spring-security.xml
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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-3.1.xsd">

<http auto-config='true'>
<intercept-url pattern="/*" access="ROLE_USER" />
</http>

<authentication-manager>
<authentication-provider>
<user-service>
<user name="user" password="password" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>

</beans:beans>

更多详情,如何扩展 spring-security.xml 您可以使用的配置 Spring resources .

关于spring - Vaadin 7.1 + Spring-Security 集成在 Tomcat 服务器中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18605904/

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