Hi
the "@PreAuthorize("isAuthenticated()")" not really working.
I login like this:
spring-security.xml:Code:List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); authorities.add(new GrantedAuthorityImpl("ROLE_USER")); Authentication auth = new UsernamePasswordAuthenticationToken(username, password, authorities); SecurityContext securityContext = SecurityContextHolder.getContext(); securityContext.setAuthentication(auth); // Create a new session and add the security context. request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, securityContext);
Please helpCode:<?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/schem...-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> <http use-expressions="true"> <form-login login-page="/index.htm" /> <logout logout-url="/logout.htm" /> </http> <global-method-security pre-post-annotations="enabled"> </global-method-security> <authentication-manager alias="authenticationManager" /> </beans:beans>
thanks
from Peter (cmk128@hotmail.com)


Reply With Quote
