List of usage examples for org.springframework.security.web.authentication AnonymousAuthenticationFilter AnonymousAuthenticationFilter
AnonymousAuthenticationFilter
From source file:ch.astina.hesperid.web.services.SecurityModule.java
/** * Detects if there is no <code>Authentication</code> object in the * <code>SecurityContextHolder</code>, and populates it with one if needed. *//* w w w . ja v a2 s .c o m*/ @Marker(SpringSecurityServices.class) public static HttpServletRequestFilter buildAnonymousProcessingFilter( @Inject @Value("${spring-security.anonymous.attribute}") final String anonymousAttr, @Inject @Value("${spring-security.anonymous.key}") final String anonymousKey) throws Exception { AnonymousAuthenticationFilter filter = new AnonymousAuthenticationFilter(); filter.setKey(anonymousKey); UserAttributeEditor attrEditor = new UserAttributeEditor(); attrEditor.setAsText(anonymousAttr); UserAttribute attr = (UserAttribute) attrEditor.getValue(); filter.setUserAttribute(attr); filter.afterPropertiesSet(); return new HttpServletRequestFilterWrapper(filter); }