English 中文(简体)
2. 通过春季批准 不符合习俗的说明
原标题:Spring Authorization via Annotations not working with custom Authentication

I ve overcraft the BasicAuthenticationFilter, 取而代之的是我们的过滤器,从db中挑选出一种习俗的异构化物,然后通过 d子确定。

SecurityContextHolder.getContext().setAuthentication(auth);

这里是安全大厦的重要部分:

<http use-expressions="true" entry-point-ref="authEntryPoint">
    <custom-filter position="BASIC_AUTH_FILTER" ref="basicProcessingFilter" />
    <intercept-url pattern="/**" access="hasRole( user )"/>
</http>
<beans:bean id="authEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
    <beans:property name="loginFormUrl" value="/login"/>
</beans:bean>
<global-method-security jsr250-annotations="enabled"/>

我也提供我自己的AusthenticationProvider,由于认证程序已经在海关过滤器中进行,这只是一种不可行的做法:

@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    logger.info("user:" + authentication.getPrincipal() + " pw:" + authentication.getCredentials());
    authentication.setAuthenticated(false);        
    return authentication;
}

@Override
public boolean supports(Class<? extends Object> authentication) {
    return MyAuthentication.class.isAssignableFrom(authentication);
}

Now, Spring correctly prints the required role(s) for every method on start, so it detects the annotations correctly. E.g. the admin role for a delete method:

2011-11-22 11:47:09,474 [main] DEBUG org.childrenframework.security.access.method.DelegatingMethod SecurityMetadataSource - Adding security methods [CacheKey[com.somecompany.SomeClass; public com.somecompany.ReturnType comsomecompany.SomeClass.delete()] [admin]

www.un.org/Depts/DGACM/index_spanish.htm 但是,如果用户发挥这种作用,春天不会检查一些情况。 相反,它又回到了安全环境的标签xml文档中界定的全球格局。 因此,例如,如果我能用角色用户使用这一删除方法:由于用户在http tag中的“Role”(用户)而接受。

也许,在开始使用DefaultFilter Invention SecurityMetadataSource标语时,这是错误的,因为它赢得了一条关于删除方法的具体规则! 仅通过添加SecureUrl方法添加了“http-tag”定义的规则。

www.un.org/Depts/DGACM/index_spanish.htm 什么可能是错误的?

最佳回答

前进

<global-method-security jsr250-annotations="enabled"/>

从春天的安全背景到我扫描这些班级(即我的申请背景)的情况。 由于的评论,本回答

问题回答

暂无回答




相关问题
array dependency injection in spring?

is there a way to use dependency injection to inject all available implementations of a specific interface in spring? This is kind of the same thing as asked here for .NET. Though my aim is to use @...

Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and ...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

热门标签