不能使我的vaadin应用程序使用spring安全性

时间:2014-12-22 12:32:49

标签: spring-security vaadin

我正在尝试使用Spring Security添加身份验证。

我创建了security context

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

    <http auto-config="true">
        <intercept-url pattern="/*" access="ROLE_USER, ROLE_ADMIN, ROLE_ANONYMOUS"/>
        <form-login login-page="/login" default-target-url="/login" authentication-failure-url="/login/?error=true"/>
    </http>

    <authentication-manager>
        <authentication-provider>
            <user-service>
                <user name="user" password="pass" authorities="ROLE_USER"/>
                <user name="admin" password="admin" authorities="ROLE_ADMIN, ROLE_USER"/>
            </user-service>
        </authentication-provider>
    </authentication-manager>

</beans:beans>

并将其作为资源导入主上下文文件中。

我的web.xml看起来像这样

<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5">

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:/pmc-web-context.xml
        </param-value>
    </context-param>

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

    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>another-pmc-servlet</servlet-name>
        <servlet-class>ru.xpoft.vaadin.SpringVaadinServlet</servlet-class>
        <init-param>
            <param-name>beanName</param-name>
            <param-value>pmcVaadin</param-value>
        </init-param>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value></param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>another-pmc-servlet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

    <!-- Spring Security -->
    <servlet>
        <servlet-name>login-pmc-servlet</servlet-name>
        <servlet-class>ru.xpoft.vaadin.SpringVaadinServlet</servlet-class>
        <init-param>
            <param-name>beanName</param-name>
            <param-value>loginVaadin</param-value>
        </init-param>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value></param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>login-pmc-servlet</servlet-name>
        <url-pattern>/login</url-pattern>
    </servlet-mapping>
    <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>

但是当我使用localhost:8080/pmc-web运行我的应用程序时,它会打开我的主应用程序pmcVaadin,甚至没有显示登录窗口(loginVaadin应用程序)

为什么呢?有什么问题?

我的pmcVaadin组件是一个类,从UI

扩展而来
@Title("PMC")
@Component("pmcVaadin")
@Scope("prototype")
public class PmcUi extends UI implements ErrorHandler {

我的loginVaadin组件是相同的

@Title("PMC")
@Component("loginVaadin")
@Scope("prototype")
public class LoginUi extends UI {

0 个答案:

没有答案