English 中文(简体)
三. 不处理前/后说明
原标题:Spring Security not processing pre/post annotations

我试图通过网络应用获得事先/后的说明,但出于某种原因,在春季安全方面没有发生。

网络:

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

<!-- 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>

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

<servlet>
    <servlet-name>rva</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>rva</servlet-name>
    <url-pattern>/rva/*</url-pattern>
 </servlet-mapping>

rvaContext-security.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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.0.xsd
       http://www.springframework.org/schema/security
       http://www.springframework.org/schema/security/spring-security-3.0.xsd">

<global-method-security pre-post-annotations="enabled"/>

<http use-expressions="true">
    <form-login login-page="/login" />
    <logout />
    <remember-me />
</http>
...

后勤舱:

@Controller
@RequestMapping("/login")
public class LoginController {

    @RequestMapping(method = RequestMethod.GET)
    public String login(ModelMap map){
        map.addAttribute("title", "Login: AD Credentials");
        return("login");
    }

    @RequestMapping("/secure")
    @PreAuthorize("hasRole( ROLE_USER )")
    public String secure(ModelMap map){
        return("secure");
    }
}
最佳回答

为了便于对控制人员进行自我说明,你应宣布<代码>和>;安全:全球方法安全 ....../> in the context of the controllers are declaration, that is in rva-servlet.xml.

问题回答

确实,你需要重新界定在座标书中的,该词也用于你的控制人员。 ∗∗∗∗ 页: 1 当把安全与Roo混为一谈时,混编的档案申请符合文字安全。 xml最初配置是为了便于这些说明。 令人困惑不解......

Spring Security FAQ(斜线地雷)。

In a Spring web application, the application context which holds the Spring MVC beans for the dispatcher servlet is often separate from the main application context. It is often defined in a file called myapp-servlet.xml, where “myapp” is the name assigned to the Spring DispatcherServlet in web.xml. An application can have multiple DispatcherServlets, each with its own isolated application context. The beans in these “child” contexts are not visible to the rest of the application. The “parent” application context is loaded by the ContextLoaderListener you define in your web.xml and is visible to all the child contexts. This parent context is usually where you define your security configuration, including the element). As a result any security constraints applied to methods in these web beans will not be enforced, since the beans cannot be seen from the DispatcherServlet context. You need to either move the declaration to the web context or moved the beans you want secured into the main application context.

Generally we would recommend applying method security at the service layer rather than on individual web controllers.

如果你对服务层适用点,那么你在安全方面只需要制定<条码>和>;全球-方法-安全”;





相关问题
Spring Security Encrypt MD5

I have a java web application using spring framework and spring security for its login. In my database I have my passwords encrypted to MD5 before being saved. I added in my application-config.xml ...

Grails security [closed]

Which is the best security solution for grails among acegi, jsecurity and Stark security?

Rewrite spring-security redirect URLs

I m trying to get Tuckey UrlRewriteFilter to tidy up URLs for my webapp. One problem I ve got is that when spring-security notices that an anonymous user is trying to access a protected resource it ...

Spring Security Custom freemarker form

I m currently working on a project were we use freemarker as a template language. Instead of using the defualt login form I have created a custom controller and a custom freemarker view which goes ...

Spring Security - Different Filter Entry Points based on Role

I m developing a webapp which allows for two types for users - User and Admin. There s are two parts of the site - the User side, and the Admin side. I m using Spring Security to secure both sites ...