Spring Security 2 configuration in intensive

Source: Internet
Author: User

Security Rights Management Handbook http://www.family168.com/oa/springsecurity/html/

As we all know, a major improvement in Spring security for Acegi is that its configuration is greatly simplified. So if the configuration is based on the cumbersome configuration of acegi-1.x, then we might as well use the acegi instead of upgrading. So here, I'll combine an example to focus on how the Spring security 2 is configured to simplify.

Build a basic environment

First of all, we set up the basic development environment for the example, the way of setting up the environment, can refer to my another article: STRUTS2 Development environment Construction

The construction of the whole environment includes: creating the appropriate directory structure, adding the appropriate library, joining the basic jetty startup classes, adding basic configuration files, and so on. The final project structure can refer to my attachment.

Reference documentation

The main reference document here is the reference of spring security. On the internet there is a translation of its Chinese, the address is as follows: http://www.family168.com/tutorial/springsecurity/html/springsecurity.html

In addition, Springside has a more complete example, but based on the Acegi, I also see some of these implementations.

Spring Security Basic Configuration

Spring security is a permissions certification framework based on spring, and for those of you who are already familiar with spring and Acegi, the previous configuration should already be well understood. The next example will show you how spring security is based on the schema configuration.

Minimize configuration

1. Add the filter statement to the Web.xml file

XML code

<!-- Spring security Filter -->
<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>

<!-- Spring security Filter -->
<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>

This filter intercepts all URL requests and verifies these URL requests with spring security.

Note that the name Springsecurityfilterchain is the ID of an internal bean that was created by default in the namespace to handle web security. So you should not use this ID as your bean in your spring configuration file.

Unlike the Acegi configuration, Acegi needs to declare a spring bean as an implementation of the filter, and using spring security eliminates the need for additional definition of the bean and uses the

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.