2015-06-25 7 views
0

У меня возникли проблемы с обеспечением весенней безопасности для статического веб-проекта.Весенняя безопасность для статического веб-проекта

мой web.xml

<?xml version="1.0"?> 
<web-app xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" id="WebApp_ID"> 
    <display-name>Spring Security Application</display-name> 

    <listener> 
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 
    <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value> /WEB-INF/spring-security.xml </param-value> 
    </context-param> 
    <!-- 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> 

и моя весна-security.xml

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:security="http://www.springframework.org/schema/security" 
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.0.xsd 
     http://www.springframework.org/schema/security 
     http://www.springframework.org/schema/security/spring-security.xsd"> 

<security:http auto-config="true" use-expressions="true"> 

    <security:intercept-url pattern="/security/html/folder1/**" access="isAnonymous()" /> 

    <security:intercept-url pattern="/security/html/folder2/**" access="isAuthenticated()" /> 

    <security:intercept-url pattern="/security/html/folder3/**" access="hasRole('ROLE_MANAGER')" /> 
    <security:intercept-url pattern="/security/html/folder4/**" access="hasRole('ROLE_ADMIN','ROLE_USER','ROLE_MANAGER')" /> 

    <security:form-login password-parameter="password" username-parameter="username" authentication-failure-url="/login?error" login-page="/login" /> 
    <security:logout logout-success-url="/login?logout" /> 

</security:http> 

<security:authentication-manager> 
    <security:authentication-provider> 
     <security:user-service> 
      <security:user name="user1" password="password" authorities="ROLE_USER, ROLE_ADMIN" /> 
      <security:user name="user2" password="password" authorities="ROLE_USER" /> 
      <security:user name="user3" password="password" authorities="ROLE_MANAGER" /> 
      <security:user name="user4" password="password" authorities="ROLE_ADMIN" /> 
      <security:user name="user5" password="password" authorities="ROLE_USER, ROLE_MANAGER" /> 
      <security:user name="user6" password="password" authorities="ROLE_ADMIN, ROLE_MANAGER" /> 
      <security:user name="user7" password="password" authorities="ROLE_ADMIN, ROLE_USER, ROLE_MANAGER" /> 
     </security:user-service> 
    </security:authentication-provider> 
</security:authentication-manager> 

Моя структура папок являются SRC/главная/веб-приложение/WEB-INF/веб. xml

src/main/webapp/WEB-INF/spring-security.xml

SRC/Главный/WebApp/WEB-INF/HTML/папка1/*. HTML

SRC/Главный/WebApp/WEB-INF/HTML/folder2/*. HTML

SRC/Основной/WebApp /WEB-INF/html/folder3/*.html

SRC/главная/веб-приложение/WEB-INF/html/Folder4/*. HTML

у меня нет какой-либо страницы приветствия или любые другие файлы в Java мой проект. Мне нужно это для развертывания на сервере Tomcat.

Может ли один помочь мне, если я пропускаю что-либо в файлах конфигурации

+0

Можете ли вы предоставить более подробную информацию о вашей проблеме? О каких проблемах вы говорите? – Dherik

ответ

1

Я нашел ответ на мой вопрос.

Две ошибки.

  1. мне пришлось удалить/безопасность от перехвата-URL, как безопасность мой корневой контекст
  2. Переместить HTML папку из WEB-INF